From 75f1ac769ba8158ff73f724a91e9544b29943905 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 4 Nov 2018 19:25:06 -0800 Subject: GLK: SCOTT: Fix loading and saving games --- engines/gargoyle/scott/scott.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/engines/gargoyle/scott/scott.cpp b/engines/gargoyle/scott/scott.cpp index f92754f38f..b0c3444a45 100644 --- a/engines/gargoyle/scott/scott.cpp +++ b/engines/gargoyle/scott/scott.cpp @@ -37,6 +37,7 @@ Scott::Scott(OSystem *syst, const GargoyleGameDescription *gameDesc) : Glk(syst, void Scott::runGame(Common::SeekableReadStream *gameFile) { int vb, no; + int saveSlot; initialize(); Bottom = glk_window_open(0, 0, 0, wintype_TextBuffer, 1); @@ -62,24 +63,26 @@ void Scott::runGame(Common::SeekableReadStream *gameFile) { Top = Bottom; } + // Check for savegame + saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1; + output("\ Scott Free, A Scott Adams game driver in C.\n\ Release 1.14, (c) 1993,1994,1995 Swansea University Computer Society.\n\ Distributed under the GNU software license\n\n"); loadDatabase(gameFile, (Options & DEBUGGING) ? 1 : 0); - // Check for savegame - if (ConfMan.hasKey("save_slot")) { - int saveSlot = ConfMan.getInt("save_slot"); - if (saveSlot >= 0) - loadGameState(saveSlot); - } - while (!shouldQuit()) { glk_tick(); performActions(0, 0); + if (saveSlot >= 0) { + // Load any savegame during startup + loadGameState(saveSlot); + saveSlot = -1; + } + look(); if (getInput(&vb, &no) == -1) @@ -547,9 +550,7 @@ void Scott::saveGame(void) { Common::Error Scott::saveGameState(int slot, const Common::String &desc) { Common::String msg; - FileReference ref; - ref._slotNumber = slot; - ref._description = desc; + FileReference ref(slot, desc, fileusage_TextMode | fileusage_SavedGame); strid_t file = glk_stream_open_file(&ref, filemode_Write, 0); if (file == nullptr) @@ -595,8 +596,7 @@ Common::Error Scott::loadGameState(int slot) { short lo; short darkFlag; - FileReference ref; - ref._slotNumber = slot; + FileReference ref(slot, "", fileusage_SavedGame | fileusage_TextMode); file = glk_stream_open_file(&ref, filemode_Read, 0); if (file == nullptr) -- cgit v1.2.3