From dc0088f8fd2f168a38042678f7e0f3a2c083f47f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Fri, 31 Aug 2007 10:59:33 +0000 Subject: Fix end credits in IHNM. Now video length is determined properly. svn-id: r28771 --- engines/saga/animation.cpp | 13 +++++++++---- engines/saga/animation.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'engines/saga') diff --git a/engines/saga/animation.cpp b/engines/saga/animation.cpp index b16c26a2a1..d978956abc 100644 --- a/engines/saga/animation.cpp +++ b/engines/saga/animation.cpp @@ -385,6 +385,7 @@ void Anim::load(uint16 animId, const byte *animResourceData, size_t animResource anim->start += temp; // Cache frame offsets + anim->maxFrame = fillFrameOffsets(anim, false); anim->frameOffsets = (size_t *)malloc((anim->maxFrame + 1) * sizeof(*anim->frameOffsets)); if (anim->frameOffsets == NULL) { memoryError("Anim::load"); @@ -808,8 +809,8 @@ void Anim::decodeFrame(AnimationData *anim, size_t frameOffset, byte *buf, size_ } while (1); } -void Anim::fillFrameOffsets(AnimationData *anim) { - uint16 currentFrame; +int Anim::fillFrameOffsets(AnimationData *anim, bool reallyFill) { + uint16 currentFrame = 0; byte markByte; uint16 control; uint16 runcount; @@ -822,8 +823,10 @@ void Anim::fillFrameOffsets(AnimationData *anim) { readS._bigEndian = !_vm->isBigEndian(); // RLE has inversion BE<>LE - for (currentFrame = 0; currentFrame <= anim->maxFrame; currentFrame++) { - anim->frameOffsets[currentFrame] = readS.pos(); + while (!readS.eos()) { + if (reallyFill) + anim->frameOffsets[currentFrame] = readS.pos(); + currentFrame++; // For some strange reason, the animation header is in little // endian format, but the actual RLE encoded frame data, @@ -905,6 +908,8 @@ void Anim::fillFrameOffsets(AnimationData *anim) { } } while (markByte != SAGA_FRAME_END); } + + return currentFrame; } void Anim::animInfo() { diff --git a/engines/saga/animation.h b/engines/saga/animation.h index 7ea36d498e..90b24340a3 100644 --- a/engines/saga/animation.h +++ b/engines/saga/animation.h @@ -160,7 +160,7 @@ public: private: void decodeFrame(AnimationData *anim, size_t frameOffset, byte *buf, size_t bufLength); - void fillFrameOffsets(AnimationData *anim); + int fillFrameOffsets(AnimationData *anim, bool reallyFill = true); void validateAnimationId(uint16 animId) { if (animId >= MAX_ANIMATIONS) { -- cgit v1.2.3