aboutsummaryrefslogtreecommitdiff
path: root/engines/toon
diff options
context:
space:
mode:
authorDavid Fioramonti2018-08-17 19:51:08 -0700
committerEugene Sandulenko2018-08-18 14:21:28 +0200
commite2e0f9f5289a56031f9427040a4615264eeb9851 (patch)
tree9d89c7b3c9c7519a34428c66c5d75222b0c8668b /engines/toon
parent16ee8aa69f48ad3dd9183b4a525ee600ddaa7294 (diff)
downloadscummvm-rg350-e2e0f9f5289a56031f9427040a4615264eeb9851.tar.gz
scummvm-rg350-e2e0f9f5289a56031f9427040a4615264eeb9851.tar.bz2
scummvm-rg350-e2e0f9f5289a56031f9427040a4615264eeb9851.zip
TOON: Add playtime to saved game
Supports saved games made in the current version or the the last saved game version.
Diffstat (limited to 'engines/toon')
-rw-r--r--engines/toon/detection.cpp18
-rw-r--r--engines/toon/toon.cpp10
-rw-r--r--engines/toon/toon.h3
3 files changed, 23 insertions, 8 deletions
diff --git a/engines/toon/detection.cpp b/engines/toon/detection.cpp
index 634d286c7c..f3b510b6f4 100644
--- a/engines/toon/detection.cpp
+++ b/engines/toon/detection.cpp
@@ -160,6 +160,7 @@ bool ToonMetaEngine::hasFeature(MetaEngineFeature f) const {
(f == kSavesSupportMetaInfo) ||
(f == kSavesSupportThumbnail) ||
(f == kSavesSupportCreationDate) ||
+ (f == kSavesSupportPlayTime) ||
(f == kSimpleSavesNames);
}
@@ -168,7 +169,7 @@ void ToonMetaEngine::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(fileName);
}
-int ToonMetaEngine::getMaximumSaveSlot() const { return 99; }
+int ToonMetaEngine::getMaximumSaveSlot() const { return MAX_SAVE_SLOT; }
SaveStateList ToonMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
@@ -183,11 +184,11 @@ SaveStateList ToonMetaEngine::listSaves(const char *target) const {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(filename->c_str() + filename->size() - 3);
- if (slotNum >= 0 && slotNum <= 99) {
+ if (slotNum >= 0 && slotNum <= MAX_SAVE_SLOT) {
Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
if (file) {
int32 version = file->readSint32BE();
- if (version != TOON_SAVEGAME_VERSION) {
+ if ( (version < 4) || (version > TOON_SAVEGAME_VERSION) ) {
delete file;
continue;
}
@@ -220,7 +221,7 @@ SaveStateDescriptor ToonMetaEngine::querySaveMetaInfos(const char *target, int s
if (file) {
int32 version = file->readSint32BE();
- if (version != TOON_SAVEGAME_VERSION) {
+ if ( (version < 4) || (version > TOON_SAVEGAME_VERSION) ) {
delete file;
return SaveStateDescriptor();
}
@@ -232,8 +233,8 @@ SaveStateDescriptor ToonMetaEngine::querySaveMetaInfos(const char *target, int s
SaveStateDescriptor desc(slot, saveName);
- Graphics::Surface *thumbnail;
- if (!Graphics::loadThumbnail(*file, thumbnail)) {
+ Graphics::Surface *thumbnail = nullptr;
+ if (!Graphics::loadThumbnail(*file, thumbnail, false)) {
delete file;
return SaveStateDescriptor();
}
@@ -253,6 +254,11 @@ SaveStateDescriptor ToonMetaEngine::querySaveMetaInfos(const char *target, int s
desc.setSaveTime(hour, minutes);
+ if (version >= 5) {
+ uint32 playTimeMsec = file->readUint32BE();
+ desc.setPlayTime(playTimeMsec);
+ }
+
delete file;
return desc;
}
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 248057d539..d0a4059402 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -3378,6 +3378,8 @@ bool ToonEngine::saveGame(int32 slot, const Common::String &saveGameDesc) {
saveFile->writeUint32BE(saveDate);
saveFile->writeUint16BE(saveTime);
+ uint32 playTime = getTotalPlayTime();
+ saveFile->writeUint32BE(playTime);
// save global state
_gameState->save(saveFile);
@@ -3444,7 +3446,7 @@ bool ToonEngine::loadGame(int32 slot) {
return false;
int32 saveGameVersion = loadFile->readSint32BE();
- if (saveGameVersion != TOON_SAVEGAME_VERSION) {
+ if ( (saveGameVersion < 4) || (saveGameVersion > TOON_SAVEGAME_VERSION) ) {
delete loadFile;
return false;
}
@@ -3456,6 +3458,12 @@ bool ToonEngine::loadGame(int32 slot) {
loadFile->skip(6); // date & time skip
+ uint32 playTimeMsec = 0;
+ if (saveGameVersion >= 5) {
+ playTimeMsec = loadFile->readUint32BE();
+ }
+ setTotalPlayTime(playTimeMsec);
+
if (_gameState->_currentScene != -1) {
exitScene();
}
diff --git a/engines/toon/toon.h b/engines/toon/toon.h
index f419d491c6..efb473fef8 100644
--- a/engines/toon/toon.h
+++ b/engines/toon/toon.h
@@ -47,8 +47,9 @@ struct ADGameDescription;
#define TOON_DAT_VER_MAJ 0 // 1 byte
#define TOON_DAT_VER_MIN 3 // 1 byte
-#define TOON_SAVEGAME_VERSION 4
+#define TOON_SAVEGAME_VERSION 5
#define DATAALIGNMENT 4
+#define MAX_SAVE_SLOT 99
#define TOON_SCREEN_WIDTH 640
#define TOON_SCREEN_HEIGHT 400