aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorEugene Sandulenko2009-06-06 17:41:50 +0000
committerEugene Sandulenko2009-06-06 17:41:50 +0000
commitb26ae991f8b03ee03710f7bf29e134ca4fa42319 (patch)
treee18edc5b2ca1f5562f569cd911b53e5759f3fbc8 /engines/agi
parenta5d762c029b904258cc1346fea54fb255585470f (diff)
downloadscummvm-rg350-b26ae991f8b03ee03710f7bf29e134ca4fa42319.tar.gz
scummvm-rg350-b26ae991f8b03ee03710f7bf29e134ca4fa42319.tar.bz2
scummvm-rg350-b26ae991f8b03ee03710f7bf29e134ca4fa42319.zip
Store and compare MD5s in the saves
svn-id: r41245
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/agi.h2
-rw-r--r--engines/agi/detection.cpp4
-rw-r--r--engines/agi/saveload.cpp25
3 files changed, 30 insertions, 1 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 5a577c9fba..fb58c86db2 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -754,6 +754,8 @@ public:
uint16 getGameType() const;
Common::Language getLanguage() const;
Common::Platform getPlatform() const;
+ const char *getGameMD5() const;
+
Common::Error loadGameState(int slot);
Common::Error saveGameState(int slot, const char *desc);
bool canLoadGameStateCurrently();
diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp
index fd81fc0ca0..daea94cb9b 100644
--- a/engines/agi/detection.cpp
+++ b/engines/agi/detection.cpp
@@ -70,6 +70,10 @@ uint16 AgiBase::getGameType() const {
return _gameDescription->gameType;
}
+const char *AgiBase::getGameMD5() const {
+ return _gameDescription->desc.filesDescriptions[0].md5;
+}
+
}
static const PlainGameDescriptor agiGames[] = {
diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp
index e4cf4afd2c..46f6d8d734 100644
--- a/engines/agi/saveload.cpp
+++ b/engines/agi/saveload.cpp
@@ -39,7 +39,7 @@
#include "agi/keyboard.h"
#include "agi/menu.h"
-#define SAVEGAME_VERSION 4
+#define SAVEGAME_VERSION 5
//
// Version 0 (Sarien): view table has 64 entries
@@ -47,6 +47,7 @@
// Version 2 (ScummVM): first ScummVM version
// Version 3 (ScummVM): added AGIPAL save/load support
// Version 4 (ScummVM): added thumbnails and save creation date/time
+// Version 5 (ScummVM): Added game md5
//
namespace Agi {
@@ -96,6 +97,10 @@ int AgiEngine::saveGame(const char *fileName, const char *description) {
out->write(gameIDstring, 8);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game id (%s, %s)", gameIDstring, _game.id);
+ const char *tmp = getGameMD5();
+ for (i = 0; i < 32; i++)
+ out->writeByte(tmp[i]);
+
for (i = 0; i < MAX_FLAGS; i++)
out->writeByte(_game.flags[i]);
for (i = 0; i < MAX_VARS; i++)
@@ -299,6 +304,24 @@ int AgiEngine::loadGame(const char *fileName, bool checkId) {
strncpy(_game.id, loadId, 8);
+ if (saveVersion >= 5) {
+ char md5[32 + 1];
+
+ for (i = 0; i < 32; i++) {
+ md5[i] = in->readByte();
+
+ }
+ md5[i] = 0; // terminate
+
+ debug(0, "Saved game MD5: %s", md5);
+
+ if (strcmp(md5, getGameMD5())) {
+ warning("Game was saved with different gamedata - you may encounter problems");
+
+ debug(0, "You have %s and save is %s.", getGameMD5(), md5);
+ }
+ }
+
for (i = 0; i < MAX_FLAGS; i++)
_game.flags[i] = in->readByte();
for (i = 0; i < MAX_VARS; i++)