From 74ef0d9cfe2106cd0e4286ccd3e829c2edc00f98 Mon Sep 17 00:00:00 2001 From: Ľubomír Remák Date: Sun, 15 Jul 2018 18:19:07 +0200 Subject: MUTATIONOFJB: Correctly handle empty animation frames. --- engines/mutationofjb/animationdecoder.cpp | 56 +++++++++++++++++-------------- 1 file changed, 30 insertions(+), 26 deletions(-) (limited to 'engines') diff --git a/engines/mutationofjb/animationdecoder.cpp b/engines/mutationofjb/animationdecoder.cpp index 5b201535c8..c88a9e095d 100644 --- a/engines/mutationofjb/animationdecoder.cpp +++ b/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 { -- cgit v1.2.3