summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-stuff.cc
diff options
context:
space:
mode:
authorMatthew Cline <zelgadis@sourceforge.net>2009-11-16 23:57:19 -0800
committerMatthew Cline <zelgadis@sourceforge.net>2009-11-17 00:01:17 -0800
commit48624c055f2a8b98a71284ecb0522f94ebe3251c (patch)
tree6f974d583c5129cef9530164b921bb57aa603900 /crawl-ref/source/mon-stuff.cc
parent156bccf542ff28a29a69bc89af69259951f613bf (diff)
downloadcrawl-ref-48624c055f2a8b98a71284ecb0522f94ebe3251c.tar.gz
crawl-ref-48624c055f2a8b98a71284ecb0522f94ebe3251c.zip
Bug #2898311: fix memory problem leading to crash
Diffstat (limited to 'crawl-ref/source/mon-stuff.cc')
-rw-r--r--crawl-ref/source/mon-stuff.cc27
1 files changed, 8 insertions, 19 deletions
diff --git a/crawl-ref/source/mon-stuff.cc b/crawl-ref/source/mon-stuff.cc
index a1a955030e..f8b4962823 100644
--- a/crawl-ref/source/mon-stuff.cc
+++ b/crawl-ref/source/mon-stuff.cc
@@ -1184,8 +1184,6 @@ static void _hogs_to_humans()
// tell them apart anyway.
// On the other hand, hogs which left the level are too far away to be
// affected by the magic of Kirke's death.
- // FIXME: If another monster was polymorphed into a hog by Kirke's
- // porkalator spell, they should be handled specially...
int any = 0, human = 0;
for (monster_iterator mi; mi; ++mi)
@@ -1199,20 +1197,17 @@ static void _hogs_to_humans()
const bool could_see = you.can_see(*mi);
- monsters _orig;
- monsters* orig;
+ monsters orig;
if (mi->props.exists(ORIG_MONSTER_KEY))
- {
- orig = &(mi->props[ORIG_MONSTER_KEY].get_monster());
- }
+ // Copy it, since the instance in props will get deleted
+ // as soon a **mi is assigned to.
+ orig = mi->props[ORIG_MONSTER_KEY].get_monster();
else
{
- orig = &_orig;
-
- orig->type = MONS_HUMAN;
- orig->attitude = mi->attitude;
- define_monster(*orig);
+ orig.type = MONS_HUMAN;
+ orig.attitude = mi->attitude;
+ define_monster(orig);
}
// Keep at same spot.
@@ -1227,19 +1222,13 @@ static void _hogs_to_humans()
mon_enchant_list enchantments = mi->enchantments;
// Restore original monster.
- **mi = *orig;
+ **mi = orig;
mi->set_position(pos);
mi->enchantments = enchantments;
mi->hit_points = std::max(1, (int) (mi->max_hit_points * hp));
mi->flags = mi->flags | preserve_flags;
- // Allow ORIG_MONSTER_KEY to be chained.
- if (orig->props.exists(ORIG_MONSTER_KEY))
- mi->props[ORIG_MONSTER_KEY] = orig->props[ORIG_MONSTER_KEY];
- else
- mi->props.erase(ORIG_MONSTER_KEY);
-
const bool can_see = you.can_see(*mi);
// A monster changing factions while in the arena messes up