mirror of
https://github.com/OpenMW/openmw.git
synced 2025-11-08 21:46:43 +00:00
Prevent iterator invalidation when cleaning up summons
This commit is contained in:
parent
dc1fe62dde
commit
161e042e2a
2 changed files with 4 additions and 2 deletions
|
|
@ -277,8 +277,9 @@ namespace MWGui
|
||||||
auto it = std::find_if(summons.begin(), summons.end(), [&] (const auto& entry) { return entry.second == creatureStats.getActorId(); });
|
auto it = std::find_if(summons.begin(), summons.end(), [&] (const auto& entry) { return entry.second == creatureStats.getActorId(); });
|
||||||
if(it != summons.end())
|
if(it != summons.end())
|
||||||
{
|
{
|
||||||
MWMechanics::purgeSummonEffect(summoner, *it);
|
auto summon = *it;
|
||||||
summons.erase(it);
|
summons.erase(it);
|
||||||
|
MWMechanics::purgeSummonEffect(summoner, summon);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,9 @@ namespace MWMechanics
|
||||||
if (!ptr.isEmpty() && ptr.getClass().getCreatureStats(ptr).isDead() && ptr.getClass().getCreatureStats(ptr).isDeathAnimationFinished())
|
if (!ptr.isEmpty() && ptr.getClass().getCreatureStats(ptr).isDead() && ptr.getClass().getCreatureStats(ptr).isDeathAnimationFinished())
|
||||||
{
|
{
|
||||||
// Purge the magic effect so a new creature can be summoned if desired
|
// Purge the magic effect so a new creature can be summoned if desired
|
||||||
purgeSummonEffect(summoner, *it);
|
auto summon = *it;
|
||||||
creatureMap.erase(it++);
|
creatureMap.erase(it++);
|
||||||
|
purgeSummonEffect(summoner, summon);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++it;
|
++it;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue