mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 02:15:32 +00:00
fixed handling of cell changes during local and global script execution
This commit is contained in:
parent
0e641f1246
commit
f693a2942e
1 changed files with 13 additions and 5 deletions
|
@ -35,6 +35,9 @@ void OMW::Engine::executeLocalScripts()
|
||||||
MWScript::InterpreterContext interpreterContext (mEnvironment,
|
MWScript::InterpreterContext interpreterContext (mEnvironment,
|
||||||
&iter->second.getRefData().getLocals(), MWWorld::Ptr (iter->second));
|
&iter->second.getRefData().getLocals(), MWWorld::Ptr (iter->second));
|
||||||
mScriptManager->run (iter->first, interpreterContext);
|
mScriptManager->run (iter->first, interpreterContext);
|
||||||
|
|
||||||
|
if (mEnvironment.mWorld->hasCellChanged())
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,18 +48,23 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
// console
|
// console
|
||||||
processCommands();
|
processCommands();
|
||||||
|
|
||||||
// local scripts
|
|
||||||
executeLocalScripts();
|
|
||||||
|
|
||||||
// global scripts
|
// global scripts
|
||||||
mEnvironment.mGlobalScripts->run (mEnvironment);
|
mEnvironment.mGlobalScripts->run (mEnvironment);
|
||||||
|
|
||||||
|
bool changed = mEnvironment.mWorld->hasCellChanged();
|
||||||
|
|
||||||
|
// local scripts
|
||||||
|
executeLocalScripts(); // This does not handle the case where a global script causes a cell
|
||||||
|
// change, followed by a cell change in a local script during the same
|
||||||
|
// frame.
|
||||||
|
|
||||||
// passing of time
|
// passing of time
|
||||||
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
|
if (mEnvironment.mWindowManager->getMode()==MWGui::GM_Game)
|
||||||
mEnvironment.mWorld->advanceTime (
|
mEnvironment.mWorld->advanceTime (
|
||||||
mEnvironment.mFrameDuration*mEnvironment.mWorld->getTimeScaleFactor()/3600);
|
mEnvironment.mFrameDuration*mEnvironment.mWorld->getTimeScaleFactor()/3600);
|
||||||
|
|
||||||
mEnvironment.mWorld->markCellAsUnchanged();
|
if (changed) // keep change flag for another frame, if cell changed happend in local script
|
||||||
|
mEnvironment.mWorld->markCellAsUnchanged();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue