aboutsummaryrefslogtreecommitdiff
path: root/engines/cge2
diff options
context:
space:
mode:
authorAdrian Frühwirth2018-05-05 02:09:17 +0200
committerAdrian Frühwirth2018-05-05 22:19:03 +0200
commit03312fba61d65fed96ff4f7dad0112c0db2187a5 (patch)
tree0cf210c016ba30a516918178c39cde85283bc416 /engines/cge2
parentafc48cfb0ec2ce3e87b7121f5616bc01f6281284 (diff)
downloadscummvm-rg350-03312fba61d65fed96ff4f7dad0112c0db2187a5.tar.gz
scummvm-rg350-03312fba61d65fed96ff4f7dad0112c0db2187a5.tar.bz2
scummvm-rg350-03312fba61d65fed96ff4f7dad0112c0db2187a5.zip
CGE2: Add play time metadata to savegames
Diffstat (limited to 'engines/cge2')
-rw-r--r--engines/cge2/cge2.h7
-rw-r--r--engines/cge2/detection.cpp5
-rw-r--r--engines/cge2/saveload.cpp28
3 files changed, 32 insertions, 8 deletions
diff --git a/engines/cge2/cge2.h b/engines/cge2/cge2.h
index 381d42bf6f..1fa23ad6f7 100644
--- a/engines/cge2/cge2.h
+++ b/engines/cge2/cge2.h
@@ -106,7 +106,7 @@ struct SavegameHeader;
#define kQuitText 201
#define kNoQuitText 202
-#define kSavegameVersion 1
+#define kSavegameVersion 2
#define kSavegameStrSize 12
#define kSavegameStr "SCUMMVM_CGE2"
@@ -116,8 +116,9 @@ struct SavegameHeader {
uint8 version;
Common::String saveName;
Graphics::Surface *thumbnail;
- int saveYear, saveMonth, saveDay;
- int saveHour, saveMinutes;
+ int16 saveYear, saveMonth, saveDay;
+ int16 saveHour, saveMinutes;
+ uint32 playTime;
};
enum ColorBank { kCBRel, kCBStd, kCBSay, kCBInf, kCBMnu, kCBWar };
diff --git a/engines/cge2/detection.cpp b/engines/cge2/detection.cpp
index 68f16d8dc9..54c324057e 100644
--- a/engines/cge2/detection.cpp
+++ b/engines/cge2/detection.cpp
@@ -185,6 +185,7 @@ bool CGE2MetaEngine::hasFeature(MetaEngineFeature f) const {
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSavesSupportCreationDate) ||
+ (f == kSavesSupportPlayTime) ||
(f == kSupportsListSaves) ||
(f == kSupportsLoadingDuringStartup) ||
(f == kSimpleSavesNames);
@@ -263,6 +264,10 @@ SaveStateDescriptor CGE2MetaEngine::querySaveMetaInfos(const char *target, int s
desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay);
desc.setSaveTime(header.saveHour, header.saveMinutes);
+ if (header.playTime) {
+ desc.setPlayTime(header.playTime * 1000);
+ }
+
// Slot 0 is used for the 'automatic save on exit' save in Soltys, thus
// we prevent it from being deleted or overwritten by accident.
desc.setDeletableFlag(slot != 0);
diff --git a/engines/cge2/saveload.cpp b/engines/cge2/saveload.cpp
index 83cba5316d..a8120c1017 100644
--- a/engines/cge2/saveload.cpp
+++ b/engines/cge2/saveload.cpp
@@ -117,6 +117,8 @@ bool CGE2Engine::loadGame(int slotNumber) {
delete readStream;
return false;
}
+
+ g_engine->setTotalPlayTime(saveHeader.playTime * 1000);
}
resetGame();
@@ -174,16 +176,27 @@ void CGE2Engine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &h
out->writeSint16LE(td.tm_mday);
out->writeSint16LE(td.tm_hour);
out->writeSint16LE(td.tm_min);
+
+ out->writeUint32LE(g_engine->getTotalPlayTime() / 1000);
}
WARN_UNUSED_RESULT bool CGE2Engine::readSavegameHeader(Common::InSaveFile *in, SavegameHeader &header, bool skipThumbnail) {
+ header.version = 0;
+ header.saveName.clear();
+ header.thumbnail = nullptr;
+ header.saveYear = 0;
+ header.saveMonth = 0;
+ header.saveDay = 0;
+ header.saveHour = 0;
+ header.saveMinutes = 0;
+ header.playTime = 0;
+
// Get the savegame version
header.version = in->readByte();
if (header.version > kSavegameVersion)
return false;
// Read in the string
- header.saveName.clear();
char ch;
while ((ch = (char)in->readByte()) != '\0')
header.saveName += ch;
@@ -194,12 +207,17 @@ WARN_UNUSED_RESULT bool CGE2Engine::readSavegameHeader(Common::InSaveFile *in, S
}
// Read in save date/time
- header.saveYear = in->readSint16LE();
- header.saveMonth = in->readSint16LE();
- header.saveDay = in->readSint16LE();
- header.saveHour = in->readSint16LE();
+ header.saveYear = in->readSint16LE();
+ header.saveMonth = in->readSint16LE();
+ header.saveDay = in->readSint16LE();
+ header.saveHour = in->readSint16LE();
header.saveMinutes = in->readSint16LE();
+ if (header.version >= 2) {
+ header.playTime = in->readUint32LE();
+ }
+
+
return true;
}