summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/beam.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/beam.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/beam.cc')
-rw-r--r--crawl-ref/source/beam.cc52
1 files changed, 39 insertions, 13 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();