mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 20:45:32 +00:00
Remember package iterator to erase it from list without find call
This commit is contained in:
parent
d48eead038
commit
a4fbcb8a10
1 changed files with 5 additions and 5 deletions
|
@ -212,7 +212,8 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|||
return;
|
||||
}
|
||||
|
||||
MWMechanics::AiPackage* package = mPackages.front();
|
||||
auto packageIt = mPackages.begin();
|
||||
MWMechanics::AiPackage* package = *packageIt;
|
||||
if (!package->alwaysActive() && outOfRange)
|
||||
return;
|
||||
|
||||
|
@ -274,7 +275,8 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|||
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
||||
}
|
||||
|
||||
package = mPackages.front();
|
||||
packageIt = mPackages.begin();
|
||||
package = *packageIt;
|
||||
packageTypeId = package->getTypeId();
|
||||
}
|
||||
|
||||
|
@ -290,9 +292,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|||
}
|
||||
// To account for the rare case where AiPackage::execute() queued another AI package
|
||||
// (e.g. AiPursue executing a dialogue script that uses startCombat)
|
||||
std::list<MWMechanics::AiPackage*>::iterator toRemove =
|
||||
std::find(mPackages.begin(), mPackages.end(), package);
|
||||
mPackages.erase(toRemove);
|
||||
mPackages.erase(packageIt);
|
||||
delete package;
|
||||
if (isActualAiPackage(packageTypeId))
|
||||
mDone = true;
|
||||
|
|
Loading…
Reference in a new issue