ASYLUM: add support for loading during startup

This commit is contained in:
alxpnv 2021-09-20 12:03:40 +03:00
parent 0fbe223f8a
commit 377ffb92be

View file

@ -145,6 +145,17 @@ Common::Error AsylumEngine::run() {
_video->play(0, NULL);
restart();
} else {
int saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
bool noError = false;
if (saveSlot >= 0 && saveSlot < SAVEGAME_COUNT) {
if (loadGameState(saveSlot).getCode() != Common::kNoError)
warning("[AsylumEngine::run] Could not load savegame in slot %d", saveSlot);
else
noError = true;
}
if (!noError)
_handler = _menu;
// Load config
@ -655,7 +666,10 @@ bool AsylumEngine::canSaveGameStateCurrently() {
Common::Error AsylumEngine::loadGameState(int slot) {
savegame()->loadList();
savegame()->setIndex(slot);
if (savegame()->hasSavegame(slot))
startGame(savegame()->getScenePack(), AsylumEngine::kStartGameLoad);
else
return Common::kReadingFailed;
return Common::kNoError;
}