mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +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;
|
startWaypoint = o->oPathedStartWaypoint;
|
||||||
lastWaypoint = o->oPathedPrevWaypoint;
|
lastWaypoint = o->oPathedPrevWaypoint;
|
||||||
|
|
||||||
if ((lastWaypoint + 1)->flags != WAYPOINT_FLAGS_END) {
|
// sanity check waypoints
|
||||||
targetWaypoint = lastWaypoint + 1;
|
if (lastWaypoint == NULL) { lastWaypoint = startWaypoint; }
|
||||||
|
struct Waypoint* tmpWaypoint = (lastWaypoint + 1);
|
||||||
|
if (tmpWaypoint == NULL) { tmpWaypoint = lastWaypoint; }
|
||||||
|
|
||||||
|
if (tmpWaypoint->flags != WAYPOINT_FLAGS_END) {
|
||||||
|
targetWaypoint = tmpWaypoint;
|
||||||
} else {
|
} else {
|
||||||
targetWaypoint = startWaypoint;
|
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 dot(prevToNext, objToNext) <= 0 (i.e. reached other side of target waypoint)
|
||||||
if (prevToNextX * objToNextX + prevToNextY * objToNextY + prevToNextZ * objToNextZ <= 0.0f) {
|
if (prevToNextX * objToNextX + prevToNextY * objToNextY + prevToNextZ * objToNextZ <= 0.0f) {
|
||||||
o->oPathedPrevWaypoint = targetWaypoint;
|
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;
|
return PATH_REACHED_END;
|
||||||
} else {
|
} else {
|
||||||
return PATH_REACHED_WAYPOINT;
|
return PATH_REACHED_WAYPOINT;
|
||||||
|
|
Loading…
Reference in a new issue