diff --git a/src/k_pathfind.c b/src/k_pathfind.c index eb91dda2b..857f0343a 100644 --- a/src/k_pathfind.c +++ b/src/k_pathfind.c @@ -427,7 +427,7 @@ boolean K_PathfindAStar(path_t *const path, pathfindsetup_t *const pathfindsetup else { // skip this node if it isn't traversable - if (pathfindsetup->gettraversable(checknodedata) == false) + if (pathfindsetup->gettraversable(checknodedata, currentnode->nodedata) == false) { continue; } diff --git a/src/k_pathfind.h b/src/k_pathfind.h index ba0e38f47..7b7f1475f 100644 --- a/src/k_pathfind.h +++ b/src/k_pathfind.h @@ -27,7 +27,7 @@ typedef UINT32*(*getnodeconnectioncostsfunc)(void*); typedef UINT32(*getnodeheuristicfunc)(void*, void*); // function pointer for getting if a node is traversable from its base data -typedef boolean(*getnodetraversablefunc)(void*); +typedef boolean(*getnodetraversablefunc)(void*, void*); // A pathfindnode contains information about a node from the pathfinding diff --git a/src/k_waypoint.c b/src/k_waypoint.c index 903e66e2a..ec50a96be 100644 --- a/src/k_waypoint.c +++ b/src/k_waypoint.c @@ -975,10 +975,12 @@ static UINT32 K_WaypointPathfindGetHeuristic(void *data1, void *data2) Return:- True if the waypoint is traversable, false otherwise. --------------------------------------------------*/ -static boolean K_WaypointPathfindTraversableAllEnabled(void *data) +static boolean K_WaypointPathfindTraversableAllEnabled(void *data, void *prevdata) { boolean traversable = false; + (void)prevdata; + if (data == NULL) { CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindTraversableAllEnabled received NULL data.\n"); @@ -1004,18 +1006,21 @@ static boolean K_WaypointPathfindTraversableAllEnabled(void *data) Return:- True if the waypoint is traversable, false otherwise. --------------------------------------------------*/ -static boolean K_WaypointPathfindTraversableNoShortcuts(void *data) +static boolean K_WaypointPathfindTraversableNoShortcuts(void *data, void *prevdata) { boolean traversable = false; - if (data == NULL) + if (data == NULL || prevdata == NULL) { CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindTraversableNoShortcuts received NULL data.\n"); } else { waypoint_t *waypoint = (waypoint_t *)data; - traversable = ((K_GetWaypointIsShortcut(waypoint) == false) && (K_GetWaypointIsEnabled(waypoint) == true)); + waypoint_t *prevWaypoint = (waypoint_t *)prevdata; + + traversable = ((K_GetWaypointIsEnabled(waypoint) == true) + && (K_GetWaypointIsShortcut(waypoint) == false || K_GetWaypointIsShortcut(prevWaypoint) == true)); // Allow shortcuts to be used if the starting waypoint is already a shortcut. } return traversable;