From e8743f3f795ff8b4b7c3bfe103ca930587872258 Mon Sep 17 00:00:00 2001 From: rexelion Date: Mon, 30 Oct 2017 20:59:36 +0000 Subject: [PATCH] check the presence of OnActivate using the SuppressActivate flag instead of looking for keywords --- apps/openmw/mwbase/scriptmanager.hpp | 4 ---- apps/openmw/mwgui/inventorywindow.cpp | 3 +-- apps/openmw/mwscript/scriptmanagerimp.cpp | 6 ------ apps/openmw/mwscript/scriptmanagerimp.hpp | 4 ---- apps/openmw/mwworld/refdata.cpp | 5 +++++ apps/openmw/mwworld/refdata.hpp | 2 ++ 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwbase/scriptmanager.hpp b/apps/openmw/mwbase/scriptmanager.hpp index 44d350115..7bdeba132 100644 --- a/apps/openmw/mwbase/scriptmanager.hpp +++ b/apps/openmw/mwbase/scriptmanager.hpp @@ -42,10 +42,6 @@ namespace MWBase ///< Compile script with the given namen /// \return Success? - virtual bool hasOnActivate (const std::string& name) = 0; - ///< Determine if a script with the given name contains OnActivate - /// \return Contains OnActivate? - virtual std::pair compileAll() = 0; ///< Compile all scripts /// \return count, success diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 8586cfb5b..5fe644d45 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -663,8 +663,7 @@ namespace MWGui if (object.getClass().getName(object) == "") // objects without name presented to user can never be picked up return; - std::string scriptName = object.getClass().getScript(object); // Objects that have OnActivte in their script cannot be picked up through inventory - if (!scriptName.empty() && MWBase::Environment::get().getScriptManager()->hasOnActivate(scriptName)) + if (object.getRefData().hasSuppressActivate()) // if Flag_SuppressActivate is set, script that contains OnActivate is attached to the item { if (std::find(mItemsToActivate.begin(), mItemsToActivate.end(), object) == mItemsToActivate.end()) { diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 01ff97be2..7c1f9bf4d 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -88,12 +88,6 @@ namespace MWScript return false; } - bool ScriptManager::hasOnActivate(const std::string& name) - { - const ESM::Script *script = mStore.get().find(name); - return script->mScriptText.find("OnActivate"); - } - void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext) { // compile script diff --git a/apps/openmw/mwscript/scriptmanagerimp.hpp b/apps/openmw/mwscript/scriptmanagerimp.hpp index 3835be26e..c22a5da81 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.hpp +++ b/apps/openmw/mwscript/scriptmanagerimp.hpp @@ -62,10 +62,6 @@ namespace MWScript ///< Compile script with the given namen /// \return Success? - virtual bool hasOnActivate(const std::string& name); - ///< Determine if a script with the given name contains OnActivate - /// \return Contains OnActivate? - virtual std::pair compileAll(); ///< Compile all scripts /// \return count, success diff --git a/apps/openmw/mwworld/refdata.cpp b/apps/openmw/mwworld/refdata.cpp index f6fa3556f..95b0fb3e0 100644 --- a/apps/openmw/mwworld/refdata.cpp +++ b/apps/openmw/mwworld/refdata.cpp @@ -192,6 +192,11 @@ namespace MWWorld return mEnabled; } + bool RefData::hasSuppressActivate() + { + return mFlags & Flag_SuppressActivate; + } + void RefData::enable() { if (!mEnabled) diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 75eec6742..4dfa9e91c 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -111,6 +111,8 @@ namespace MWWorld bool isEnabled() const; + bool hasSuppressActivate(); + void enable(); void disable();