mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-21 19:45:10 +00:00
Better fix for crash in cur_obj_follow_path()
This commit is contained in:
parent
202bd1964c
commit
369a7cd7e5
1 changed files with 10 additions and 3 deletions
|
@ -2138,8 +2138,13 @@ s32 cur_obj_follow_path(UNUSED s32 unusedArg) {
|
|||
startWaypoint = o->oPathedStartWaypoint;
|
||||
lastWaypoint = o->oPathedPrevWaypoint;
|
||||
|
||||
if ((lastWaypoint + 1)->flags != WAYPOINT_FLAGS_END) {
|
||||
targetWaypoint = lastWaypoint + 1;
|
||||
// sanity check waypoints
|
||||
if (lastWaypoint == NULL) { lastWaypoint = startWaypoint; }
|
||||
struct Waypoint* tmpWaypoint = (lastWaypoint + 1);
|
||||
if (tmpWaypoint == NULL) { tmpWaypoint = lastWaypoint; }
|
||||
|
||||
if (tmpWaypoint->flags != WAYPOINT_FLAGS_END) {
|
||||
targetWaypoint = tmpWaypoint;
|
||||
} else {
|
||||
targetWaypoint = startWaypoint;
|
||||
}
|
||||
|
@ -2161,7 +2166,9 @@ 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;
|
||||
if ((targetWaypoint + 1)->flags == WAYPOINT_FLAGS_END) {
|
||||
struct Waypoint* tmpWaypoint2 = (targetWaypoint + 1);
|
||||
if (tmpWaypoint2 == NULL) { tmpWaypoint2 = targetWaypoint; }
|
||||
if (tmpWaypoint2->flags == WAYPOINT_FLAGS_END) {
|
||||
return PATH_REACHED_END;
|
||||
} else {
|
||||
return PATH_REACHED_WAYPOINT;
|
||||
|
|
Loading…
Reference in a new issue