Fix invalid iterator warning

0.6.1
Allofich 8 years ago
parent df3b4fe6a5
commit 2e5fd74db0

@ -114,9 +114,7 @@ void adjustCommandedActor (const MWWorld::Ptr& actor)
}
if (!check.mCommanded && hasCommandPackage)
{
stats.getAiSequence().erase(it);
}
}
void getRestorationPerHourOfSleep (const MWWorld::Ptr& ptr, float& health, float& magicka)
@ -707,16 +705,8 @@ namespace MWMechanics
// any value of calm > 0 will stop the actor from fighting
if ((effects.get(ESM::MagicEffect::CalmHumanoid).getMagnitude() > 0 && ptr.getClass().isNpc())
|| (effects.get(ESM::MagicEffect::CalmCreature).getMagnitude() > 0 && !ptr.getClass().isNpc()))
{
for (std::list<AiPackage*>::const_iterator it = creatureStats.getAiSequence().begin(); it != creatureStats.getAiSequence().end(); )
{
if ((*it)->getTypeId() == AiPackage::TypeIdCombat)
it = creatureStats.getAiSequence().erase(it);
else
++it;
}
}
|| (effects.get(ESM::MagicEffect::CalmCreature).getMagnitude() > 0 && !ptr.getClass().isNpc()))
creatureStats.getAiSequence().stopCombat();
// Update bound effects
// Note: in vanilla MW multiple bound items of the same type can be created by different spells.

@ -96,16 +96,16 @@ std::list<AiPackage*>::const_iterator AiSequence::end() const
return mPackages.end();
}
std::list<AiPackage*>::const_iterator AiSequence::erase(std::list<AiPackage*>::const_iterator package)
void AiSequence::erase(std::list<AiPackage*>::const_iterator package)
{
// Not sure if manually terminated packages should trigger mDone, probably not?
for(std::list<AiPackage*>::iterator it = mPackages.begin(); it != mPackages.end(); ++it)
{
if (package == it)
{
AiPackage* packagePtr = *it;
delete packagePtr;
return mPackages.erase(it);
delete *it;
mPackages.erase(it);
return;
}
}
throw std::runtime_error("can't find package to erase");

@ -64,7 +64,7 @@ namespace MWMechanics
std::list<AiPackage*>::const_iterator begin() const;
std::list<AiPackage*>::const_iterator end() const;
std::list<AiPackage*>::const_iterator erase (std::list<AiPackage*>::const_iterator package);
void erase (std::list<AiPackage*>::const_iterator package);
/// Returns currently executing AiPackage type
/** \see enum AiPackage::TypeId **/

Loading…
Cancel
Save