Fix crash in set_anim_to_frame()

This commit is contained in:
MysterD 2022-03-04 20:40:57 -08:00
parent 29d9615f7b
commit 15d657a7be
1 changed files with 5 additions and 2 deletions

View File

@ -149,17 +149,20 @@ s16 set_mario_anim_with_accel(struct MarioState *m, s32 targetAnimID, s32 accel)
* Sets the animation to a specific "next" frame from the frame given.
*/
void set_anim_to_frame(struct MarioState *m, s16 animFrame) {
if (m == NULL || m->marioObj == NULL) { return; }
struct AnimInfo *animInfo = &m->marioObj->header.gfx.animInfo;
struct Animation *curAnim = animInfo->curAnim;
if (animInfo == NULL) { return; }
if (animInfo->animAccel) {
if (curAnim->flags & ANIM_FLAG_FORWARD) {
if (curAnim != NULL && curAnim->flags & ANIM_FLAG_FORWARD) {
animInfo->animFrameAccelAssist = (animFrame << 0x10) + animInfo->animAccel;
} else {
animInfo->animFrameAccelAssist = (animFrame << 0x10) - animInfo->animAccel;
}
} else {
if (curAnim->flags & ANIM_FLAG_FORWARD) {
if (curAnim != NULL && curAnim->flags & ANIM_FLAG_FORWARD) {
animInfo->animFrame = animFrame + 1;
} else {
animInfo->animFrame = animFrame - 1;