From 5767ae985f1337f4a2cb96d77577704b871e9402 Mon Sep 17 00:00:00 2001 From: defacube <85292886+yoyeet961@users.noreply.github.com> Date: Thu, 16 Nov 2023 04:53:31 +1100 Subject: [PATCH] Fix going OOB sometimes crashing the game (#517) * Fixed going OOB sometimes crashing the game * Avoid nested if statements * Update camera.c --------- Co-authored-by: PeachyPeach <72323920+PeachyPeachSM64@users.noreply.github.com> --- src/game/camera.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/game/camera.c b/src/game/camera.c index b6232b831..eb2a95683 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -7199,15 +7199,13 @@ void find_mario_floor_and_ceil(struct PlayerGeometry *pg) { s16 tempCheckingSurfaceCollisionsForCamera = gCheckingSurfaceCollisionsForCamera; gCheckingSurfaceCollisionsForCamera = TRUE; - if (find_floor(sMarioCamState->pos[0], sMarioCamState->pos[1] + 10.f, - sMarioCamState->pos[2], &surf) != gLevelValues.floorLowerLimit) { + if (find_floor(sMarioCamState->pos[0], sMarioCamState->pos[1] + 10.f, sMarioCamState->pos[2], &surf) != gLevelValues.floorLowerLimit && surf != NULL) { pg->currFloorType = surf->type; } else { pg->currFloorType = 0; } - if (find_ceil(sMarioCamState->pos[0], sMarioCamState->pos[1] - 10.f, - sMarioCamState->pos[2], &surf) != gLevelValues.cellHeightLimit) { + if (find_ceil(sMarioCamState->pos[0], sMarioCamState->pos[1] - 10.f, sMarioCamState->pos[2], &surf) != gLevelValues.cellHeightLimit && surf != NULL) { pg->currCeilType = surf->type; } else { pg->currCeilType = 0;