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
This commit is contained in:
parent
7746321ed6
commit
d577d863ce
4 changed files with 20 additions and 12 deletions
|
@ -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);
|
||||
|
||||
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.
|
||||
|
|
|
@ -197,7 +197,7 @@ public:
|
|||
|
||||
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 @@ public:
|
|||
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);
|
||||
|
||||
|
|
|
@ -566,7 +566,7 @@ bool CineEngine::loadTempSaveOS(Common::SeekableReadStream &in) {
|
|||
}
|
||||
|
||||
loadObjectTable(in);
|
||||
renderer->restorePalette(in);
|
||||
renderer->restorePalette(in, hdr.version);
|
||||
globalVars.load(in, NUM_MAX_VAR);
|
||||
loadZoneData(in);
|
||||
loadCommandVariables(in);
|
||||
|
@ -698,7 +698,7 @@ bool CineEngine::loadPlainSaveFW(Common::SeekableReadStream &in, CineSaveGameFor
|
|||
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);
|
||||
|
|
|
@ -74,7 +74,7 @@ enum CineSaveGameFormat {
|
|||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue