diff options
author | Torbjörn Andersson | 2005-01-03 17:39:20 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-01-03 17:39:20 +0000 |
commit | 9f0783e3914a45283cd09cc0d8861c8acd7c9d0e (patch) | |
tree | d7966e75a49ba1c4e3a1cb1f2c44b80f3456b7ab | |
parent | ab432327d89e239c077eda6d64f50253773e9d76 (diff) | |
download | scummvm-rg350-9f0783e3914a45283cd09cc0d8861c8acd7c9d0e.tar.gz scummvm-rg350-9f0783e3914a45283cd09cc0d8861c8acd7c9d0e.tar.bz2 scummvm-rg350-9f0783e3914a45283cd09cc0d8861c8acd7c9d0e.zip |
Fixed a regression where - I think - the last animation frame wasn't
displayed. This was most noticeable in looping animations, in particular
the spinning "Dreamer's Guild" logo in the IHNM intro.
In the process I changed the name of 'n_frames' and 'nframes' to 'maxframe'
since that's what they are. I could, of course, have added 1 to the value
instead, but that would have introduced a subtle difference compared to the
original code. Probably not a good idea at this stage.
svn-id: r16417
-rw-r--r-- | saga/animation.cpp | 21 | ||||
-rw-r--r-- | saga/animation.h | 4 |
2 files changed, 11 insertions, 14 deletions
diff --git a/saga/animation.cpp b/saga/animation.cpp index 900325f634..4233d4e7c3 100644 --- a/saga/animation.cpp +++ b/saga/animation.cpp @@ -91,18 +91,18 @@ int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_i MemoryReadStreamEndian headerReadS(anim_resdata, anim_resdata_len, IS_BIG_ENDIAN); readAnimHeader(headerReadS, ah); - new_anim->n_frames = ah.nframes; + new_anim->maxframe = ah.maxframe; new_anim->loopframe = ah.loopframe; if (_vm->_gameType == GType_ITE) { // Cache frame offsets - new_anim->frame_offsets = (size_t *)malloc(new_anim->n_frames * sizeof(*new_anim->frame_offsets)); + new_anim->frame_offsets = (size_t *)malloc((new_anim->maxframe + 1) * sizeof(*new_anim->frame_offsets)); if (new_anim->frame_offsets == NULL) { warning("Anim::load Allocation failure"); return MEM; } - for (i = 0; i < new_anim->n_frames; i++) { + for (i = 0; i <= new_anim->maxframe; i++) { getFrameOffset(anim_resdata, anim_resdata_len, i, &new_anim->frame_offsets[i]); } } else { @@ -113,7 +113,7 @@ int Anim::load(const byte *anim_resdata, size_t anim_resdata_len, uint16 *anim_i // Set animation data new_anim->current_frame = 0; new_anim->completed = 0; - new_anim->cycles = new_anim->n_frames; + new_anim->cycles = new_anim->maxframe; new_anim->frame_time = DEFAULT_FRAME_TIME; new_anim->flags = 0; @@ -233,7 +233,7 @@ int Anim::play(uint16 anim_id, int vector_time, bool playing) { anim->current_frame++; anim->completed++; - if (anim->current_frame >= anim->n_frames) { + if (anim->current_frame > anim->maxframe) { anim->current_frame = anim->loopframe; // FIXME: HACK. probably needs more testing for IHNM @@ -262,7 +262,7 @@ int Anim::play(uint16 anim_id, int vector_time, bool playing) { anim_id = link_anim_id; } else { // No link, stop playing - anim->current_frame = anim->n_frames - 1; + anim->current_frame = anim->maxframe; anim->state = ANIM_PAUSE; if (anim->flags & ANIM_ENDSCENE) { @@ -424,7 +424,7 @@ void Anim::readAnimHeader(MemoryReadStreamEndian &readS, ANIMATION_HEADER &ah) { ah.unknown06 = readS.readByte(); ah.unknown07 = readS.readByte(); - ah.nframes = readS.readByte() - 1; + ah.maxframe = readS.readByte() - 1; ah.loopframe = readS.readByte() - 1; ah.start = readS.readUint16BE(); @@ -836,7 +836,6 @@ int Anim::IHNM_DecodeFrame(byte *decode_buf, size_t decode_buf_len, const byte * int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_frame, size_t *frame_offset_p) { ANIMATION_HEADER ah; - uint16 num_frames; uint16 current_frame; byte mark_byte; @@ -850,9 +849,7 @@ int Anim::getFrameOffset(const byte *resdata, size_t resdata_len, uint16 find_fr readAnimHeader(readS, ah); - num_frames = ah.nframes; - - if (find_frame >= num_frames) { + if (find_frame > ah.maxframe) { return FAILURE; } @@ -954,7 +951,7 @@ void Anim::animInfo() { idx++; } - _vm->_console->DebugPrintf("%02d: Frames: %u Flags: %u\n", i, _anim_tbl[idx]->n_frames, _anim_tbl[idx]->flags); + _vm->_console->DebugPrintf("%02d: Frames: %u Flags: %u\n", i, _anim_tbl[idx]->maxframe, _anim_tbl[idx]->flags); } } diff --git a/saga/animation.h b/saga/animation.h index 3bab6a1182..7e8f691f40 100644 --- a/saga/animation.h +++ b/saga/animation.h @@ -57,7 +57,7 @@ struct ANIMATION_HEADER { byte unknown06; byte unknown07; - byte nframes; + byte maxframe; byte loopframe; uint16 start; @@ -80,7 +80,7 @@ struct ANIMATION { const byte *resdata; size_t resdata_len; - uint16 n_frames; + uint16 maxframe; size_t *frame_offsets; int16 current_frame; uint16 completed; |