From 3619b613bcf92386c62b4c23fed62502bbdd712d Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Tue, 26 Nov 2019 22:12:33 +0100 Subject: BLADERUNNER: Fixed crossplatform thumbnails in saves Thumbnail was broken when savefile was transfered between big endiang and little endian platforms. closes #11258 --- engines/bladerunner/bladerunner.cpp | 10 ++++++++-- engines/bladerunner/savefile.cpp | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'engines/bladerunner') diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 21ebebcd0b..3493c8adbb 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -2043,7 +2043,12 @@ bool BladeRunnerEngine::saveGame(Common::WriteStream &stream, Graphics::Surface SaveFileWriteStream s(memoryStream); thumbnail.convertToInPlace(gameDataPixelFormat()); - s.write(thumbnail.getPixels(), SaveFileManager::kThumbnailSize); + + uint16* thumbnailData = (uint16*)thumbnail.getPixels(); + for (uint i = 0; i < SaveFileManager::kThumbnailSize / 2; ++i) { + s.writeUint16LE(thumbnailData[i]); + } + s.writeFloat(1.0f); _settings->save(s); _scene->save(s); @@ -2126,8 +2131,9 @@ bool BladeRunnerEngine::loadGame(Common::SeekableReadStream &stream) { _gameIsLoading = true; _settings->setLoadingGame(); + s.skip(SaveFileManager::kThumbnailSize); // skip the thumbnail - s.skip(4);// always float 1.0, but never used + s.skip(4);// always float 1.0, but never used, assuming it's the game version _settings->load(s); _scene->load(s); _scene->_exits->load(s); diff --git a/engines/bladerunner/savefile.cpp b/engines/bladerunner/savefile.cpp index 1ea1a8807d..7a0739bd98 100644 --- a/engines/bladerunner/savefile.cpp +++ b/engines/bladerunner/savefile.cpp @@ -146,8 +146,10 @@ bool SaveFileManager::readHeader(Common::SeekableReadStream &in, SaveFileHeader s.skip(4); //skip size; - void *thumbnailData = malloc(kThumbnailSize); // freed by ScummVM's smartptr - s.read(thumbnailData, kThumbnailSize); + uint16 *thumbnailData = (uint16*)malloc(kThumbnailSize); // freed by ScummVM's smartptr + for (uint i = 0; i < kThumbnailSize / 2; ++i) { + thumbnailData[i] = s.readUint16LE(); + } header._thumbnail->init(80, 60, 160, thumbnailData, gameDataPixelFormat()); -- cgit v1.2.3