Skip to content

Commit

Permalink
Fix curiosity shop crash (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
NEstelami authored May 1, 2024
1 parent 8504a49 commit cfaff99
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions mm/src/code/z_sub_s.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,14 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animationI
s32 startFrame;

animationInfo += animIndex;
AnimationHeader* anim = animationInfo->animation;

if (ResourceMgr_OTRSigCheck(anim))
anim = ResourceMgr_LoadAnimByName(anim);

endFrame = animationInfo->frameCount;
if (animationInfo->frameCount < 0) {
endFrame = Animation_GetLastFrame(&animationInfo->animation->common);
endFrame = Animation_GetLastFrame(&anim->common);
}
startFrame = animationInfo->startFrame;
if (startFrame >= endFrame || startFrame < 0) {
Expand All @@ -547,7 +552,7 @@ s32 SubS_ChangeAnimationByInfoS(SkelAnime* skelAnime, AnimationInfoS* animationI
if (animationInfo->playSpeed < 0.0f) {
SWAP(s32, endFrame, startFrame);
}
Animation_Change(skelAnime, animationInfo->animation, animationInfo->playSpeed, startFrame, endFrame,
Animation_Change(skelAnime, anim, animationInfo->playSpeed, startFrame, endFrame,
animationInfo->mode, animationInfo->morphFrames);
return true;
}
Expand Down Expand Up @@ -1383,6 +1388,11 @@ void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* a
f32 endFrame;
f32 morphFrames;

AnimationHeader* anim = animation->animation;

if (ResourceMgr_OTRSigCheck(anim))
anim = ResourceMgr_LoadAnimByName(anim);

if ((*curAnimIndex < 0) || (nextAnimIndex == *curAnimIndex)) {
morphFrames = 0.0f;
if (*curAnimIndex < 0) {
Expand All @@ -1395,12 +1405,12 @@ void SubS_ChangeAnimationBySpeedInfo(SkelAnime* skelAnime, AnimationSpeedInfo* a
}
}
if (animation->playSpeed >= 0.0f) {
endFrame = Animation_GetLastFrame(&animation->animation->common);
endFrame = Animation_GetLastFrame(&anim->common);
} else {
startFrame = Animation_GetLastFrame(&animation->animation->common);
startFrame = Animation_GetLastFrame(&anim->common);
endFrame = 0.0f;
}
Animation_Change(skelAnime, animation->animation, animation->playSpeed, startFrame, endFrame, animation->mode,
Animation_Change(skelAnime, anim, animation->playSpeed, startFrame, endFrame, animation->mode,
morphFrames);
*curAnimIndex = nextAnimIndex;
}
Expand Down

0 comments on commit cfaff99

Please sign in to comment.