Fix bad endian bug in thumbnails code
svn-id: r18256
This commit is contained in:
parent
ca40942959
commit
de52d556d4
3 changed files with 13 additions and 6 deletions
|
@ -130,8 +130,12 @@ bool ScummEngine::loadState(int slot, bool compat) {
|
||||||
|
|
||||||
// Since version 52 a thumbnail is saved directly after the header
|
// Since version 52 a thumbnail is saved directly after the header
|
||||||
if (hdr.ver >= VER(52)) {
|
if (hdr.ver >= VER(52)) {
|
||||||
uint32 type = in->readUint32BE();
|
uint32 type;
|
||||||
if (type != MKID('THMB')) {
|
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");
|
warning("Can not load thumbnail");
|
||||||
delete in;
|
delete in;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace Scumm {
|
||||||
* only saves/loads those which are valid for the version of the savegame
|
* only saves/loads those which are valid for the version of the savegame
|
||||||
* which is being loaded/saved currently.
|
* 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
|
* An auxillary macro, used to specify savegame versions. We use this instead
|
||||||
|
|
|
@ -56,8 +56,11 @@ inline void colorToRGB(uint16 color, uint8 &r, uint8 &g, uint8 &b) {
|
||||||
|
|
||||||
Graphics::Surface *ScummEngine::loadThumbnail(Common::InSaveFile *file) {
|
Graphics::Surface *ScummEngine::loadThumbnail(Common::InSaveFile *file) {
|
||||||
ThumbnailHeader header;
|
ThumbnailHeader header;
|
||||||
header.type = file->readUint32BE();
|
file->read(&header.type, 4);
|
||||||
if (header.type != MKID('THMB'))
|
// 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;
|
return 0;
|
||||||
|
|
||||||
header.size = file->readUint32BE();
|
header.size = file->readUint32BE();
|
||||||
|
@ -111,7 +114,7 @@ void ScummEngine::saveThumbnail(Common::OutSaveFile *file) {
|
||||||
header.height = thumb.h;
|
header.height = thumb.h;
|
||||||
header.bpp = thumb.bytesPerPixel;
|
header.bpp = thumb.bytesPerPixel;
|
||||||
|
|
||||||
file->writeUint32BE(header.type);
|
file->write(&header.type, 4);
|
||||||
file->writeUint32BE(header.size);
|
file->writeUint32BE(header.size);
|
||||||
file->writeByte(header.version);
|
file->writeByte(header.version);
|
||||||
file->writeUint16BE(header.width);
|
file->writeUint16BE(header.width);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue