From e49658cf819815286b4e386889ed55a8143dade6 Mon Sep 17 00:00:00 2001 From: Martin Kiewitz Date: Sat, 13 Feb 2016 13:40:47 +0100 Subject: [PATCH] AGI: Adding seconds of current time to saved games Useful to properly detect the most recent saved game (that's done by the original save/restore dialogs) --- engines/agi/agi.h | 2 +- engines/agi/detection.cpp | 3 +++ engines/agi/saveload.cpp | 17 +++++++++++++---- engines/agi/systemui.cpp | 6 +++--- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/engines/agi/agi.h b/engines/agi/agi.h index bcd47c9f08e..627b18e7533 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -761,7 +761,7 @@ public: SavedGameSlotIdArray getSavegameSlotIds(); Common::String getSavegameFilename(int16 slotId) const; - bool getSavegameInformation(int16 slotId, Common::String &saveDescription, uint32 &saveDate, uint16 &saveTime, bool &saveIsValid); + bool getSavegameInformation(int16 slotId, Common::String &saveDescription, uint32 &saveDate, uint32 &saveTime, bool &saveIsValid); int saveGame(const Common::String &fileName, const Common::String &descriptionString); int loadGame(const Common::String &fileName, bool checkId = true); diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 6fca86db63e..7d5243e0235 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -359,6 +359,9 @@ SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int sl uint32 saveDate = in->readUint32BE(); uint16 saveTime = in->readUint16BE(); + if (saveVersion >= 9) { + in->readByte(); // skip over seconds of saveTime (not needed here) + } if (saveVersion >= 6) { uint32 playTime = in->readUint32BE(); descriptor.setPlayTime(playTime * 1000); diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index f59fbacc7d1..e22b1270218 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -45,7 +45,7 @@ #include "agi/systemui.h" #include "agi/words.h" -#define SAVEGAME_CURRENT_VERSION 8 +#define SAVEGAME_CURRENT_VERSION 9 // // Version 0 (Sarien): view table has 64 entries @@ -62,6 +62,7 @@ // Version 8 (ScummVM): Added Hold-Key-Mode boolean // required for at least Mixed Up Mother Goose // gets set at the start of the game only +// Version 9 (ScummVM): Added seconds to saved game time stamp namespace Agi { @@ -109,6 +110,8 @@ int AgiEngine::saveGame(const Common::String &fileName, const Common::String &de debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save date (%d)", saveDate); out->writeUint16BE(saveTime); debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save time (%d)", saveTime); + // Version 9+: save seconds of current time as well + out->writeByte(curTime.tm_sec & 0xFF); out->writeUint32BE(playTime); debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing play time (%d)", playTime); @@ -384,7 +387,10 @@ int AgiEngine::loadGame(const Common::String &fileName, bool checkId) { Graphics::skipThumbnail(*in); in->readUint32BE(); // save date - in->readUint16BE(); // save time + in->readUint16BE(); // save time (hour + minute) + if (saveVersion >= 9) { + in->readByte(); // save time seconds + } if (saveVersion >= 6) { uint32 playTime = in->readUint32BE(); inGameTimerReset(playTime * 1000); @@ -813,7 +819,7 @@ Common::String AgiEngine::getSavegameFilename(int16 slotId) const { return saveLoadSlot; } -bool AgiEngine::getSavegameInformation(int16 slotId, Common::String &saveDescription, uint32 &saveDate, uint16 &saveTime, bool &saveIsValid) { +bool AgiEngine::getSavegameInformation(int16 slotId, Common::String &saveDescription, uint32 &saveDate, uint32 &saveTime, bool &saveIsValid) { Common::InSaveFile *in; Common::String fileName = getSavegameFilename(slotId); char saveGameDescription[31]; @@ -875,7 +881,10 @@ bool AgiEngine::getSavegameInformation(int16 slotId, Common::String &saveDescrip Graphics::skipThumbnail(*in); saveDate = in->readUint32BE(); - saveTime = in->readUint16BE(); + saveTime = in->readUint16BE() << 8; + if (saveVersion >= 9) { + saveTime |= in->readByte(); // add seconds (only available since saved game version 9+) + } // save date is DDMMYYYY, we need a proper format byte saveDateDay = saveDate >> 24; diff --git a/engines/agi/systemui.cpp b/engines/agi/systemui.cpp index 72017a16bb7..f618459823f 100644 --- a/engines/agi/systemui.cpp +++ b/engines/agi/systemui.cpp @@ -329,7 +329,7 @@ int16 SystemUI::askForRestoreGameSlot() { int16 restoreGameSlotNr = -1; // Fill saved game slot cache - readSavedGameSlots(true, true); // filter empty/corrupt slots, but including auto-save slot + readSavedGameSlots(true, true); // filter empty/corrupt slots, but include auto-save slot if (_savedGameArray.size() == 0) { // no saved games @@ -528,12 +528,12 @@ void SystemUI::readSavedGameSlots(bool filterNonexistant, bool withAutoSaveSlot) SystemUISavedGameEntry savedGameEntry; Common::String saveDescription; uint32 saveDate = 0; - uint16 saveTime = 0; + uint32 saveTime = 0; bool saveIsValid = false; int16 mostRecentSlotNr = -1; uint32 mostRecentSlotSaveDate = 0; - uint16 mostRecentSlotSaveTime = 0; + uint32 mostRecentSlotSaveTime = 0; clearSavedGameSlots();