SCI: Add support for QFG3 automatic saves

Fixes bug #11421
This commit is contained in:
sluicebox 2020-04-21 12:10:09 -07:00
parent 4952a6fb04
commit b57c205e30
3 changed files with 19 additions and 5 deletions

View File

@ -348,16 +348,15 @@ void listSavegames(Common::Array<SavegameDesc> &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)) {

View File

@ -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;

View File

@ -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();