From 7867949c0e28cc2963a6f0fa8085f7630eecc529 Mon Sep 17 00:00:00 2001 From: MysterD Date: Wed, 8 Nov 2023 12:54:41 -0800 Subject: [PATCH] Fixed crash in act_dile() --- src/game/mario_actions_stationary.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/game/mario_actions_stationary.c b/src/game/mario_actions_stationary.c index 773c8d74..9004af1e 100644 --- a/src/game/mario_actions_stationary.c +++ b/src/game/mario_actions_stationary.c @@ -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); }