diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 42821e361..1b8d813fd 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -326,6 +326,8 @@ namespace MWBase virtual void setupPlayer(bool newGame) = 0; virtual void renderPlayer() = 0; + virtual bool getOpenOrCloseDoor(const MWWorld::Ptr& door) = 0; + ///< if activated, should this door be opened or closed? virtual void activateDoor(const MWWorld::Ptr& door) = 0; ///< activate (open or close) an non-teleport door diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 5b061e090..91d38b8ef 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -141,7 +141,7 @@ namespace MWClass { // animated door boost::shared_ptr action(new MWWorld::ActionDoor(ptr)); - if (ptr.getRefData().getLocalRotation().rot[2] == 0) + if (MWBase::Environment::get().getWorld()->getOpenOrCloseDoor(ptr)) action->setSound(openSound); else action->setSound(closeSound); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index f1fd020df..736c52a38 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1548,4 +1548,11 @@ namespace MWWorld mDoorStates[door] = 0; // close } } + + bool World::getOpenOrCloseDoor(const Ptr &door) + { + if (mDoorStates.find(door) != mDoorStates.end()) + return !mDoorStates[door]; // if currently opening or closing, then do the opposite + return door.getRefData().getLocalRotation().rot[2] == 0; + } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 172ae406c..8ea43cb25 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -113,6 +113,9 @@ namespace MWWorld void addContainerScripts(const Ptr& reference, Ptr::CellStore* cell); void PCDropped (const Ptr& item); + virtual void processDoors(float duration); + ///< Run physics simulation and modify \a world accordingly. + public: World (OEngine::Render::OgreRenderer& renderer, @@ -272,9 +275,6 @@ namespace MWWorld virtual void doPhysics(const PtrMovementList &actors, float duration); ///< Run physics simulation and modify \a world accordingly. - virtual void processDoors(float duration); - ///< Run physics simulation and modify \a world accordingly. - virtual bool toggleCollisionMode(); ///< Toggle collision mode for player. If disabled player object should ignore /// collisions and gravity. @@ -374,6 +374,8 @@ namespace MWWorld virtual void setupPlayer(bool newGame); virtual void renderPlayer(); + virtual bool getOpenOrCloseDoor(const MWWorld::Ptr& door); + ///< if activated, should this door be opened or closed? virtual void activateDoor(const MWWorld::Ptr& door); ///< activate (open or close) an non-teleport door