mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-20 10:20:50 +00:00
Apply delayed Lua actions before making a save
This commit is contained in:
parent
d2f16774d9
commit
f344c26465
@ -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;
|
||||
|
@ -237,6 +237,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…
x
Reference in New Issue
Block a user