diff --git a/source/games/blood/src/qav.cpp b/source/games/blood/src/qav.cpp index 5d7adf60f..2709deea5 100644 --- a/source/games/blood/src/qav.cpp +++ b/source/games/blood/src/qav.cpp @@ -76,21 +76,10 @@ void QAV::Draw(double x, double y, int ticks, int stat, int shade, int palnum, b { assert(ticksPerFrame > 0); - int nFrame = ticks / ticksPerFrame; - assert(nFrame >= 0 && nFrame < nFrames); + auto const nFrame = clamp(ticks / ticksPerFrame, 0, nFrames - 1); FRAMEINFO *thisFrame = &frames[nFrame]; - if ((nFrame == (nFrames - 1)) && !lastframetic) - { - lastframetic = ticks; - } - else if (lastframetic > ticks) - { - lastframetic = 0; - } - - int oFrame = nFrame == 0 || (lastframetic && ticks > lastframetic) ? !looped ? nFrame : nFrames - 1 : nFrame - 1; - assert(oFrame >= 0 && oFrame < nFrames); + auto const oFrame = clamp((nFrame == 0 && looped ? nFrames : nFrame) - 1, 0, nFrames - 1); FRAMEINFO *prevFrame = &frames[oFrame]; auto drawTile = [&](TILE_FRAME *thisTile, TILE_FRAME *prevTile, bool const interpolate = true) diff --git a/source/games/blood/src/qav.h b/source/games/blood/src/qav.h index 0571056d6..71f987524 100644 --- a/source/games/blood/src/qav.h +++ b/source/games/blood/src/qav.h @@ -75,8 +75,7 @@ struct QAV int y; // 18 int nSprite; // 1c //SPRITE *pSprite; // 1c - char pad3[1]; // 20 - char lastframetic; + char pad3[2]; // 20 unsigned short res_id; FRAMEINFO frames[1]; // 24 void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool to3dview, double const smoothratio = 65536, bool const looped = false);