From 7877966f03fbc9b89904095a5d354d23a7cdba16 Mon Sep 17 00:00:00 2001 From: fig02 Date: Mon, 24 Jan 2022 18:55:34 -0500 Subject: [PATCH] fix function (#1118) --- .../actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c | 33 +++++-------------- 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 8377723718..55a519643e 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -338,33 +338,18 @@ void ObjOshihiki_SetFloors(ObjOshihiki* this, GlobalContext* globalCtx) { } s16 ObjOshihiki_GetHighestFloor(ObjOshihiki* this) { + s32 i; s16 highestFloor = 0; - s16 temp = 1; - f32 phi_f0 = this->floorHeights[temp]; - if (phi_f0 > this->floorHeights[highestFloor]) { - highestFloor = temp; - } else if ((this->floorBgIds[temp] == BGCHECK_SCENE) && ((phi_f0 - this->floorHeights[highestFloor]) > -0.001f)) { - highestFloor = temp; - } - if (this->floorHeights[temp + 1] > this->floorHeights[highestFloor]) { - highestFloor = temp + 1; - } else if ((this->floorBgIds[temp + 1] == BGCHECK_SCENE) && - ((this->floorHeights[temp + 1] - this->floorHeights[highestFloor]) > -0.001f)) { - highestFloor = temp + 1; - } - if (this->floorHeights[temp + 2] > this->floorHeights[highestFloor]) { - highestFloor = temp + 2; - } else if ((this->floorBgIds[temp + 2] == BGCHECK_SCENE) && - ((this->floorHeights[temp + 2] - this->floorHeights[highestFloor]) > -0.001f)) { - highestFloor = temp + 2; - } - if (this->floorHeights[temp + 3] > this->floorHeights[highestFloor]) { - highestFloor = temp + 3; - } else if ((this->floorBgIds[temp + 3] == BGCHECK_SCENE) && - ((this->floorHeights[temp + 3] - this->floorHeights[highestFloor]) > -0.001f)) { - highestFloor = temp + 3; + for (i = 1; i < ARRAY_COUNT(this->floorHeights); i++) { + if (this->floorHeights[i] > this->floorHeights[highestFloor]) { + highestFloor = i; + } else if ((this->floorBgIds[i] == BGCHECK_SCENE) && + ((this->floorHeights[i] - this->floorHeights[highestFloor]) > -0.001f)) { + highestFloor = i; + } } + return highestFloor; }