Fix saving persistent data on regular save

develop
lethosor 2019-08-23 20:30:06 -04:00
parent 07575095fd
commit 100e584c34
1 changed files with 10 additions and 5 deletions

@ -136,6 +136,8 @@ struct Core::Private
{
std::thread iothread;
std::thread hotkeythread;
bool last_autosave_request{false};
};
struct CommandDepthCounter
@ -1965,6 +1967,14 @@ void Core::doUpdate(color_ostream &out, bool first_update)
vs_changed = true;
}
// save data (do this before updating last_world_data_ptr and triggering unload events)
if ((df::global::ui->main.autosave_request && !d->last_autosave_request) ||
(vs_changed && strict_virtual_cast<df::viewscreen_savegamest>(screen)))
{
doSaveData(out);
}
d->last_autosave_request = df::global::ui->main.autosave_request;
bool is_load_save =
strict_virtual_cast<df::viewscreen_game_cleanerst>(screen) ||
strict_virtual_cast<df::viewscreen_loadgamest>(screen) ||
@ -2026,11 +2036,6 @@ void Core::doUpdate(color_ostream &out, bool first_update)
// Execute per-frame handlers
onUpdate(out);
if (df::global::ui->main.autosave_request || (vs_changed && strict_virtual_cast<df::viewscreen_savegamest>(screen)))
{
doSaveData(out);
}
out << std::flush;
}