diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 963b53f60..38db494e2 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -3,6 +3,8 @@ #include +#include + #include #include "../mwmechanics/creaturestats.hpp" @@ -12,9 +14,9 @@ #include "../mwworld/actiontalk.hpp" #include "../mwworld/environment.hpp" #include "../mwworld/world.hpp" +#include "../mwmechanics/movement.hpp" #include "../mwmechanics/mechanicsmanager.hpp" -#include namespace { @@ -25,6 +27,7 @@ namespace { MWMechanics::NpcStats mNpcStats; MWMechanics::CreatureStats mCreatureStats; + MWMechanics::Movement mMovement; virtual MWWorld::CustomData *clone() const; }; @@ -253,29 +256,20 @@ namespace MWClass MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const { - if (!ptr.getRefData().getMovement().get()) - { - boost::shared_ptr movement ( - new MWMechanics::Movement); - - ptr.getRefData().getMovement() = movement; - } + ensureCustomData (ptr); - return *ptr.getRefData().getMovement(); + return dynamic_cast (*ptr.getRefData().getCustomData()).mMovement; } Ogre::Vector3 Npc::getMovementVector (const MWWorld::Ptr& ptr) const { Ogre::Vector3 vector (0, 0, 0); - if (ptr.getRefData().getMovement().get()) - { - vector.x = - ptr.getRefData().getMovement()->mLeftRight * 200; - vector.y = ptr.getRefData().getMovement()->mForwardBackward * 200; + vector.x = - getMovementSettings (ptr).mLeftRight * 200; + vector.y = getMovementSettings (ptr).mForwardBackward * 200; - if (getStance (ptr, Run, false)) - vector *= 2; - } + if (getStance (ptr, Run, false)) + vector *= 2; return vector; } diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 4eb41ebf5..5bfb82138 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -3,6 +3,8 @@ #include "../mwrender/player.hpp" +#include "../mwmechanics/movement.hpp" + #include "world.hpp" #include "class.hpp" diff --git a/apps/openmw/mwworld/refdata.cpp b/apps/openmw/mwworld/refdata.cpp index 2e4811367..133440e0f 100644 --- a/apps/openmw/mwworld/refdata.cpp +++ b/apps/openmw/mwworld/refdata.cpp @@ -14,7 +14,6 @@ namespace MWWorld mCount = refData.mCount; mPosition = refData.mPosition; - mMovement = refData.mMovement; mContainerStore = refData.mContainerStore; mCustomData = refData.mCustomData ? refData.mCustomData->clone() : 0; @@ -127,11 +126,6 @@ namespace MWWorld mEnabled = true; } - boost::shared_ptr& RefData::getMovement() - { - return mMovement; - } - boost::shared_ptr >& RefData::getContainerStore() { return mContainerStore; diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index d6984afd9..075693533 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -9,8 +9,6 @@ #include "../mwscript/locals.hpp" -#include "../mwmechanics/movement.hpp" - #include "containerstore.hpp" namespace ESM @@ -42,8 +40,6 @@ namespace MWWorld // assignment operator and destructor. As a consequence though copying a RefData object // manually will probably give unexcepted results. This is not a problem since RefData // are never copied outside of container operations. - boost::shared_ptr mMovement; - boost::shared_ptr > mContainerStore; void copy (const RefData& refData); @@ -86,8 +82,6 @@ namespace MWWorld void disable(); - boost::shared_ptr& getMovement(); - boost::shared_ptr >& getContainerStore(); ESM::Position& getPosition();