diff options
author | Neil Moore <neil@s-z.org> | 2013-06-25 21:26:16 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-06-25 21:26:16 -0400 |
commit | cca2df18b6fb1f59109847a27292fd4bbb4e1de1 (patch) | |
tree | 2a0b13c06b2f7f5985f06e24756a201a3f9d660f /crawl-ref/source/data-index.h | |
parent | 9c62d115c66329943db7e17718b3de3736b568a2 (diff) | |
download | crawl-ref-cca2df18b6fb1f59109847a27292fd4bbb4e1de1.tar.gz crawl-ref-cca2df18b6fb1f59109847a27292fd4bbb4e1de1.zip |
Check ranges in data_index directly.
Also, have operator[] take a key rather than a raw integer.
Diffstat (limited to 'crawl-ref/source/data-index.h')
-rw-r--r-- | crawl-ref/source/data-index.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crawl-ref/source/data-index.h b/crawl-ref/source/data-index.h index fc84cb4d9c..5775043b11 100644 --- a/crawl-ref/source/data-index.h +++ b/crawl-ref/source/data-index.h @@ -13,14 +13,16 @@ public: data_index(const TVal* _pop) : pop(_pop), index_created(false) { } - const TVal* operator[](int i) + const TVal* operator[](TKey key) { + ASSERT_RANGE(key, 0, NMax); check_index(); - return (&pop[index[i]]); + return (&pop[index[key]]); } bool contains(TKey key) { + ASSERT_RANGE(key, 0, NMax); check_index(); return (index[key] >= 0); } |