stop local scripts from being run twice in case of activation

actorid
Marc Zinnschlag 15 years ago
parent 7a313f24ab
commit 15124601aa

@ -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())
{

@ -11,6 +11,7 @@
#include <components/compiler/extensions.hpp>
#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&);

Loading…
Cancel
Save