mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-31 23: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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::AiPackage* package = mPackages.front();
|
auto packageIt = mPackages.begin();
|
||||||
|
MWMechanics::AiPackage* package = *packageIt;
|
||||||
if (!package->alwaysActive() && outOfRange)
|
if (!package->alwaysActive() && outOfRange)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -274,7 +275,8 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
||||||
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
mPackages.splice(mPackages.begin(), mPackages, itActualCombat);
|
||||||
}
|
}
|
||||||
|
|
||||||
package = mPackages.front();
|
packageIt = mPackages.begin();
|
||||||
|
package = *packageIt;
|
||||||
packageTypeId = package->getTypeId();
|
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
|
// To account for the rare case where AiPackage::execute() queued another AI package
|
||||||
// (e.g. AiPursue executing a dialogue script that uses startCombat)
|
// (e.g. AiPursue executing a dialogue script that uses startCombat)
|
||||||
std::list<MWMechanics::AiPackage*>::iterator toRemove =
|
mPackages.erase(packageIt);
|
||||||
std::find(mPackages.begin(), mPackages.end(), package);
|
|
||||||
mPackages.erase(toRemove);
|
|
||||||
delete package;
|
delete package;
|
||||||
if (isActualAiPackage(packageTypeId))
|
if (isActualAiPackage(packageTypeId))
|
||||||
mDone = true;
|
mDone = true;
|
||||||
|
|
Loading…
Reference in a new issue