[Scummvm-cvs-logs] SF.net SVN: scummvm:[49699] scummvm/trunk/engines/cine

sev at users.sourceforge.net sev at users.sourceforge.net
Tue Jun 15 12:17:18 CEST 2010


Revision: 49699
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49699&view=rev
Author:   sev
Date:     2010-06-15 10:17:18 +0000 (Tue, 15 Jun 2010)

Log Message:
-----------
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.

Modified Paths:
--------------
    scummvm/trunk/engines/cine/gfx.cpp
    scummvm/trunk/engines/cine/gfx.h
    scummvm/trunk/engines/cine/saveload.cpp
    scummvm/trunk/engines/cine/saveload.h

Modified: scummvm/trunk/engines/cine/gfx.cpp
===================================================================
--- scummvm/trunk/engines/cine/gfx.cpp	2010-06-15 10:16:53 UTC (rev 49698)
+++ scummvm/trunk/engines/cine/gfx.cpp	2010-06-15 10:17:18 UTC (rev 49699)
@@ -772,7 +772,7 @@
  * 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 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,13 +835,22 @@
  * 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;
 
-	// Load the active 256 color palette from file
+	if (version > 0)
+		colorCount = fHandle.readUint16LE();
+
 	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.
 	fHandle.seek(kHighPalNumBytes, SEEK_CUR);

Modified: scummvm/trunk/engines/cine/gfx.h
===================================================================
--- scummvm/trunk/engines/cine/gfx.h	2010-06-15 10:16:53 UTC (rev 49698)
+++ scummvm/trunk/engines/cine/gfx.h	2010-06-15 10:17:18 UTC (rev 49699)
@@ -197,7 +197,7 @@
 
 	virtual void refreshPalette();
 	virtual void reloadPalette();
-	virtual void restorePalette(Common::SeekableReadStream &fHandle);
+	virtual void restorePalette(Common::SeekableReadStream &fHandle, int version);
 	virtual void savePalette(Common::OutSaveFile &fHandle);
 	virtual void rotatePalette(int a, int b, int c);
 	virtual void transformPalette(int first, int last, int r, int g, int b);
@@ -257,7 +257,7 @@
 	const char *getBgName(uint idx = 0) const;
 
 	void reloadPalette();
-	void restorePalette(Common::SeekableReadStream &fHandle);
+	void restorePalette(Common::SeekableReadStream &fHandle, int version);
 	void savePalette(Common::OutSaveFile &fHandle);
 	void transformPalette(int first, int last, int r, int g, int b);
 

Modified: scummvm/trunk/engines/cine/saveload.cpp
===================================================================
--- scummvm/trunk/engines/cine/saveload.cpp	2010-06-15 10:16:53 UTC (rev 49698)
+++ scummvm/trunk/engines/cine/saveload.cpp	2010-06-15 10:17:18 UTC (rev 49699)
@@ -566,7 +566,7 @@
 	}
 
 	loadObjectTable(in);
-	renderer->restorePalette(in);
+	renderer->restorePalette(in, hdr.version);
 	globalVars.load(in, NUM_MAX_VAR);
 	loadZoneData(in);
 	loadCommandVariables(in);
@@ -698,7 +698,7 @@
 	loadObjectTable(in);
 
 	// At 0x2043 (i.e. 0x005F + 2 * 2 + 255 * 32):
-	renderer->restorePalette(in);
+	renderer->restorePalette(in, 0);
 
 	// At 0x2083 (i.e. 0x2043 + 16 * 2 * 2):
 	globalVars.load(in, NUM_MAX_VAR);

Modified: scummvm/trunk/engines/cine/saveload.h
===================================================================
--- scummvm/trunk/engines/cine/saveload.h	2010-06-15 10:16:53 UTC (rev 49698)
+++ scummvm/trunk/engines/cine/saveload.h	2010-06-15 10:17:18 UTC (rev 49699)
@@ -74,7 +74,7 @@
 static const uint32 TEMP_OS_FORMAT_ID = MKID_BE('TEMP');
 
 /** The current version number of Operation Stealth's savegame format. */
-static const uint32 CURRENT_OS_SAVE_VER = 0;
+static const uint32 CURRENT_OS_SAVE_VER = 1;
 
 /** Chunk header used by the temporary Operation Stealth savegame format. */
 struct ChunkHeader {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list