From 61c38356378fb4ab0de5bf4a23cd828b40ab7a29 Mon Sep 17 00:00:00 2001 From: Arthur Moore Date: Thu, 30 Jul 2015 08:20:16 -0400 Subject: [PATCH] Don't try to play animations we know are bad Prevents log spam --- apps/openmw/mwmechanics/aiwander.cpp | 34 +++++++++++++++++----------- apps/openmw/mwmechanics/aiwander.hpp | 4 ++-- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index f05040b66..331ec8b9d 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -58,7 +58,6 @@ namespace MWMechanics bool mTurnActorGivingGreetingToFacePlayer; float mReaction; // update some actions infrequently - AiWander::GreetingState mSaidGreeting; int mGreetingTimer; @@ -68,6 +67,7 @@ namespace MWMechanics AiWander::WanderState mState; unsigned short mIdleAnimation; + std::vector mBadIdles; //Idle animations that when called cause errors PathFinder mPathFinder; @@ -79,7 +79,8 @@ namespace MWMechanics mGreetingTimer(0), mCell(NULL), mState(AiWander::Wander_ChooseAction), - mIdleAnimation(0) + mIdleAnimation(0), + mBadIdles() {}; }; @@ -392,24 +393,31 @@ namespace MWMechanics short unsigned& idleAnimation = storage.mIdleAnimation; idleAnimation = getRandomIdle(); - //If we should be moving + // If we should be moving if (!idleAnimation && mDistance) { storage.mState = Wander_MoveNow; + return; } - else - { - //Recreate vanilla (broken?) behavior of resetting start time of AIWander: - MWWorld::TimeStamp currentTime = MWBase::Environment::get().getWorld()->getTimeStamp(); - mStartTime = currentTime; - storage.mState = Wander_IdleNow; - } - - //If we aren't going to just stand + // If we aren't going to just stand if(idleAnimation) { - playIdle(actor, idleAnimation); + // If the idle animation actually exists + if(std::find(storage.mBadIdles.begin(), storage.mBadIdles.end(), idleAnimation)==storage.mBadIdles.end()) + { + if(!playIdle(actor, idleAnimation)) + { + std::cerr<< "Unable to play idle animation "<getTimeStamp(); + storage.mState = Wander_IdleNow; + return; } void AiWander::evadeObstacles(const MWWorld::Ptr& actor, AiWanderStorage& storage, float duration) diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index c03cdfaa2..27e6fe9fb 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -76,8 +76,8 @@ namespace MWMechanics void stopWalking(const MWWorld::Ptr& actor, AiWanderStorage& storage); - ///Have the given actor play an idle animation - ///@return Success or error + /// Have the given actor play an idle animation + /// @return Success or error bool playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect); bool checkIdle(const MWWorld::Ptr& actor, unsigned short idleSelect); short unsigned getRandomIdle();