Fixed crash in act_dile()

This commit is contained in:
MysterD 2023-11-08 12:54:41 -08:00
parent c27ed37c7e
commit 7867949c0e
1 changed files with 3 additions and 2 deletions

View File

@ -129,7 +129,7 @@ s32 act_idle(struct MarioState *m) {
extern bool gDjuiInMainMenu;
if (m->actionState == 3) {
if ((m->area->terrainType & TERRAIN_MASK) == TERRAIN_SNOW) {
if (m->area && ((m->area->terrainType & TERRAIN_MASK) == TERRAIN_SNOW)) {
return set_mario_action(m, ACT_SHIVERING, 0);
} else {
if (!gDjuiInMainMenu) {
@ -168,7 +168,7 @@ s32 act_idle(struct MarioState *m) {
// actionTimer is used to track how many cycles have passed.
if (++m->actionState == 3) {
f32 deltaYOfFloorBehindMario = m->pos[1] - find_floor_height_relative_polar(m, -0x8000, 60.0f);
if (deltaYOfFloorBehindMario < -24.0f || 24.0f < deltaYOfFloorBehindMario || m->floor->flags & SURFACE_FLAG_DYNAMIC) {
if (deltaYOfFloorBehindMario < -24.0f || 24.0f < deltaYOfFloorBehindMario || (m->floor && (m->floor->flags & SURFACE_FLAG_DYNAMIC)) {
m->actionState = 0;
} else {
// If Mario hasn't turned his head 10 times yet, stay idle instead of going to sleep.
@ -188,6 +188,7 @@ s32 act_idle(struct MarioState *m) {
void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound) {
if (!m) { return; }
if (!m->marioObj) { return; }
if (m->actionState == actionState && m->marioObj->header.gfx.animInfo.animFrame == animFrame) {
play_sound(sound, m->marioObj->header.gfx.cameraToObject);
}