aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Frühwirth2018-05-05 19:06:30 +0200
committerAdrian Frühwirth2018-05-05 22:19:03 +0200
commit057fb9bc6eb0afe9349ebe17bbcd819b003c078c (patch)
tree1c911ac25cf211994d0ca5d9d0eaeb2948efac2f
parent03312fba61d65fed96ff4f7dad0112c0db2187a5 (diff)
downloadscummvm-rg350-057fb9bc6eb0afe9349ebe17bbcd819b003c078c.tar.gz
scummvm-rg350-057fb9bc6eb0afe9349ebe17bbcd819b003c078c.tar.bz2
scummvm-rg350-057fb9bc6eb0afe9349ebe17bbcd819b003c078c.zip
CGE: Add play time metadata to savegames
-rw-r--r--engines/cge/cge.h7
-rw-r--r--engines/cge/cge_main.cpp27
-rw-r--r--engines/cge/detection.cpp17
3 files changed, 37 insertions, 14 deletions
diff --git a/engines/cge/cge.h b/engines/cge/cge.h
index 668224d2f7..9a8ea0dde9 100644
--- a/engines/cge/cge.h
+++ b/engines/cge/cge.h
@@ -56,7 +56,7 @@ class Walk;
class Text;
class Talk;
-#define kSavegameVersion 2
+#define kSavegameVersion 3
#define kSavegameStrSize 11
#define kPocketX 174
#define kPocketY 176
@@ -99,8 +99,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;
};
extern const char *savegameStr;
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index fcbbf34a4d..05461e30e1 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -242,6 +242,8 @@ bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) {
delete readStream;
return true;
}
+
+ g_engine->setTotalPlayTime(saveHeader.playTime * 1000);
}
// Get in the savegame
@@ -367,6 +369,8 @@ void CGEEngine::writeSavegameHeader(Common::OutSaveFile *out, SavegameHeader &he
out->writeSint16LE(td.tm_mday);
out->writeSint16LE(td.tm_hour);
out->writeSint16LE(td.tm_min);
+
+ out->writeUint32LE(g_engine->getTotalPlayTime() / 1000);
}
void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteStream *writeStream, bool tiny) {
@@ -421,13 +425,22 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt
}
WARN_UNUSED_RESULT bool CGEEngine::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;
@@ -438,12 +451,16 @@ WARN_UNUSED_RESULT bool CGEEngine::readSavegameHeader(Common::InSaveFile *in, Sa
}
// 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 >= 3) {
+ header.playTime = in->readUint32LE();
+ }
+
return true;
}
diff --git a/engines/cge/detection.cpp b/engines/cge/detection.cpp
index cae2e036b9..4c23939d60 100644
--- a/engines/cge/detection.cpp
+++ b/engines/cge/detection.cpp
@@ -176,12 +176,13 @@ const ADGameDescription *CGEMetaEngine::fallbackDetect(const FileMap &allFiles,
bool CGEMetaEngine::hasFeature(MetaEngineFeature f) const {
return
- (f == kSupportsListSaves) ||
- (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave) ||
- (f == kSavesSupportMetaInfo) ||
- (f == kSavesSupportThumbnail) ||
- (f == kSavesSupportCreationDate) ||
+ (f == kSupportsListSaves) ||
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail) ||
+ (f == kSavesSupportCreationDate) ||
+ (f == kSavesSupportPlayTime) ||
(f == kSimpleSavesNames);
}
@@ -263,6 +264,10 @@ SaveStateDescriptor CGEMetaEngine::querySaveMetaInfos(const char *target, int sl
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);