mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Catch exceptions in AiSequence::execute
This commit is contained in:
parent
5a12407436
commit
03a10f217a
1 changed files with 23 additions and 15 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "aisequence.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <iostream>
|
||||
|
||||
#include <components/esm/aisequence.hpp>
|
||||
|
||||
|
@ -229,26 +230,33 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac
|
|||
}
|
||||
}
|
||||
|
||||
if (package->execute (actor,characterController,state,duration))
|
||||
try
|
||||
{
|
||||
// Put repeating noncombat AI packages on the end of the stack so they can be used again
|
||||
if (isActualAiPackage(packageTypeId) && (mRepeat || package->getRepeat()))
|
||||
if (package->execute (actor,characterController,state,duration))
|
||||
{
|
||||
package->reset();
|
||||
mPackages.push_back(package->clone());
|
||||
// Put repeating noncombat AI packages on the end of the stack so they can be used again
|
||||
if (isActualAiPackage(packageTypeId) && (mRepeat || package->getRepeat()))
|
||||
{
|
||||
package->reset();
|
||||
mPackages.push_back(package->clone());
|
||||
}
|
||||
// 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);
|
||||
delete package;
|
||||
if (isActualAiPackage(packageTypeId))
|
||||
mDone = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
mDone = false;
|
||||
}
|
||||
// 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);
|
||||
delete package;
|
||||
if (isActualAiPackage(packageTypeId))
|
||||
mDone = true;
|
||||
}
|
||||
else
|
||||
catch (std::exception& e)
|
||||
{
|
||||
mDone = false;
|
||||
std::cerr << "Error during AiSequence::execute: " << e.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue