diff options
author | Eugene Sandulenko | 2010-06-15 10:17:18 +0000 |
---|---|---|
committer | Eugene Sandulenko | 2010-06-15 10:17:18 +0000 |
commit | d577d863ce4cee58b973e3a1cb461ad339e91c61 (patch) | |
tree | 1ae16c719c99c43ca7b3bcf51240fd72b010ccc7 /engines/cine/gfx.cpp | |
parent | 7746321ed62d80c918a3687b595405e07e80e2aa (diff) | |
download | scummvm-rg350-d577d863ce4cee58b973e3a1cb461ad339e91c61.tar.gz scummvm-rg350-d577d863ce4cee58b973e3a1cb461ad339e91c61.tar.bz2 scummvm-rg350-d577d863ce4cee58b973e3a1cb461ad339e91c61.zip |
CINE: Fix bug #2812694.
Bug #2812694: "CINE: Operation Stealth german crash". Our code
assumed that there exists only 256-color version which is not
the case for German version. Added code to store background
format. Old savegames are broken and could not be fixed.
Bumped savefile version.
svn-id: r49699
Diffstat (limited to 'engines/cine/gfx.cpp')
-rw-r--r-- | engines/cine/gfx.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/engines/cine/gfx.cpp b/engines/cine/gfx.cpp index a4220e6e35..aa0330df84 100644 --- a/engines/cine/gfx.cpp +++ b/engines/cine/gfx.cpp @@ -772,7 +772,7 @@ const char *FWRenderer::getBgName(uint idx) const { * Restore active and backup palette from save * @param fHandle Savefile open for reading */ -void FWRenderer::restorePalette(Common::SeekableReadStream &fHandle) { +void FWRenderer::restorePalette(Common::SeekableReadStream &fHandle, int version) { byte buf[kLowPalNumBytes]; // Load the active 16 color palette from file @@ -819,9 +819,8 @@ void FWRenderer::savePalette(Common::OutSaveFile &fHandle) { void OSRenderer::savePalette(Common::OutSaveFile &fHandle) { byte buf[kHighPalNumBytes]; - // Make sure the active palette has the correct format and color count - assert(_activePal.colorFormat() == kHighPalFormat); - assert(_activePal.colorCount() == kHighPalNumColors); + // We can have 16 color palette in many cases + fHandle.writeUint16LE(_activePal.colorCount()); // Write the active 256 color palette. _activePal.save(buf, sizeof(buf), CINE_LITTLE_ENDIAN); @@ -836,12 +835,21 @@ void OSRenderer::savePalette(Common::OutSaveFile &fHandle) { * Restore active and backup palette from save * @param fHandle Savefile open for reading */ -void OSRenderer::restorePalette(Common::SeekableReadStream &fHandle) { +void OSRenderer::restorePalette(Common::SeekableReadStream &fHandle, int version) { byte buf[kHighPalNumBytes]; + uint colorCount; + + if (version > 0) + colorCount = fHandle.readUint16LE(); - // Load the active 256 color palette from file fHandle.read(buf, kHighPalNumBytes); - _activePal.load(buf, sizeof(buf), kHighPalFormat, kHighPalNumColors, CINE_LITTLE_ENDIAN); + + if (colorCount == kHighPalNumBytes || version == 0) { + // Load the active 256 color palette from file + _activePal.load(buf, sizeof(buf), kHighPalFormat, kHighPalNumColors, CINE_LITTLE_ENDIAN); + } else { + _activePal.load(buf, sizeof(buf), kLowPalFormat, kLowPalNumColors, CINE_LITTLE_ENDIAN); + } // Jump over the backup 256 color palette. // FIXME: Load the backup 256 color palette and use it properly. |