[Scummvm-cvs-logs] CVS: scummvm/scumm saveload.cpp,1.228,1.229 saveload.h,1.61,1.62 thumbnail.cpp,1.2,1.3

Max Horn fingolfin at users.sourceforge.net
Thu May 26 03:09:10 CEST 2005


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

Modified Files:
	saveload.cpp saveload.h thumbnail.cpp 
Log Message:
Fix bad endian bug in thumbnails code

Index: saveload.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.cpp,v
retrieving revision 1.228
retrieving revision 1.229
diff -u -d -r1.228 -r1.229
--- saveload.cpp	23 May 2005 09:30:42 -0000	1.228
+++ saveload.cpp	26 May 2005 10:07:32 -0000	1.229
@@ -130,8 +130,12 @@
 	
 	// Since version 52 a thumbnail is saved directly after the header
 	if (hdr.ver >= VER(52)) {
-		uint32 type = in->readUint32BE();
-		if (type != MKID('THMB')) {
+		uint32 type;
+		in->read(&type, 4);
+
+		// Check for the THMB header. Also, work around a bug which caused
+		// the chunk type (incorrectly) to be written in LE on LE machines.
+		if (! (type == MKID('THMB') || (hdr.ver < VER(55) && type == MKID('BMHT')))){
 			warning("Can not load thumbnail");
 			delete in;
 			return false;

Index: saveload.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/saveload.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- saveload.h	23 May 2005 07:05:42 -0000	1.61
+++ saveload.h	26 May 2005 10:07:37 -0000	1.62
@@ -45,7 +45,7 @@
  * only saves/loads those which are valid for the version of the savegame
  * which is being loaded/saved currently.
  */
-#define CURRENT_VER 54
+#define CURRENT_VER 55
 
 /**
  * An auxillary macro, used to specify savegame versions. We use this instead

Index: thumbnail.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/thumbnail.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- thumbnail.cpp	10 May 2005 23:17:34 -0000	1.2
+++ thumbnail.cpp	26 May 2005 10:07:37 -0000	1.3
@@ -56,8 +56,11 @@
 
 Graphics::Surface *ScummEngine::loadThumbnail(Common::InSaveFile *file) {
 	ThumbnailHeader header;
-	header.type = file->readUint32BE();
-	if (header.type != MKID('THMB'))
+	file->read(&header.type, 4);
+	// We also accept the bad 'BMHT' header here, for the sake of compatibility
+	// with some older savegames which were written incorrectly due to a bug in
+	// ScummVM which wrote the thumb header type incorrectly on LE systems.
+	if (header.type != MKID('THMB') && header.type != MKID('BMHT'))
 		return 0;
 
 	header.size = file->readUint32BE();
@@ -111,7 +114,7 @@
 	header.height = thumb.h;
 	header.bpp = thumb.bytesPerPixel;
 
-	file->writeUint32BE(header.type);
+	file->write(&header.type, 4);
 	file->writeUint32BE(header.size);
 	file->writeByte(header.version);
 	file->writeUint16BE(header.width);





More information about the Scummvm-git-logs mailing list