summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-util.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-27 23:32:36 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-27 23:32:36 +0000
commitace80c93707ad15ca6253a1867766daa0c340d15 (patch)
treea18b3cb738cf46fd624487aac4d88aa7313c4a6f /crawl-ref/source/spl-util.cc
parent61bc1cd16bda091d23a1d4d4744f01403377392c (diff)
downloadcrawl-ref-ace80c93707ad15ca6253a1867766daa0c340d15.tar.gz
crawl-ref-ace80c93707ad15ca6253a1867766daa0c340d15.zip
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
Diffstat (limited to 'crawl-ref/source/spl-util.cc')
-rw-r--r--crawl-ref/source/spl-util.cc29
1 files changed, 28 insertions, 1 deletions
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<std::string, spell_type> spell_name_map;