anims: fix crash when an anim has no frames

Resolves #2746.
This commit is contained in:
Marcin Kurczewski 2025-04-12 22:53:27 +02:00
parent a12e5f523c
commit 7895617006
2 changed files with 6 additions and 1 deletions

View file

@ -21,7 +21,8 @@
- fixed Lara's holsters being empty if a game flow level removes all weapons but also re-adds the pistols (#2677) - fixed Lara's holsters being empty if a game flow level removes all weapons but also re-adds the pistols (#2677)
- fixed the console opening when remapping its key (#2641) - fixed the console opening when remapping its key (#2641)
- fixed sprites rendering black if no shade value is assigned in the level (#2701, regression from 0.8) - fixed sprites rendering black if no shade value is assigned in the level (#2701, regression from 0.8)
- fixed game crashing if the images were missing - fixed a crash if an image was missing
- fixed a crash on level load if an animation has no frames (#2746, regression from 0.8)
- removed the need to specify in the game flow levels that have no secrets (secrets will be automatically counted) (#1582) - removed the need to specify in the game flow levels that have no secrets (secrets will be automatically counted) (#1582)
- removed the hard-coded end-level behaviour of the bird guardian for custom levels (#1583) - removed the hard-coded end-level behaviour of the bird guardian for custom levels (#1583)

View file

@ -41,6 +41,10 @@ static int32_t M_GetAnimFrameCount(
uint32_t next_ofs = anim_idx == Anim_GetTotalCount() - 1 uint32_t next_ofs = anim_idx == Anim_GetTotalCount() - 1
? (unsigned)(sizeof(int16_t) * frame_data_length) ? (unsigned)(sizeof(int16_t) * frame_data_length)
: Anim_GetAnim(anim_idx + 1)->frame_ofs; : Anim_GetAnim(anim_idx + 1)->frame_ofs;
if (anim->frame_size == 0) {
ASSERT(next_ofs - anim->frame_ofs == 0);
return 0;
}
return (next_ofs - anim->frame_ofs) return (next_ofs - anim->frame_ofs)
/ (int32_t)(sizeof(int16_t) * anim->frame_size); / (int32_t)(sizeof(int16_t) * anim->frame_size);
#endif #endif