From 144b93f262a13cad0e60d259bcd9f04f0fa7cfa0 Mon Sep 17 00:00:00 2001 From: GenericHeroGuy Date: Sat, 3 May 2025 22:41:09 +0200 Subject: [PATCH] Misc waypoint fixes, make bogus finish line waypoints work --- src/k_kart.c | 8 +++++++- src/k_waypoint.cpp | 4 ++-- src/p_spec.c | 6 ++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f1381a410..2e92d3741 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8382,6 +8382,11 @@ static boolean K_SetPlayerNextWaypoint(player_t *player) if (bestwaypoint != NULL) { player->currentwaypoint = bestwaypoint; + + // if currentwaypoint is the finish line, don't set nextwaypoint to it! + // fixes bigwaypointgap triggering if we're facing the back of the finish line + if (bestwaypoint == finishline) + bestwaypoint = NULL; } // check the waypoint's location in relation to the player @@ -8499,7 +8504,8 @@ static boolean K_SetPlayerNextWaypoint(player_t *player) } if ((waypoint->prevwaypoints != NULL) && (waypoint->numprevwaypoints > 0U) - && !(K_PlayerUsesBotMovement(player))) // Bots do not need prev waypoints + && !(K_PlayerUsesBotMovement(player)) // Bots do not need prev waypoints + && waypoint != finishline) // do not check finish line's prevwaypoints { for (i = 0U; i < waypoint->numprevwaypoints; i++) { diff --git a/src/k_waypoint.cpp b/src/k_waypoint.cpp index b30b913e7..cefdb0b4b 100644 --- a/src/k_waypoint.cpp +++ b/src/k_waypoint.cpp @@ -2179,14 +2179,14 @@ static waypoint_t *K_SetupWaypoint(mobj_t *const mobj) firstwaypoint = thiswaypoint; } - if (K_GetWaypointIsFinishline(thiswaypoint)) + if (K_GetWaypointIsFinishline(thiswaypoint) && K_GetWaypointIsEnabled(thiswaypoint)) { if (finishline != NULL) { const INT32 oldfinishlineid = K_GetWaypointID(finishline); const INT32 thiswaypointid = K_GetWaypointID(thiswaypoint); CONS_Alert( - CONS_WARNING, "Multiple finish line waypoints with IDs %d and %d! Using %d.", + CONS_WARNING, "Multiple finish line waypoints with IDs %d and %d! Using %d.\n", oldfinishlineid, thiswaypointid, thiswaypointid); } finishline = thiswaypoint; diff --git a/src/p_spec.c b/src/p_spec.c index 8616dc5f2..6063a5969 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2051,7 +2051,7 @@ static void K_HandleLapIncrement(player_t *player) player->karthud[khud_lapanimation] = 80; } - if (netgame && player->laps >= numlaps) + if (netgame && player->laps > numlaps) CON_LogMessage(va(M_GetText("%s has finished the race.\n"), player_names[player-players])); if (P_IsDisplayPlayer(player)) @@ -2135,7 +2135,9 @@ static void K_HandleLapDecrement(player_t *player) { if (player) { - if ((player->starpostnum == 0) && (player->laps > 0)) + if (K_IgnoreFinishLine(player)) + return; + if (player->laps > 0) { player->starpostnum = numstarposts; player->laps--;