ENGINES: Do an autosave before loading a new game

Unfortunately, this will only apply to new engines that
use the Engine::loadGameState method. Other existing engines call
loadGameState directly and provide their own implementations,
so there's nowhere convenient to add the call that'd work for
all of them
This commit is contained in:
Paul Gilbert 2020-02-05 08:01:10 -08:00 committed by Paul Gilbert
parent d35d91e6f6
commit a2a8229abe
2 changed files with 17 additions and 5 deletions

View file

@ -489,14 +489,18 @@ void Engine::handleAutoSave() {
if (_autosaveInterval != 0 && diff > (_autosaveInterval * 1000)) {
// Save the autosave
if (canSaveAutosaveCurrently())
saveGameState(getAutosaveSlot(), _("Autosave"), true);
// Reset the last autosave time
_lastAutosaveTime = _system->getMillis();
saveAutosaveIfEnabled();
}
}
void Engine::saveAutosaveIfEnabled() {
if (_autosaveInterval != 0 && canSaveAutosaveCurrently())
saveGameState(getAutosaveSlot(), _("Autosave"), true);
// Reset the last autosave time
_lastAutosaveTime = _system->getMillis();
}
void Engine::errorString(const char *buf1, char *buf2, int size) {
Common::strlcpy(buf2, buf1, size);
}
@ -645,6 +649,9 @@ void Engine::flipMute() {
}
Common::Error Engine::loadGameState(int slot) {
// In case autosaves are on, do a save first before loading the new save
saveAutosaveIfEnabled();
Common::InSaveFile *saveFile = _saveFileMan->openForLoading(getSaveStateName(slot));
if (!saveFile)