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>
This commit is contained in:
defacube 2023-11-16 04:53:31 +11:00 committed by Agent X
parent 1cb69df30f
commit 5767ae985f

View file

@ -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;