aboutsummaryrefslogtreecommitdiff
path: root/scumm
diff options
context:
space:
mode:
authorMax Horn2005-05-26 10:07:37 +0000
committerMax Horn2005-05-26 10:07:37 +0000
commitde52d556d434424f093fb954da8d1fa27025d17e (patch)
tree8f8d1986d71b63b5b7b5b2a8088e465e28328762 /scumm
parentca40942959b494edf8ff4754f7f64215d8cf70f4 (diff)
downloadscummvm-rg350-de52d556d434424f093fb954da8d1fa27025d17e.tar.gz
scummvm-rg350-de52d556d434424f093fb954da8d1fa27025d17e.tar.bz2
scummvm-rg350-de52d556d434424f093fb954da8d1fa27025d17e.zip
Fix bad endian bug in thumbnails code
svn-id: r18256
Diffstat (limited to 'scumm')
-rw-r--r--scumm/saveload.cpp8
-rw-r--r--scumm/saveload.h2
-rw-r--r--scumm/thumbnail.cpp9
3 files changed, 13 insertions, 6 deletions
diff --git a/scumm/saveload.cpp b/scumm/saveload.cpp
index d276c8257a..ab050a7673 100644
--- a/scumm/saveload.cpp
+++ b/scumm/saveload.cpp
@@ -130,8 +130,12 @@ bool ScummEngine::loadState(int slot, bool compat) {
// 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;
diff --git a/scumm/saveload.h b/scumm/saveload.h
index ac0528c834..faee798a9f 100644
--- a/scumm/saveload.h
+++ b/scumm/saveload.h
@@ -45,7 +45,7 @@ namespace Scumm {
* 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
diff --git a/scumm/thumbnail.cpp b/scumm/thumbnail.cpp
index 81aa830ce4..701b651b31 100644
--- a/scumm/thumbnail.cpp
+++ b/scumm/thumbnail.cpp
@@ -56,8 +56,11 @@ inline void colorToRGB(uint16 color, uint8 &r, uint8 &g, uint8 &b) {
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 @@ void ScummEngine::saveThumbnail(Common::OutSaveFile *file) {
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);