diff options
author | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-16 23:57:19 -0800 |
---|---|---|
committer | Matthew Cline <zelgadis@sourceforge.net> | 2009-11-17 00:01:17 -0800 |
commit | 48624c055f2a8b98a71284ecb0522f94ebe3251c (patch) | |
tree | 6f974d583c5129cef9530164b921bb57aa603900 /crawl-ref/source/mon-stuff.cc | |
parent | 156bccf542ff28a29a69bc89af69259951f613bf (diff) | |
download | crawl-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.cc | 27 |
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 |