diff options
author | Neil Moore <neil@s-z.org> | 2014-08-06 00:54:16 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2014-08-06 01:04:31 -0400 |
commit | 0ca2a48c7e8d7454b609b9156c9ce56e04e891e3 (patch) | |
tree | 5aed05f98224605f471c508d4237060efcc4e5eb /crawl-ref/source/mon-util.cc | |
parent | 477c477a1dd44682235e2b105a88dc3461a4921c (diff) | |
download | crawl-ref-0ca2a48c7e8d7454b609b9156c9ce56e04e891e3.tar.gz crawl-ref-0ca2a48c7e8d7454b609b9156c9ce56e04e891e3.zip |
Remove mon-spll.h enum order dependency.
The list of spellbooks in mon-spll.h was originally independent of enum
order, but that changed when get_unique_spells was added. Return to
the good old days.
Thanks to doy for asking about it.
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r-- | crawl-ref/source/mon-util.cc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 026c8542d4..727e0de4f8 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -2302,6 +2302,12 @@ unique_books get_unique_spells(const monster_info &mi) for (size_t i = 0; i < num_books; ++i) { const mon_spellbook_type book = books[i]; + // TODO: should we build an index to speed this reverse lookup? + unsigned int msidx; + for (msidx = 0; msidx < ARRAYSZ(mspell_list); ++msidx) + if (mspell_list[msidx].type == book) + break; + vector<spell_type> spells; for (int j = 0; j < NUM_MONSTER_SPELL_SLOTS; ++j) @@ -2310,7 +2316,10 @@ unique_books get_unique_spells(const monster_info &mi) if (book == MST_GHOST) spell = mi.spells[j]; else - spell = mspell_list[book].spells[j]; + { + ASSERT(msidx < ARRAYSZ(mspell_list)); + spell = mspell_list[msidx].spells[j]; + } bool match = false; |