diff --git a/CHANGELOG.md b/CHANGELOG.md index 32254d65b..a12d695f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -138,7 +138,7 @@ Bug #5134: Doors rotation by "Lock" console command is inconsistent Bug #5137: Textures with Clamp Mode set to Clamp instead of Wrap are too dark outside the boundaries Bug #5149: Failing lock pick attempts isn't always a crime - Bug #5155: Shouldn't be able to magically lock organic containers + Bug #5155: Lock/unlock behavior differs from vanilla Feature #1774: Handle AvoidNode Feature #2229: Improve pathfinding AI Feature #3025: Analogue gamepad movement controls diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index b7da1960e..f77a9307c 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -305,20 +305,6 @@ namespace MWClass return getContainerStore (ptr).getWeight(); } - void Container::lock (const MWWorld::Ptr& ptr, int lockLevel) const - { - if(lockLevel != 0) - ptr.getCellRef().setLockLevel(abs(lockLevel)); //Changes lock to locklevel, if positive - else - ptr.getCellRef().setLockLevel(ESM::UnbreakableLock); // If zero, set to max lock level - } - - void Container::unlock (const MWWorld::Ptr& ptr) const - { - int lockLevel = ptr.getCellRef().getLockLevel(); - ptr.getCellRef().setLockLevel(-abs(lockLevel)); //Makes lockLevel negative - } - bool Container::canLock(const MWWorld::ConstPtr &ptr) const { const MWWorld::LiveCellRef *ref = ptr.get(); diff --git a/apps/openmw/mwclass/container.hpp b/apps/openmw/mwclass/container.hpp index b13741187..8eae46353 100644 --- a/apps/openmw/mwclass/container.hpp +++ b/apps/openmw/mwclass/container.hpp @@ -47,12 +47,6 @@ namespace MWClass ///< Returns total weight of objects inside this object (including modifications from magic /// effects). Throws an exception, if the object can't hold other objects. - virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = 0) const; - ///< Lock object - - virtual void unlock (const MWWorld::Ptr& ptr) const; - ///< Unlock object - virtual bool canLock(const MWWorld::ConstPtr &ptr) const; virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 4f144e1f7..b98a8cc99 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -240,20 +240,6 @@ namespace MWClass } } - void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const - { - if(lockLevel != 0) - ptr.getCellRef().setLockLevel(abs(lockLevel)); //Changes lock to locklevel, if positive - else - ptr.getCellRef().setLockLevel(ESM::UnbreakableLock); // If zero, set to max lock level - } - - void Door::unlock (const MWWorld::Ptr& ptr) const - { - int lockLevel = ptr.getCellRef().getLockLevel(); - ptr.getCellRef().setLockLevel(-abs(lockLevel)); //Makes lockLevel negative - } - bool Door::canLock(const MWWorld::ConstPtr &ptr) const { return true; diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index b3e4e383c..46acdec72 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -41,12 +41,6 @@ namespace MWClass static std::string getDestination (const MWWorld::LiveCellRef& door); ///< @return destination cell name or token - virtual void lock (const MWWorld::Ptr& ptr, int lockLevel = 0) const; - ///< Lock object - - virtual void unlock (const MWWorld::Ptr& ptr) const; - ///< Unlock object - virtual bool canLock(const MWWorld::ConstPtr &ptr) const; virtual bool allowTelekinesis(const MWWorld::ConstPtr &ptr) const; diff --git a/apps/openmw/mwmechanics/security.cpp b/apps/openmw/mwmechanics/security.cpp index 65fab8819..62169c84a 100644 --- a/apps/openmw/mwmechanics/security.cpp +++ b/apps/openmw/mwmechanics/security.cpp @@ -29,7 +29,8 @@ namespace MWMechanics std::string& resultMessage, std::string& resultSound) { if (lock.getCellRef().getLockLevel() <= 0 || - lock.getCellRef().getLockLevel() == ESM::UnbreakableLock) //If it's unlocked or can not be unlocked back out immediately + lock.getCellRef().getLockLevel() == ESM::UnbreakableLock || + !lock.getClass().hasToolTip(lock)) //If it's unlocked or can not be unlocked back out immediately return; int lockStrength = lock.getCellRef().getLockLevel(); diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 191552bc5..d7e422006 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -146,17 +146,21 @@ namespace MWWorld void Class::lock (const Ptr& ptr, int lockLevel) const { - throw std::runtime_error ("class does not support locking"); + if(lockLevel != 0) + ptr.getCellRef().setLockLevel(abs(lockLevel)); //Changes lock to locklevel, if positive + else + ptr.getCellRef().setLockLevel(ESM::UnbreakableLock); // If zero, set to max lock level } void Class::unlock (const Ptr& ptr) const { - throw std::runtime_error ("class does not support unlocking"); + int lockLevel = ptr.getCellRef().getLockLevel(); + ptr.getCellRef().setLockLevel(-abs(lockLevel)); //Makes lockLevel negative } bool Class::canLock(const ConstPtr &ptr) const { - return false; + return hasToolTip(ptr); } void Class::setRemainingUsageTime (const Ptr& ptr, float duration) const