summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-07-12 11:17:36 -0400
committerNeil Moore <neil@s-z.org>2014-07-12 11:17:44 -0400
commit342abdf7a4efb2539a5f39343aeb519f2b623f7f (patch)
tree977c474ab0c47f016f3630642f6478d84d309b88
parent00f2e2e4d8836e699de4ecf33d02448a22508720 (diff)
downloadcrawl-ref-342abdf7a4efb2539a5f39343aeb519f2b623f7f.tar.gz
crawl-ref-342abdf7a4efb2539a5f39343aeb519f2b623f7f.zip
Don't crash on ?/inecronomicon.
Or any other book; 0.15-a0-2006-g1cf06be made spell_by_name return NUM_SPELLS rather than SPELL_NO_SPELL. Fixing up the return in spell_by_name rather than adding yet another parameter to find_earliest_match.
-rw-r--r--crawl-ref/source/spl-util.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc
index 15fb9d2536..1efbef1520 100644
--- a/crawl-ref/source/spl-util.cc
+++ b/crawl-ref/source/spl-util.cc
@@ -148,8 +148,9 @@ spell_type spell_by_name(string name, bool partial_match)
return SPELL_NO_SPELL;
}
- return find_earliest_match(name, SPELL_NO_SPELL, NUM_SPELLS,
- is_valid_spell, spell_title);
+ const spell_type sp = find_earliest_match(name, SPELL_NO_SPELL, NUM_SPELLS,
+ is_valid_spell, spell_title);
+ return sp == NUM_SPELLS ? SPELL_NO_SPELL : sp;
}
spschool_flag_type school_by_name(string name)