From ca4fa21d64256244615a4fe86ffa2126be79ec35 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 15 May 2012 20:51:19 +0200 Subject: [PATCH] removed the attempt to unify activation and use scripts which was incorrect --- apps/openmw/engine.cpp | 18 ++++++++++++++++-- apps/openmw/mwgui/inventorywindow.cpp | 5 +++-- apps/openmw/mwworld/world.cpp | 27 --------------------------- apps/openmw/mwworld/world.hpp | 3 --- 4 files changed, 19 insertions(+), 34 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index a9e7c82b0..85b0557b1 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -437,11 +437,25 @@ void OMW::Engine::activate() return; } + MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr); + boost::shared_ptr action = MWWorld::Class::get (ptr).activate (ptr, MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); - // execute action and script - MWBase::Environment::get().getWorld()->executeActionScript(ptr, action); + interpreterContext.activate (ptr, action); + + std::string script = MWWorld::Class::get (ptr).getScript (ptr); + + if (!script.empty()) + { + MWBase::Environment::get().getWorld()->getLocalScripts().setIgnore (ptr); + MWBase::Environment::get().getScriptManager()->run (script, interpreterContext); + } + + if (!interpreterContext.hasActivationBeenHandled()) + { + interpreterContext.executeActivation(); + } } void OMW::Engine::screenshot() diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index e466c34d1..ef41bf10a 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -153,8 +153,9 @@ namespace MWGui std::cout << "Item can't be equipped" << std::endl; - // execute action and script - MWBase::Environment::get().getWorld()->executeActionScript(ptr, action); + action->execute(); + + /// \todo scripts // this is necessary for books/scrolls: if they are already in the player's inventory, // the "Take" button should not be visible. diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index ce7821280..973407b0c 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -17,13 +17,6 @@ #include "../mwgui/window_manager.hpp" -#include "../mwscript/scriptmanager.hpp" -#include "../mwscript/compilercontext.hpp" -#include "../mwscript/interpretercontext.hpp" -#include "../mwscript/extensions.hpp" -#include "../mwscript/globalscripts.hpp" - - #include "ptr.hpp" #include "class.hpp" #include "player.hpp" @@ -1025,24 +1018,4 @@ namespace MWWorld mWorldScene->insertObject(object, cell); } - - void World::executeActionScript(MWWorld::Ptr ptr, boost::shared_ptr action) - { - MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr); - - action->execute(); - - // execute script - interpreterContext.activate (ptr, action); - std::string script = MWWorld::Class::get (ptr).getScript (ptr); - if (!script.empty()) - { - getLocalScripts().setIgnore (ptr); - MWBase::Environment::get().getScriptManager()->run (script, interpreterContext); - } - if (!interpreterContext.hasActivationBeenHandled()) - { - interpreterContext.executeActivation(); - } - } } diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index c1d4ace20..1ed6a976e 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -274,9 +274,6 @@ namespace MWWorld bool canPlaceObject(float cursorX, float cursorY); ///< @return true if it is possible to place on object at specified cursor location - - void executeActionScript(MWWorld::Ptr ptr, boost::shared_ptr action); - ///< execute the activation script of an object (when activating the object with space, or when activating it via the inventory) }; }