mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-16 17:29:55 +00:00
stop local scripts from being run twice in case of activation
This commit is contained in:
parent
7a313f24ab
commit
15124601aa
2 changed files with 16 additions and 5 deletions
|
@ -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…
Reference in a new issue