Add the parameter to AiSequence::stack() to control ability to cancel other AI packages

This commit is contained in:
Andrei Kortunov 2017-11-28 12:06:09 +04:00
parent 9d27eb197f
commit 18ff097e4a
3 changed files with 4 additions and 4 deletions

View file

@ -298,7 +298,7 @@ void AiSequence::clear()
mPackages.clear(); mPackages.clear();
} }
void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor) void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor, bool cancelOther)
{ {
if (actor == getPlayer()) if (actor == getPlayer())
throw std::runtime_error("Can't add AI packages to player"); throw std::runtime_error("Can't add AI packages to player");
@ -308,7 +308,7 @@ void AiSequence::stack (const AiPackage& package, const MWWorld::Ptr& actor)
stopCombat(); stopCombat();
// remove previous packages if required // remove previous packages if required
if (package.shouldCancelPreviousAi()) if (cancelOther && package.shouldCancelPreviousAi())
{ {
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end();) for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end();)
{ {

View file

@ -115,7 +115,7 @@ namespace MWMechanics
///< Add \a package to the front of the sequence ///< Add \a package to the front of the sequence
/** Suspends current package /** Suspends current package
@param actor The actor that owns this AiSequence **/ @param actor The actor that owns this AiSequence **/
void stack (const AiPackage& package, const MWWorld::Ptr& actor); void stack (const AiPackage& package, const MWWorld::Ptr& actor, bool cancelOther=true);
/// Return the current active package. /// Return the current active package.
/** If there is no active package, it will throw an exception **/ /** If there is no active package, it will throw an exception **/

View file

@ -1611,7 +1611,7 @@ namespace MWMechanics
osg::Vec3f pos = ptr.getRefData().getPosition().asVec3(); osg::Vec3f pos = ptr.getRefData().getPosition().asVec3();
MWMechanics::AiTravel travelPackage(pos.x(), pos.y(), pos.z()); MWMechanics::AiTravel travelPackage(pos.x(), pos.y(), pos.z());
aiSequence.stack(travelPackage, ptr); aiSequence.stack(travelPackage, ptr, false);
} }
aiSequence.stack(MWMechanics::AiCombat(target), ptr); aiSequence.stack(MWMechanics::AiCombat(target), ptr);