aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/saveload.cpp
diff options
context:
space:
mode:
authorFilippos Karapetis2008-11-10 19:02:47 +0000
committerFilippos Karapetis2008-11-10 19:02:47 +0000
commit2b59700d2a311c0486912435624bac78fe1f9dbb (patch)
tree025ae9e8ed87c3ddd1c52d50e4ad8ab1b29a3039 /engines/agi/saveload.cpp
parenta859e2c1c925252b6c7693efb052bc2ff28915db (diff)
downloadscummvm-rg350-2b59700d2a311c0486912435624bac78fe1f9dbb.tar.gz
scummvm-rg350-2b59700d2a311c0486912435624bac78fe1f9dbb.tar.bz2
scummvm-rg350-2b59700d2a311c0486912435624bac78fe1f9dbb.zip
AGI save games now contain thumbnails and creation date/time (visible from the GMM save/load screens)
svn-id: r34989
Diffstat (limited to 'engines/agi/saveload.cpp')
-rw-r--r--engines/agi/saveload.cpp41
1 files changed, 38 insertions, 3 deletions
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index 179db94a71..e8fb2522b1 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -28,8 +28,10 @@
* Multi-slots by Claudio Matsuoka <claudio@helllabs.org>
*/
+#include <time.h> // for extended infos
#include "common/file.h"
+#include "graphics/thumbnail.h"
#include "agi/agi.h"
#include "agi/graphics.h"
@@ -37,13 +39,14 @@
#include "agi/keyboard.h"
#include "agi/menu.h"
-#define SAVEGAME_VERSION 3
+#define SAVEGAME_VERSION 4
/*
* Version 0 (Sarien): view table has 64 entries
* Version 1 (Sarien): view table has 256 entries (needed in KQ3)
* Version 2 (ScummVM): first ScummVM version
- * Version 3 (ScummVM): adding AGIPAL save/load support
+ * Version 3 (ScummVM): added AGIPAL save/load support
+ * Version 4 (ScummVM): added thumbnails and save creation date/time
*/
namespace Agi {
@@ -70,6 +73,22 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
out->writeByte(SAVEGAME_VERSION);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save game version (%d)", SAVEGAME_VERSION);
+ // Thumbnail
+ Graphics::saveThumbnail(*out);
+
+ // Creation date/time
+ tm curTime;
+ _system->getTimeAndDate(curTime);
+
+ uint32 saveDate = (curTime.tm_mday & 0xFF) << 24 | ((curTime.tm_mon + 1) & 0xFF) << 16 | (curTime.tm_year + 1900) & 0xFFFF;
+ uint16 saveTime = (curTime.tm_hour & 0xFF) << 8 | (curTime.tm_min) & 0xFF;
+
+ out->writeUint32BE(saveDate);
+ debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save date (%d)", saveDate);
+ out->writeUint16BE(saveTime);
+ debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save time (%d)", saveTime);
+ // TODO: played time
+
out->writeByte(_game.state);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game state (%d)", _game.state);
@@ -250,9 +269,25 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
debugC(6, kDebugLevelMain | kDebugLevelSavegame, "Description is: %s", description);
saveVersion = in->readByte();
- if (saveVersion != SAVEGAME_VERSION)
+ if (saveVersion < 2) // is the save game pre-ScummVM?
warning("Old save game version (%d, current version is %d). Will try and read anyway, but don't be surprised if bad things happen", saveVersion, SAVEGAME_VERSION);
+ if (saveVersion < 3)
+ warning("This save game contains no AGIPAL data, if the game is using the AGIPAL hack, it won't work correctly");
+
+ if (saveVersion >= 4) {
+ // We don't need the thumbnail here, so just read it and discard it
+ Graphics::Surface *thumbnail = new Graphics::Surface();
+ assert(thumbnail);
+ Graphics::loadThumbnail(*in, *thumbnail);
+ delete thumbnail;
+ thumbnail = 0;
+
+ in->readUint32BE(); // save date
+ in->readUint16BE(); // save time
+ // TODO: played time
+ }
+
_game.state = in->readByte();
in->read(loadId, 8);