From 6e01ad4051e824734f3ac60ed6ad3c414e70a9fe Mon Sep 17 00:00:00 2001 From: zelgadis Date: Wed, 31 Dec 2008 23:41:10 +0000 Subject: Fix bug #2477792: caused by recycling the bolt instance "beem" inside of the loop in _handle_monster_move() without reseting it between iterations; now uses a fresh instance on each iteration. Also the loop in _handle_spell() saves and restores the beem object on each of its internal iterations, just in case any of the called functions alters it. Initialize the bolt member affects_items to false. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8066 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/beam.cc | 4 ++-- crawl-ref/source/monstuff.cc | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index af64208352..c99825f994 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -5409,8 +5409,8 @@ bolt::bolt() : range(0), type('*'), ench_power(0), hit(0), thrower(KILL_MISC), ex_size(0), beam_source(MHITNOT), name(), short_name(), is_beam(false), is_explosion(false), is_big_cloud(false), aimed_at_spot(false), - aux_source(), affects_nothing(false), effect_known(true), - draw_delay(15), obvious_effect(false), + aux_source(), affects_nothing(false), affects_items(false), + effect_known(true), draw_delay(15), obvious_effect(false), fr_count(0), foe_count(0), fr_power(0), foe_power(0), fr_hurt(0), foe_hurt(0), fr_helped(0),foe_helped(0), seen(false), range_used(0), is_tracer(false), diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index f630cbeb59..11d0105aaf 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1747,6 +1747,9 @@ static bool _valid_morph( monsters *monster, int new_mclass ) || new_mclass == MONS_PLAYER_GHOST || new_mclass == MONS_PANDEMONIUM_DEMON + // Only for use by game testers or in the arena. + || new_mclass == MONS_TEST_SPAWNER + // Other poly-unsuitable things. || new_mclass == MONS_ORB_GUARDIAN || new_mclass == MONS_ORANGE_STATUE @@ -5888,9 +5891,12 @@ static bool _handle_spell(monsters *monster, bolt &beem) return (false); } + const bolt orig_beem = beem; // Up to four tries to pick a spell. for (int loopy = 0; loopy < 4; ++loopy) { + beem = orig_beem; + bool spellOK = false; // Setup spell - monsters that are fleeing or pacified @@ -6400,7 +6406,6 @@ static void _swim_or_move_energy(monsters *mon) static void _handle_monster_move(int i, monsters *monster) { bool brkk = false; - bolt beem; FixedArray show; monster->hit_points = std::min(monster->max_hit_points, @@ -6484,6 +6489,12 @@ static void _handle_monster_move(int i, monsters *monster) if (!monster->alive()) break; + bolt beem; + + beem.source = monster->pos(); + beem.target = monster->target; + beem.beam_source = monster->mindex(); + #if DEBUG_MONS_SCAN if (!monster_was_floating && mgrd(monster->pos()) != monster->mindex()) @@ -6745,8 +6756,6 @@ static void _handle_monster_move(int i, monsters *monster) } _handle_nearby_ability( monster ); - beem.target = monster->target; - if (!mons_is_sleeping(monster) && !mons_is_wandering(monster) -- cgit v1.2.3-54-g00ecf