Merge branch 'shortcut-waypoints-fix' into 'master'

Small waypoint fixes

See merge request KartKrew/Kart!591
This commit is contained in:
James R 2022-05-21 09:13:26 +00:00
commit ef8a8061ed
6 changed files with 45 additions and 25 deletions

View file

@ -4415,6 +4415,8 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_BATTLECAPSULE_SUPPORT", "S_BATTLECAPSULE_SUPPORT",
"S_BATTLECAPSULE_SUPPORTFLY", "S_BATTLECAPSULE_SUPPORTFLY",
"S_WAYPOINTORB",
"S_WAYPOINTSPLAT",
"S_EGOORB", "S_EGOORB",
"S_WATERTRAIL1", "S_WATERTRAIL1",

View file

@ -742,6 +742,7 @@ char sprnames[NUMSPRITES + 1][5] =
"DBOS", // Drift boost flame "DBOS", // Drift boost flame
"WAYP",
"EGOO", "EGOO",
"WTRL", // Water Trail "WTRL", // Water Trail
@ -4996,6 +4997,8 @@ state_t states[NUMSTATES] =
{SPR_CAPS, 4, -1, {NULL}, 0, 0, S_NULL}, // S_BATTLECAPSULE_SUPPORT {SPR_CAPS, 4, -1, {NULL}, 0, 0, S_NULL}, // S_BATTLECAPSULE_SUPPORT
{SPR_CAPS, FF_ANIMATE|5, -1, {NULL}, 3, 1, S_NULL}, // S_BATTLECAPSULE_SUPPORTFLY {SPR_CAPS, FF_ANIMATE|5, -1, {NULL}, 3, 1, S_NULL}, // S_BATTLECAPSULE_SUPPORTFLY
{SPR_WAYP, 0, 1, {NULL}, 0, 0, S_NULL}, // S_WAYPOINTORB
{SPR_WAYP, 1|FF_FLOORSPRITE, 1, {NULL}, 0, 0, S_NULL}, // S_WAYPOINTSPLAT
{SPR_EGOO, 0, 1, {NULL}, 0, 0, S_NULL}, // S_EGOORB {SPR_EGOO, 0, 1, {NULL}, 0, 0, S_NULL}, // S_EGOORB
// Water Trail // Water Trail

View file

@ -1288,6 +1288,7 @@ typedef enum sprite
SPR_DBOS, // Drift boost flame SPR_DBOS, // Drift boost flame
SPR_WAYP,
SPR_EGOO, SPR_EGOO,
SPR_WTRL, // Water Trail SPR_WTRL, // Water Trail
@ -5420,6 +5421,8 @@ typedef enum state
S_BATTLECAPSULE_SUPPORT, S_BATTLECAPSULE_SUPPORT,
S_BATTLECAPSULE_SUPPORTFLY, S_BATTLECAPSULE_SUPPORTFLY,
S_WAYPOINTORB,
S_WAYPOINTSPLAT,
S_EGOORB, S_EGOORB,
S_WATERTRAIL1, S_WATERTRAIL1,

View file

@ -427,7 +427,7 @@ boolean K_PathfindAStar(path_t *const path, pathfindsetup_t *const pathfindsetup
else else
{ {
// skip this node if it isn't traversable // skip this node if it isn't traversable
if (pathfindsetup->gettraversable(checknodedata) == false) if (pathfindsetup->gettraversable(checknodedata, currentnode->nodedata) == false)
{ {
continue; continue;
} }

View file

@ -27,7 +27,7 @@ typedef UINT32*(*getnodeconnectioncostsfunc)(void*);
typedef UINT32(*getnodeheuristicfunc)(void*, void*); typedef UINT32(*getnodeheuristicfunc)(void*, void*);
// function pointer for getting if a node is traversable from its base data // 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 // A pathfindnode contains information about a node from the pathfinding

View file

@ -558,11 +558,9 @@ static void K_DebugWaypointsSpawnLine(waypoint_t *const waypoint1, waypoint_t *c
--------------------------------------------------*/ --------------------------------------------------*/
static void K_DebugWaypointDrawRadius(waypoint_t *const waypoint) static void K_DebugWaypointDrawRadius(waypoint_t *const waypoint)
{ {
const fixed_t spriteRadius = 96*FRACUNIT;
mobj_t *radiusOrb; mobj_t *radiusOrb;
mobj_t *waypointmobj; mobj_t *waypointmobj;
const INT32 numRadiusMobjs = 64;
INT32 i = 0;
angle_t spawnAngle = 0U;
fixed_t spawnX= 0; fixed_t spawnX= 0;
fixed_t spawnY= 0; fixed_t spawnY= 0;
fixed_t spawnZ= 0; fixed_t spawnZ= 0;
@ -572,22 +570,21 @@ static void K_DebugWaypointDrawRadius(waypoint_t *const waypoint)
waypointmobj = waypoint->mobj; waypointmobj = waypoint->mobj;
for (i = 0; i < numRadiusMobjs; i++) spawnX = waypointmobj->x;
{ spawnY = waypointmobj->y;
spawnAngle = (ANGLE_MAX / numRadiusMobjs) * i; spawnZ = waypointmobj->z + 16*mapobjectscale;
spawnZ = waypointmobj->z; radiusOrb = P_SpawnMobj(spawnX, spawnY, spawnZ, MT_SPARK);
spawnX = waypointmobj->x + P_ReturnThrustX(waypointmobj, spawnAngle, waypointmobj->radius);
spawnY = waypointmobj->y + P_ReturnThrustY(waypointmobj, spawnAngle, waypointmobj->radius);
radiusOrb = P_SpawnMobj(spawnX, spawnY, spawnZ, MT_SPARK); P_SetMobjState(radiusOrb, S_WAYPOINTSPLAT);
P_SetMobjState(radiusOrb, S_THOK); radiusOrb->tics = 1;
radiusOrb->tics = 1;
radiusOrb->frame &= ~FF_TRANSMASK; radiusOrb->frame &= ~FF_TRANSMASK;
radiusOrb->frame |= FF_FULLBRIGHT; radiusOrb->frame |= FF_FULLBRIGHT;
radiusOrb->color = SKINCOLOR_PURPLE; radiusOrb->color = SKINCOLOR_PURPLE;
radiusOrb->scale = radiusOrb->scale / 4;
} radiusOrb->destscale = FixedDiv(waypointmobj->radius, spriteRadius);
P_SetScale(radiusOrb, radiusOrb->destscale);
} }
/*-------------------------------------------------- /*--------------------------------------------------
@ -620,10 +617,10 @@ void K_DebugWaypointsVisualise(void)
waypoint = K_SearchWaypointHeapForMobj(waypointmobj); waypoint = K_SearchWaypointHeapForMobj(waypointmobj);
debugmobj = P_SpawnMobj(waypointmobj->x, waypointmobj->y, waypointmobj->z, MT_SPARK); debugmobj = P_SpawnMobj(waypointmobj->x, waypointmobj->y, waypointmobj->z, MT_SPARK);
P_SetMobjState(debugmobj, S_THOK); P_SetMobjState(debugmobj, S_WAYPOINTORB);
debugmobj->frame &= ~FF_TRANSMASK; debugmobj->frame &= ~FF_TRANSMASK;
debugmobj->frame |= FF_TRANS20|FF_FULLBRIGHT; debugmobj->frame |= FF_FULLBRIGHT; //FF_TRANS20
// There's a waypoint setup for this mobj! So draw that it's a valid waypoint and draw lines to its connections // There's a waypoint setup for this mobj! So draw that it's a valid waypoint and draw lines to its connections
if (waypoint != NULL) if (waypoint != NULL)
@ -648,6 +645,11 @@ void K_DebugWaypointsVisualise(void)
else else
{ {
debugmobj->color = SKINCOLOR_BLUE; debugmobj->color = SKINCOLOR_BLUE;
if (K_GetWaypointIsShortcut(waypoint))
{
debugmobj->color = SKINCOLOR_PINK;
}
} }
if (!K_GetWaypointIsEnabled(waypoint)) if (!K_GetWaypointIsEnabled(waypoint))
@ -655,6 +657,11 @@ void K_DebugWaypointsVisualise(void)
debugmobj->color = SKINCOLOR_GREY; debugmobj->color = SKINCOLOR_GREY;
} }
if (!K_GetWaypointIsSpawnpoint(waypoint))
{
debugmobj->frame |= FF_TRANS40;
}
// Valid waypoint, so draw lines of SPARKLES to its next or previous waypoints // Valid waypoint, so draw lines of SPARKLES to its next or previous waypoints
if (cv_kartdebugwaypoints.value == 1) if (cv_kartdebugwaypoints.value == 1)
{ {
@ -975,10 +982,12 @@ static UINT32 K_WaypointPathfindGetHeuristic(void *data1, void *data2)
Return:- Return:-
True if the waypoint is traversable, false otherwise. 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; boolean traversable = false;
(void)prevdata;
if (data == NULL) if (data == NULL)
{ {
CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindTraversableAllEnabled received NULL data.\n"); CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindTraversableAllEnabled received NULL data.\n");
@ -1004,18 +1013,21 @@ static boolean K_WaypointPathfindTraversableAllEnabled(void *data)
Return:- Return:-
True if the waypoint is traversable, false otherwise. 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; boolean traversable = false;
if (data == NULL) if (data == NULL || prevdata == NULL)
{ {
CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindTraversableNoShortcuts received NULL data.\n"); CONS_Debug(DBG_GAMELOGIC, "K_WaypointPathfindTraversableNoShortcuts received NULL data.\n");
} }
else else
{ {
waypoint_t *waypoint = (waypoint_t *)data; 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; return traversable;