From 15124601aa23927253202a6fe268d4cd7b182cf6 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 5 Aug 2010 15:46:50 +0200 Subject: [PATCH] stop local scripts from being run twice in case of activation --- apps/openmw/engine.cpp | 18 +++++++++++++----- apps/openmw/engine.hpp | 3 +++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index badb19629d..b67bcd0ac7 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -38,13 +38,18 @@ void OMW::Engine::executeLocalScripts() mEnvironment.mWorld->getLocalScripts().begin()); iter!=mEnvironment.mWorld->getLocalScripts().end(); ++iter) { - MWScript::InterpreterContext interpreterContext (mEnvironment, - &iter->second.getRefData().getLocals(), MWWorld::Ptr (iter->second)); - mScriptManager->run (iter->first, interpreterContext); + if (!mIgnoreLocalPtr.isEmpty() && mIgnoreLocalPtr!=iter->second) + { + MWScript::InterpreterContext interpreterContext (mEnvironment, + &iter->second.getRefData().getLocals(), MWWorld::Ptr (iter->second)); + mScriptManager->run (iter->first, interpreterContext); - if (mEnvironment.mWorld->hasCellChanged()) - break; + if (mEnvironment.mWorld->hasCellChanged()) + break; + } } + + mIgnoreLocalPtr = MWWorld::Ptr(); } bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) @@ -291,7 +296,10 @@ void OMW::Engine::activate() std::string script = MWWorld::Class::get (ptr).getScript (ptr); if (!script.empty()) + { + mIgnoreLocalPtr = ptr; mScriptManager->run (script, interpreterContext); + } if (!interpreterContext.hasActivationBeenHandled()) { diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index 62166e0500..bc612d13c0 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -11,6 +11,7 @@ #include #include "mwworld/environment.hpp" +#include "mwworld/ptr.hpp" namespace Compiler { @@ -68,6 +69,8 @@ namespace OMW int focusFrameCounter; static const int focusUpdateFrame = 10; + MWWorld::Ptr mIgnoreLocalPtr; + // not implemented Engine (const Engine&); Engine& operator= (const Engine&);