Permalink
Browse files

MUTATIONOFJB: Correctly handle empty animation frames.

  • Loading branch information...
LubomirR authored and sev- committed Jul 15, 2018
1 parent 2ee0a90 commit 74ef0d9cfe2106cd0e4286ccd3e829c2edc00f98
Showing with 30 additions and 26 deletions.
  1. +30 −26 engines/mutationofjb/animationdecoder.cpp
@@ -61,34 +61,38 @@ bool AnimationDecoder::decode(AnimationDecoderCallback *callback) {

// Subrecords.
if (recordId == 0xF1FA) {
for (int i = 0; i < subrecords; ++i) {
int32 filePos = file.pos();

const uint32 subLength = file.readUint32LE();
const uint16 type = file.readUint16LE();

if (type == 0x0B) {
loadPalette(file);
if (callback) {
callback->onPaletteUpdated(_palette);
}
} else if (type == 0x0F) {
loadFullFrame(file, subLength - 6);
if (callback) {
callback->onFrame(frameNo, _surface);
}
} else if (type == 0x0C) {
loadDiffFrame(file, subLength - 6);
if (callback) {
callback->onFrame(frameNo, _surface);
if (subrecords == 0) {
callback->onFrame(frameNo, _surface); // Empty record, frame identical to the previous one.
} else {
for (int i = 0; i < subrecords; ++i) {
int32 filePos = file.pos();

const uint32 subLength = file.readUint32LE();
const uint16 type = file.readUint16LE();

if (type == 0x0B) {
loadPalette(file);
if (callback) {
callback->onPaletteUpdated(_palette);
}
} else if (type == 0x0F) {
loadFullFrame(file, subLength - 6);
if (callback) {
callback->onFrame(frameNo, _surface);
}
} else if (type == 0x0C) {
loadDiffFrame(file, subLength - 6);
if (callback) {
callback->onFrame(frameNo, _surface);
}
} else {
debug(_("Unsupported record type %02X."), type);
file.seek(subLength - 6, SEEK_CUR);
}
} else {
debug(_("Unsupported record type %02X."), type);
file.seek(subLength - 6, SEEK_CUR);
}

// Makes decoding more robust, because for some reason records might have extra data at the end.
file.seek(filePos + subLength, SEEK_SET);
// Makes decoding more robust, because for some reason records might have extra data at the end.
file.seek(filePos + subLength, SEEK_SET);
}
}
frameNo++;
} else {

0 comments on commit 74ef0d9

Please sign in to comment.