From 3fd8d74dc1ac502fa297fe454785470eeb36ccdb Mon Sep 17 00:00:00 2001 From: MysterD Date: Mon, 10 Apr 2023 17:41:51 -0700 Subject: [PATCH] Fixed crash in cur_obj_follow_path --- src/game/object_helpers.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 3cc94e649..49084d1d9 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -2282,6 +2282,8 @@ s32 cur_obj_follow_path(UNUSED s32 unusedArg) { f32 objToNextXZ; f32 objToNextX, objToNextY, objToNextZ; + if (o == NULL) { return PATH_NONE; } + if (o->oPathedPrevWaypointFlags == 0) { o->oPathedPrevWaypoint = o->oPathedStartWaypoint; o->oPathedPrevWaypointFlags = WAYPOINT_FLAGS_INITIALIZED; @@ -2295,12 +2297,15 @@ s32 cur_obj_follow_path(UNUSED s32 unusedArg) { struct Waypoint* tmpWaypoint = (lastWaypoint + 1); if (tmpWaypoint == NULL) { tmpWaypoint = lastWaypoint; } - if (tmpWaypoint->flags != WAYPOINT_FLAGS_END) { + if (tmpWaypoint && tmpWaypoint->flags != WAYPOINT_FLAGS_END) { targetWaypoint = tmpWaypoint; } else { targetWaypoint = startWaypoint; } + if (lastWaypoint == NULL) { return PATH_NONE; } + if (targetWaypoint == NULL) { return PATH_NONE; } + o->oPathedPrevWaypointFlags = lastWaypoint->flags | WAYPOINT_FLAGS_INITIALIZED; prevToNextX = targetWaypoint->pos[0] - lastWaypoint->pos[0]; @@ -2320,7 +2325,7 @@ s32 cur_obj_follow_path(UNUSED s32 unusedArg) { o->oPathedPrevWaypoint = targetWaypoint; struct Waypoint* tmpWaypoint2 = (targetWaypoint + 1); if (tmpWaypoint2 == NULL) { tmpWaypoint2 = targetWaypoint; } - if (tmpWaypoint2->flags == WAYPOINT_FLAGS_END) { + if (tmpWaypoint2 && tmpWaypoint2->flags == WAYPOINT_FLAGS_END) { return PATH_REACHED_END; } else { return PATH_REACHED_WAYPOINT;