From b57c205e30f99a2a595a452c6952aa267304f539 Mon Sep 17 00:00:00 2001 From: sluicebox <22204938+sluicebox@users.noreply.github.com> Date: Tue, 21 Apr 2020 12:10:09 -0700 Subject: [PATCH] SCI: Add support for QFG3 automatic saves Fixes bug #11421 --- engines/sci/engine/file.cpp | 7 +++---- engines/sci/engine/guest_additions.cpp | 3 ++- engines/sci/engine/kfile.cpp | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp index e1b727c5216..96aa46b8777 100644 --- a/engines/sci/engine/file.cpp +++ b/engines/sci/engine/file.cpp @@ -348,16 +348,15 @@ void listSavegames(Common::Array &saves) { for (Common::StringArray::const_iterator iter = saveNames.begin(); iter != saveNames.end(); ++iter) { const Common::String &filename = *iter; -#ifdef ENABLE_SCI32 - // exclude new game and autosave slots, except for QFG4, + // exclude new game and autosave slots, except for QFG3/4, // whose autosave should appear as a normal saved game - if (g_sci->getGameId() != GID_QFG4) { + if (g_sci->getGameId() != GID_QFG3 && + g_sci->getGameId() != GID_QFG4) { const int id = strtol(filename.end() - 3, NULL, 10); if (id == kNewGameId || id == kAutoSaveId) { continue; } } -#endif SavegameDesc desc; if (fillSavegameDesc(filename, desc)) { diff --git a/engines/sci/engine/guest_additions.cpp b/engines/sci/engine/guest_additions.cpp index 603afe6d266..0e26ee0c3c4 100644 --- a/engines/sci/engine/guest_additions.cpp +++ b/engines/sci/engine/guest_additions.cpp @@ -403,7 +403,8 @@ void GuestAdditions::patchGameSaveRestoreSCI16() const { uint16 selectorId = patchObjectSave->getFuncSelector(methodNr); Common::String methodName = _kernel->getSelectorName(selectorId); if (methodName == "save") { - if (g_sci->getGameId() != GID_FAIRYTALES) { // Fairy Tales saves automatically without a dialog + if (g_sci->getGameId() != GID_FAIRYTALES && // Fairy Tales saves automatically without a dialog + g_sci->getGameId() != GID_QFG3) { // QFG3 does automatic saving in Glory:save patchKSaveRestore(_segMan, patchObjectSave->getFunction(methodNr), kernelIdSave); } break; diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 7d36cdcd7cf..3a60d640782 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -1105,6 +1105,20 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) { // Jones has one save slot only savegameId = 0; break; + case GID_QFG3: { + // Auto-save system used by QFG3 + reg_t autoSaveNameId; + SciArray &autoSaveName = *s->_segMan->allocateArray(kArrayTypeString, kMaxSaveNameLength, &autoSaveNameId); + MessageTuple autoSaveNameTuple(0, 0, 16, 1); + s->_msgState->getMessage(0, autoSaveNameTuple, autoSaveNameId); + + if (game_description == autoSaveName.toString()) { + savegameId = kAutoSaveId; + } + + s->_segMan->freeArray(autoSaveNameId); + break; + } case GID_FANMADE: { // Fanmade game, try to identify the game const char *gameName = g_sci->getGameObjectName();