diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-27 23:32:36 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-12-27 23:32:36 +0000 |
commit | ace80c93707ad15ca6253a1867766daa0c340d15 (patch) | |
tree | a18b3cb738cf46fd624487aac4d88aa7313c4a6f /crawl-ref | |
parent | 61bc1cd16bda091d23a1d4d4744f01403377392c (diff) | |
download | crawl-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')
-rw-r--r-- | crawl-ref/source/beam.cc | 52 | ||||
-rw-r--r-- | crawl-ref/source/spl-data.h | 6 | ||||
-rw-r--r-- | crawl-ref/source/spl-util.cc | 29 |
3 files changed, 70 insertions, 17 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 1371e49c1c..61c4a76d67 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -163,8 +163,6 @@ static void _ench_animation( int flavour, const monsters *mon, bool force ) static void _beam_set_default_values(bolt &beam, int power) { - if (beam.range <= 0) - beam.range = LOS_RADIUS; beam.hit = 0; // default for "0" beams (I think) beam.damage = dice_def( 1, 0 ); // default for "0" beams (I think) beam.type = 0; // default for "0" beams @@ -1457,18 +1455,52 @@ bool bolt::invisible() const void bolt::initialize_fire() { + if (chose_ray) + { + ASSERT(in_bounds(ray.pos())); + + if (source == coord_def()) + source = ray.pos(); + } + + if (range == -1) + { +#if DEBUG + if (is_tracer) + { + mpr("Tracer with range == -1, skipping.", MSGCH_ERROR); + return; + } + + std::string item_name = item ? item->name(DESC_PLAIN, false, true) + : "none"; + std::string source_name = "unknown"; + if (beam_source == NON_MONSTER && source == you.pos()) + { + source_name = "player"; + } + else if (!invalid_monster_index(beam_source)) + source_name = menv[beam_source].name(DESC_PLAIN, true); + + mprf(MSGCH_ERROR, "beam '%s' (source '%s', item '%s') has range -1; " + "setting to LOS_RADIUS", + name.c_str(), source_name.c_str(), item_name.c_str()); +#endif + range = LOS_RADIUS; + } + + ASSERT(!name.empty() || is_tracer); + ASSERT(in_bounds(source)); ASSERT(flavour > BEAM_NONE && flavour < BEAM_FIRST_PSEUDO); - ASSERT(!drop_item || item); + ASSERT(!drop_item || item && is_valid_item(*item)); ASSERT(range >= 0); - ASSERT(chose_ray && in_bounds(ray.pos()) - || !chose_ray && in_bounds(source)); real_flavour = flavour; // Fix some things which the tracer might have set. - range_used = 0; + range_used = 0; in_explosion_phase = false; - use_target_as_pos = false; + use_target_as_pos = false; message_cache.clear(); @@ -1939,14 +1971,8 @@ void bolt::do_fire() if (!in_bounds(pos())) { ASSERT(!aimed_at_spot); -#ifdef DEBUG - mprf(MSGCH_DIAGNOSTICS, "fire_beam(): beam '%s' passed off edge of " - "map (item = '%s')", name.c_str(), - item ? item->name(DESC_PLAIN).c_str() : "none"); -#endif int tries = std::max(GXM, GYM); - while (!in_bounds(ray.pos()) && tries-- > 0) ray.regress(); diff --git a/crawl-ref/source/spl-data.h b/crawl-ref/source/spl-data.h index 6bf21a8484..4197057f84 100644 --- a/crawl-ref/source/spl-data.h +++ b/crawl-ref/source/spl-data.h @@ -317,7 +317,7 @@ SPFLAG_DIR_OR_TARGET | SPFLAG_NOT_SELF | SPFLAG_NEUTRAL, 4, 200, - -1, -1, + LOS_RADIUS, LOS_RADIUS, 0, NULL, false, @@ -1413,7 +1413,7 @@ SPFLAG_DIR_OR_TARGET | SPFLAG_UNHOLY, 4, 200, - -1, -1, + LOS_RADIUS, LOS_RADIUS, 0, NULL, true, @@ -2907,7 +2907,7 @@ SPELL_NO_SPELL, "nonexistent spell", 0, SPFLAG_TESTING, - 0, + 1, 0, -1, -1, 0, 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; |