[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.235,2.236 saveload.cpp,1.170,1.171 saveload.h,1.41,1.42 scumm.cpp,1.188,1.189 scumm.h,1.476,1.477

James Brown ender at users.sourceforge.net
Fri Sep 10 05:14:00 CEST 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21548/scumm

Modified Files:
	intern.h saveload.cpp saveload.h scumm.cpp scumm.h 
Log Message:
Store SCUMM md5s in save game. Save format bump.


Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.235
retrieving revision 2.236
diff -u -d -r2.235 -r2.236
--- intern.h	10 Sep 2004 10:55:43 -0000	2.235
+++ intern.h	10 Sep 2004 12:13:02 -0000	2.236
@@ -42,7 +42,8 @@
 	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 @@
 // 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 @@
 	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 @@
 
 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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 
 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 @@
 	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();

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.170
retrieving revision 1.171
diff -u -d -r1.170 -r1.171
--- saveload.cpp	10 Sep 2004 01:03:01 -0000	1.170
+++ saveload.cpp	10 Sep 2004 12:13:03 -0000	1.171
@@ -414,6 +414,7 @@
 	};
 
 	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 @@
 	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();
 

Index: saveload.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.h,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- saveload.h	10 Sep 2004 01:03:01 -0000	1.41
+++ saveload.h	10 Sep 2004 12:13:03 -0000	1.42
@@ -32,7 +32,7 @@
 // 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

Index: scumm.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.cpp,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -d -r1.188 -r1.189
--- scumm.cpp	10 Sep 2004 10:45:22 -0000	1.188
+++ scumm.cpp	10 Sep 2004 12:13:03 -0000	1.189
@@ -416,7 +416,7 @@
 	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 @@
 	  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 @@
 	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 @@
 	_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 @@
 
 	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 (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 (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(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 @@
 		}
 	}
 
+	// 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 @@
 	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 @@
 		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:

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.476
retrieving revision 1.477
diff -u -d -r1.476 -r1.477
--- scumm.h	10 Sep 2004 10:45:22 -0000	1.476
+++ scumm.h	10 Sep 2004 12:13:03 -0000	1.477
@@ -346,6 +346,7 @@
 	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 @@
 
 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





More information about the Scummvm-git-logs mailing list