mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-17 11:06:30 +00:00
Allow pathfind traversal thru shortcuts when starting from one
Fixes shortcut pathfinding behavior when the entire shortcut's waypoints have the flag instead of only the entrance.
This commit is contained in:
parent
1835605619
commit
69aa74b9bf
3 changed files with 11 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue