diff options
author | James Brown | 2004-09-10 12:13:03 +0000 |
---|---|---|
committer | James Brown | 2004-09-10 12:13:03 +0000 |
commit | a427d72d0407aae11ae43ebe54aa630bd8323160 (patch) | |
tree | acb253def947cecb88ac9f1c67c5cc19773f2103 | |
parent | 71866c1287d35bb88b4d9dc048b296cc84bafb32 (diff) | |
download | scummvm-rg350-a427d72d0407aae11ae43ebe54aa630bd8323160.tar.gz scummvm-rg350-a427d72d0407aae11ae43ebe54aa630bd8323160.tar.bz2 scummvm-rg350-a427d72d0407aae11ae43ebe54aa630bd8323160.zip |
Store SCUMM md5s in save game. Save format bump.
svn-id: r14996
-rw-r--r-- | scumm/intern.h | 25 | ||||
-rw-r--r-- | scumm/saveload.cpp | 20 | ||||
-rw-r--r-- | scumm/saveload.h | 2 | ||||
-rw-r--r-- | scumm/scumm.cpp | 85 | ||||
-rw-r--r-- | scumm/scumm.h | 3 |
5 files changed, 88 insertions, 47 deletions
diff --git a/scumm/intern.h b/scumm/intern.h index d9d0723b7a..bcc7552177 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -42,7 +42,8 @@ protected: const OpcodeEntryV5 *_opcodesV5; public: - ScummEngine_v5(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine(detector, syst, gs) {} + ScummEngine_v5(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : +ScummEngine(detector, syst, gs, md5sum) {} protected: virtual void setupOpcodes(); @@ -174,7 +175,7 @@ protected: // of preserving the right readIndexFile / loadCharset !!! class ScummEngine_v3 : public ScummEngine_v5 { public: - ScummEngine_v3(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v5(detector, syst, gs) {} + ScummEngine_v3(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v5(detector, syst, gs, md5sum) {} protected: void readIndexFile(); @@ -201,7 +202,7 @@ protected: const OpcodeEntryV2 *_opcodesV2; public: - ScummEngine_v2(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v3(detector, syst, gs) {} + ScummEngine_v2(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v3(detector, syst, gs, md5sum) {} protected: virtual void setupOpcodes(); @@ -308,7 +309,7 @@ protected: class ScummEngine_v4 : public ScummEngine_v3 { public: - ScummEngine_v4(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v3(detector, syst, gs) {} + ScummEngine_v4(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v3(detector, syst, gs, md5sum) {} protected: void loadCharset(int no); @@ -329,7 +330,7 @@ protected: int _smushFrameRate; public: - ScummEngine_v6(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs); + ScummEngine_v6(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]); virtual void scummInit(); @@ -555,7 +556,7 @@ protected: File _hFileTable[17]; public: - ScummEngine_v6he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v6(detector, syst, gs) {} + ScummEngine_v6he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v6(detector, syst, gs, md5sum) {} protected: virtual void setupOpcodes(); @@ -608,7 +609,7 @@ protected: const OpcodeEntryV7he *_opcodesV7he; public: - ScummEngine_v7he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs); + ScummEngine_v7he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]); protected: virtual void setupOpcodes(); @@ -677,7 +678,7 @@ protected: uint16 _wizImagesNum; public: - ScummEngine_v72he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v7he(detector, syst, gs), _wizImagesNum(0) {} + ScummEngine_v72he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v7he(detector, syst, gs, md5sum), _wizImagesNum(0) {} protected: virtual void setupScummVars(); @@ -775,7 +776,7 @@ protected: const OpcodeEntryV80he *_opcodesV80he; public: - ScummEngine_v80he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v72he(detector, syst, gs) {} + ScummEngine_v80he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v72he(detector, syst, gs, md5sum) {} protected: virtual void setupOpcodes(); @@ -804,7 +805,7 @@ protected: const OpcodeEntryV90he *_opcodesV90he; public: - ScummEngine_v90he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v80he(detector, syst, gs) {} + ScummEngine_v90he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v80he(detector, syst, gs, md5sum) {} protected: virtual void setupOpcodes(); @@ -823,7 +824,7 @@ protected: class ScummEngine_v7 : public ScummEngine_v6 { public: - ScummEngine_v7(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v6(detector, syst, gs) {} + ScummEngine_v7(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v6(detector, syst, gs, md5sum) {} protected: virtual void setupScummVars(); @@ -845,7 +846,7 @@ protected: const OpcodeEntryV8 *_opcodesV8; public: - ScummEngine_v8(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) : ScummEngine_v7(detector, syst, gs) {} + ScummEngine_v8(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : ScummEngine_v7(detector, syst, gs, md5sum) {} protected: virtual void setupOpcodes(); diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp index aba1fcc3d1..d60232a730 100644 --- a/scumm/saveload.cpp +++ b/scumm/saveload.cpp @@ -414,6 +414,7 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { }; const SaveLoadEntry mainEntries[] = { + MKARRAY(ScummEngine, _gameMD5[0], sleUint8, 16, VER(39)), MKLINE(ScummEngine, _roomWidth, sleUint16, VER(8)), MKLINE(ScummEngine, _roomHeight, sleUint16, VER(8)), MKLINE(ScummEngine, _ENCD_offs, sleUint32, VER(8)), @@ -661,9 +662,28 @@ void ScummEngine::saveOrLoad(Serializer *s, uint32 savegameVersion) { int i, j; int var120Backup; int var98Backup; + uint8 md5Backup[16]; + + // MD5 Operations: Backup on load, compare, and reset. + if (s->isLoading()) { + for (i=0; i<17; i++) md5Backup[i] = _gameMD5[i]; + } s->saveLoadEntries(this, mainEntries); + // MD5 Operations: Backup on load, compare, and reset. + if (s->isLoading()) { + for (j = 0; j < 16; j++) { + if (_gameMD5[j] != md5Backup[j]) { + warning("Game was saved with different gamedata - you may encounter problems."); + _gameMD5[j] = md5Backup[j]; + break; + } + _gameMD5[j] = md5Backup[j]; + } + } + + if (s->isLoading() && savegameVersion < VER(14)) upgradeGfxUsageBits(); diff --git a/scumm/saveload.h b/scumm/saveload.h index fba338e6db..2ed1a87f1f 100644 --- a/scumm/saveload.h +++ b/scumm/saveload.h @@ -32,7 +32,7 @@ namespace Scumm { // Can be useful for other ports too :) #define VER(x) x -#define CURRENT_VER 38 +#define CURRENT_VER 39 // To work around a warning in GCC 3.2 (and 3.1 ?) regarding non-POD types, // we use a small trick: instead of 0 we use 42. Why? Well, it seems newer GCC diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 701cc3810a..6bd27d89a5 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -416,7 +416,7 @@ static int compareMD5Table(const void *a, const void *b) { return strcmp(key, elem->md5); } -ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) +ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) : Engine(syst), _gameId(gs.id), _version(gs.version), @@ -425,6 +425,9 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS gdi(this), _pauseDialog(0), _optionsDialog(0), _mainMenuDialog(0), _versionDialog(0), _targetName(detector->_targetName) { + // Copy md5sum + for (int i = 0; i < 17; i++) _gameMD5[i] = md5sum[i]; + // Add default file directories. if (((_features & GF_AMIGA) || (_features & GF_ATARI_ST)) && (_version <= 4)) { // This is for the Amiga version of Indy3/Loom/Maniac/Zak @@ -1081,8 +1084,8 @@ ScummEngine::~ScummEngine() { delete _debugger; } -ScummEngine_v6::ScummEngine_v6(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) - : ScummEngine(detector, syst, gs) { +ScummEngine_v6::ScummEngine_v6(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) + : ScummEngine(detector, syst, gs, md5sum) { VAR_VIDEONAME = 0xFF; VAR_RANDOM_NR = 0xFF; VAR_STRING2DRAW = 0xFF; @@ -1097,8 +1100,8 @@ ScummEngine_v6::ScummEngine_v6(GameDetector *detector, OSystem *syst, const Scum _smushFrameRate = 0; } -ScummEngine_v7he::ScummEngine_v7he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs) - : ScummEngine_v6he(detector, syst, gs) { +ScummEngine_v7he::ScummEngine_v7he(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]) + : ScummEngine_v6he(detector, syst, gs, md5sum) { _Win32ResExtractor = new Win32ResExtractor(this); } @@ -3271,26 +3274,39 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) { ScummGameSettings game = *g; - if (game.features & GF_MULTIPLE_VERSIONS) { - uint8 md5sum[16]; - char buf[256]; - const char *name = game.name; - char md5str[32+1]; - - if (game.features & GF_HUMONGOUS) - sprintf(buf, "%s.he0", name); - else - sprintf(buf, "%s.000", name); + // Calculate MD5 of the games detection file, for savegames etc. + const char *name = g->name; + char detectName[256], gameMD5[32+1]; + uint8 md5sum[16]; + + if (g->detectFilename) { + strcpy(detectName, game.detectFilename); + } else if (g->version <= 3) { + strcpy(detectName, "00.LFL"); + } else if (g->version == 4) { + strcpy(detectName, "000.LFL"); + } else if (g->version >= 7) { + strcpy(detectName, name); + strcat(detectName, ".la0"); + } else if (g->features & GF_HUMONGOUS) { + strcpy(detectName, name); + strcat(detectName, ".he0"); + } else { + strcpy(detectName, name); + strcat(detectName, ".000"); + } - if (md5_file(buf, md5sum, ConfMan.get("path").c_str())) { - for (int j = 0; j < 16; j++) { - sprintf(md5str + j*2, "%02x", (int)md5sum[j]); - } + if (md5_file(detectName, md5sum, ConfMan.get("path").c_str())) { + for (int j = 0; j < 16; j++) { + sprintf(gameMD5 + j*2, "%02x", (int)md5sum[j]); } - + } + + // Use MD5 to determine specific game version, if required. + if (game.features & GF_MULTIPLE_VERSIONS) { g = he_md5_settings; while (g->name) { - if (!scumm_stricmp(md5str, g->name)) + if (!scumm_stricmp(gameMD5, g->name)) break; g++; } @@ -3303,6 +3319,9 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) { } } + // TODO: REMOVE DEPRECATED OPTION + // (Perhaps GUI should display a messagebox on encountering an unknown key?) + if (ConfMan.hasKey("amiga")) { warning("Configuration key 'amiga' is deprecated. Use 'platform=amiga' instead"); if (ConfMan.getBool("amiga")) @@ -3350,16 +3369,16 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) { switch (game.version) { case 1: case 2: - engine = new ScummEngine_v2(detector, syst, game); + engine = new ScummEngine_v2(detector, syst, game, md5sum); break; case 3: - engine = new ScummEngine_v3(detector, syst, game); + engine = new ScummEngine_v3(detector, syst, game, md5sum); break; case 4: - engine = new ScummEngine_v4(detector, syst, game); + engine = new ScummEngine_v4(detector, syst, game, md5sum); break; case 5: - engine = new ScummEngine_v5(detector, syst, game); + engine = new ScummEngine_v5(detector, syst, game, md5sum); break; case 6: switch (game.heversion) { @@ -3367,32 +3386,32 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) { case 90: case 98: case 99: - engine = new ScummEngine_v90he(detector, syst, game); + engine = new ScummEngine_v90he(detector, syst, game, md5sum); break; case 80: - engine = new ScummEngine_v80he(detector, syst, game); + engine = new ScummEngine_v80he(detector, syst, game, md5sum); break; case 72: - engine = new ScummEngine_v72he(detector, syst, game); + engine = new ScummEngine_v72he(detector, syst, game, md5sum); break; case 71: case 70: - engine = new ScummEngine_v7he(detector, syst, game); + engine = new ScummEngine_v7he(detector, syst, game, md5sum); break; #endif case 60: - engine = new ScummEngine_v6he(detector, syst, game); + engine = new ScummEngine_v6he(detector, syst, game, md5sum); break; default: - engine = new ScummEngine_v6(detector, syst, game); + engine = new ScummEngine_v6(detector, syst, game, md5sum); } break; case 7: - engine = new ScummEngine_v7(detector, syst, game); + engine = new ScummEngine_v7(detector, syst, game, md5sum); break; #ifndef __PALM_OS__ case 8: - engine = new ScummEngine_v8(detector, syst, game); + engine = new ScummEngine_v8(detector, syst, game, md5sum); break; #endif default: diff --git a/scumm/scumm.h b/scumm/scumm.h index d58cf7783e..b572bd6026 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -346,6 +346,7 @@ public: byte _version; byte _heversion; uint32 _features; // Should only be accessed for reading (TODO enforce it compiler-wise with making it private and creating an accessor) + uint8 _gameMD5[16]; /** Random number generator */ Common::RandomSource _rnd; @@ -371,7 +372,7 @@ protected: public: // Constructor / Destructor - ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs); + ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameSettings &gs, uint8 md5sum[16]); virtual ~ScummEngine(); // Init functions |