summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-31 23:41:10 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-31 23:41:10 +0000
commit6e01ad4051e824734f3ac60ed6ad3c414e70a9fe (patch)
tree136b145162540f806063a7ec4d1ed547320451ea /crawl-ref/source/monstuff.cc
parentd752c86b835ebb44452f869e772b3071371d800a (diff)
downloadcrawl-ref-6e01ad4051e824734f3ac60ed6ad3c414e70a9fe.tar.gz
crawl-ref-6e01ad4051e824734f3ac60ed6ad3c414e70a9fe.zip
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
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc15
1 files changed, 12 insertions, 3 deletions
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 <unsigned int, 19, 19> 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)