From 202bd1964c50636cf5a4aa9a7f25457f05b5ad83 Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 5 Mar 2022 14:25:17 -0800 Subject: [PATCH] Revert "Fixed crash in cur_obj_follow_path()" This reverts commit 394d1970c544cd61985c1f6670315f85e2a9ee8e. --- src/game/object_helpers.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index e5c465cf..c5874df2 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -2138,24 +2138,17 @@ s32 cur_obj_follow_path(UNUSED s32 unusedArg) { startWaypoint = o->oPathedStartWaypoint; lastWaypoint = o->oPathedPrevWaypoint; - struct Waypoint *tmpWaypoint = (lastWaypoint + 1); - if (tmpWaypoint != NULL && tmpWaypoint->flags != WAYPOINT_FLAGS_END) { - targetWaypoint = tmpWaypoint; + if ((lastWaypoint + 1)->flags != WAYPOINT_FLAGS_END) { + targetWaypoint = lastWaypoint + 1; } else { targetWaypoint = startWaypoint; } - if (targetWaypoint == NULL) { - return PATH_NONE; - } + o->oPathedPrevWaypointFlags = lastWaypoint->flags | WAYPOINT_FLAGS_INITIALIZED; - if (lastWaypoint != NULL) { - o->oPathedPrevWaypointFlags = lastWaypoint->flags | WAYPOINT_FLAGS_INITIALIZED; - } - - prevToNextX = targetWaypoint->pos[0] - (lastWaypoint != NULL) ? lastWaypoint->pos[0] : 0; - prevToNextY = targetWaypoint->pos[1] - (lastWaypoint != NULL) ? lastWaypoint->pos[1] : 0; - prevToNextZ = targetWaypoint->pos[2] - (lastWaypoint != NULL) ? lastWaypoint->pos[2] : 0; + prevToNextX = targetWaypoint->pos[0] - lastWaypoint->pos[0]; + prevToNextY = targetWaypoint->pos[1] - lastWaypoint->pos[1]; + prevToNextZ = targetWaypoint->pos[2] - lastWaypoint->pos[2]; objToNextX = targetWaypoint->pos[0] - o->oPosX; objToNextY = targetWaypoint->pos[1] - o->oPosY; @@ -2168,8 +2161,7 @@ s32 cur_obj_follow_path(UNUSED s32 unusedArg) { // If dot(prevToNext, objToNext) <= 0 (i.e. reached other side of target waypoint) if (prevToNextX * objToNextX + prevToNextY * objToNextY + prevToNextZ * objToNextZ <= 0.0f) { o->oPathedPrevWaypoint = targetWaypoint; - tmpWaypoint = (targetWaypoint + 1); - if (tmpWaypoint != NULL && tmpWaypoint->flags == WAYPOINT_FLAGS_END) { + if ((targetWaypoint + 1)->flags == WAYPOINT_FLAGS_END) { return PATH_REACHED_END; } else { return PATH_REACHED_WAYPOINT;