mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 06:09:42 +00:00
Merge branch 'save_apply_lua_actions' into 'master'
Apply delayed Lua actions before making a save See merge request OpenMW/openmw!3294
This commit is contained in:
commit
0c5faf8fbb
4 changed files with 15 additions and 0 deletions
|
@ -98,6 +98,9 @@ namespace MWBase
|
|||
virtual void write(ESM::ESMWriter& writer, Loading::Listener& progress) = 0;
|
||||
virtual void saveLocalScripts(const MWWorld::Ptr& ptr, ESM::LuaScripts& data) = 0;
|
||||
|
||||
// Must be called before save, otherwise the world can be saved in an inconsistent state.
|
||||
virtual void applyDelayedActions() = 0;
|
||||
|
||||
// Loading from a save
|
||||
virtual void readRecord(ESM::ESMReader& reader, uint32_t type) = 0;
|
||||
virtual void loadLocalScripts(const MWWorld::Ptr& ptr, const ESM::LuaScripts& data) = 0;
|
||||
|
|
|
@ -238,6 +238,11 @@ namespace MWLua
|
|||
windowManager->printToConsole(msg, "#" + color.toHex());
|
||||
mInGameConsoleMessages.clear();
|
||||
|
||||
applyDelayedActions();
|
||||
}
|
||||
|
||||
void LuaManager::applyDelayedActions()
|
||||
{
|
||||
for (DelayedAction& action : mActionQueue)
|
||||
action.apply();
|
||||
mActionQueue.clear();
|
||||
|
|
|
@ -56,6 +56,11 @@ namespace MWLua
|
|||
// Can use the scene graph and applies the actions queued during update()
|
||||
void synchronizedUpdate();
|
||||
|
||||
// Normally it is called by `synchronizedUpdate` every frame.
|
||||
// Additionally must be called before making a save to ensure that there are no pending delayed
|
||||
// actions and the world is in a consistent state.
|
||||
void applyDelayedActions() override;
|
||||
|
||||
// Available everywhere through the MWBase::LuaManager interface.
|
||||
// LuaManager queues these events and propagates to scripts on the next `update` call.
|
||||
void newGameStarted() override;
|
||||
|
|
|
@ -190,6 +190,8 @@ void MWState::StateManager::resumeGame()
|
|||
|
||||
void MWState::StateManager::saveGame(std::string_view description, const Slot* slot)
|
||||
{
|
||||
MWBase::Environment::get().getLuaManager()->applyDelayedActions();
|
||||
|
||||
MWState::Character* character = getCurrentCharacter();
|
||||
|
||||
try
|
||||
|
|
Loading…
Reference in a new issue