From ace80c93707ad15ca6253a1867766daa0c340d15 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Sat, 27 Dec 2008 23:32:36 +0000 Subject: If a beam has range == -1 then set it to LOS_RADIUS and, in debug builds, complain about it. Eventually turn this into an ASSERT when all code that makes this assumption is caught and fixed. If beam.chose_ray is true and source is still the default then change source to ray.pos() Fix Banishment and Dig having range -1. Sanity check spell definitions at startup in init_spell_descs() git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7996 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spl-util.cc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/spl-util.cc') diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index 584e297770..a267e3805a 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -90,7 +90,34 @@ void init_spell_descs(void) spell_list[i] = -1; for (unsigned int i = 0; i < SPELLDATASIZE; i++) - spell_list[spelldata[i].id] = i; + { + spell_desc &data = spelldata[i]; + +#if DEBUG + if (data.id < SPELL_NO_SPELL || data.id >= NUM_SPELLS) + end(1, false, "spell #%d has invalid id %d", i, data.id); + + if (data.title == NULL || strlen(data.title) == 0) + end(1, false, "spell #%d, id %d has no name", i, data.id); + + if (data.level < 1 || data.level > 9) + end(1, false, "spell '%s' has invalid level %d", + data.title, data.level); + + if (data.min_range > data.max_range) + end(1, false, "spell '%s' has min_range larger than max_range", + data.title); + + if (data.flags & SPFLAG_TARGETING_MASK) + { + if (data.min_range <= -1 || data.max_range <= 0) + end(1, false, "targeted/directed spell '%s' has invalid range", + data.title); + } +#endif + + spell_list[data.id] = i; + } } typedef std::map spell_name_map; -- cgit v1.2.3-54-g00ecf