forked from mirror/openmw-tes3mp
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 "aisequence.hpp"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <components/esm/aisequence.hpp>
|
#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 (package->execute (actor,characterController,state,duration))
|
||||||
if (isActualAiPackage(packageTypeId) && (mRepeat || package->getRepeat()))
|
|
||||||
{
|
{
|
||||||
package->reset();
|
// Put repeating noncombat AI packages on the end of the stack so they can be used again
|
||||||
mPackages.push_back(package->clone());
|
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