diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 12aeb9a5b..d15a01e9f 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -50,6 +50,9 @@ namespace MWClass ESMS::LiveCellRef *ref = ptr.get(); + // TODO check lock + // TODO check trap + if (ref->ref.teleport) { // teleport door @@ -74,6 +77,19 @@ namespace MWClass } } + void Door::lock (const MWWorld::Ptr& ptr, int lockLevel) const + { + if (lockLevel<0) + lockLevel = 0; + + ptr.getCellRef().lockLevel = lockLevel; + } + + void Door::unlock (const MWWorld::Ptr& ptr) const + { + ptr.getCellRef().lockLevel = 0; + } + std::string Door::getScript (const MWWorld::Ptr& ptr) const { ESMS::LiveCellRef *ref = diff --git a/apps/openmw/mwclass/door.hpp b/apps/openmw/mwclass/door.hpp index b6bf8808e..aecb117d3 100644 --- a/apps/openmw/mwclass/door.hpp +++ b/apps/openmw/mwclass/door.hpp @@ -21,6 +21,12 @@ namespace MWClass const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const; ///< Generate action for activation + virtual void lock (const MWWorld::Ptr& ptr, int lockLevel) const; + ///< Lock object + + virtual void unlock (const MWWorld::Ptr& ptr) const; + ///< Unlock object + virtual std::string getScript (const MWWorld::Ptr& ptr) const; ///< Return name of the script attached to ptr diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index e21e4908c..1e9f25bbd 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -77,6 +77,16 @@ namespace MWWorld throw std::runtime_error ("class does not support inserting into a container"); } + void Class::lock (const Ptr& ptr, int lockLevel) const + { + throw std::runtime_error ("class does not support locking"); + } + + void Class::unlock (const Ptr& ptr) const + { + throw std::runtime_error ("class does not support unlocking"); + } + std::string Class::getScript (const Ptr& ptr) const { return ""; diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index c3f4bff14..5153d7468 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -98,6 +98,12 @@ namespace MWWorld ///< Insert into a container or throw an exception, if class does not support inserting into /// a container. + virtual void lock (const Ptr& ptr, int lockLevel) const; + ///< Lock object (default implementation: throw an exception) + + virtual void unlock (const Ptr& ptr) const; + ///< Unlock object (default implementation: throw an exception) + virtual std::string getScript (const Ptr& ptr) const; ///< Return name of the script attached to ptr (default implementation: return an empty /// string).