mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-06 09:39:49 +00:00
Fix #6618: Crash due to iterator invalidation
This commit is contained in:
parent
d680870e8f
commit
83be3826ff
@ -309,12 +309,18 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|||||||
{
|
{
|
||||||
if (package->execute(actor, characterController, mAiState, duration))
|
if (package->execute(actor, characterController, mAiState, duration))
|
||||||
{
|
{
|
||||||
// Put repeating noncombat AI packages on the end of the stack so they can be used again
|
const auto packageIdx = std::distance(mPackages.begin(), packageIt);
|
||||||
|
|
||||||
|
// Put repeating non-combat AI packages on the end of the stack so they can be used again
|
||||||
if (isActualAiPackage(packageTypeId) && package->getRepeat())
|
if (isActualAiPackage(packageTypeId) && package->getRepeat())
|
||||||
{
|
{
|
||||||
package->reset();
|
package->reset();
|
||||||
mPackages.push_back(package->clone());
|
mPackages.push_back(package->clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iterator may have been invalidated by push back ensure its correct.
|
||||||
|
packageIt = mPackages.begin() + packageIdx;
|
||||||
|
|
||||||
// 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)
|
||||||
erase(packageIt);
|
erase(packageIt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user