From 1919471ae450d82566fb203b81f44f165a54137f Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 23 Feb 2024 22:44:35 -0800 Subject: [PATCH 1/3] Update waypoints on same tic as crossing finish line Fix 1 tic delay between crossing finish line and next waypoint updating. May influence respawn behavior. --- src/p_spec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index 2ad07f581..89733f6fa 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1954,7 +1954,9 @@ static void K_HandleLapIncrement(player_t *player) nump++; } + player->cheatchecknum = 0; player->laps++; + K_UpdateAllPlayerPositions(); if (G_TimeAttackStart() && !linecrossed) { @@ -1987,8 +1989,6 @@ static void K_HandleLapIncrement(player_t *player) if (netgame && player->laps > numlaps) CON_LogMessage(va(M_GetText("%s has finished the race.\n"), player_names[player-players])); - player->cheatchecknum = 0; - if (gametyperules & GTR_SPECIALSTART) { if (player->laps > numlaps) @@ -2182,6 +2182,7 @@ static void K_HandleLapDecrement(player_t *player) { player->cheatchecknum = numcheatchecks; player->laps--; + K_UpdateAllPlayerPositions(); curlap = UINT32_MAX; } } From a03cc5489c1abe76dfb485640b92a7f0482f3461 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 23 Feb 2024 22:46:18 -0800 Subject: [PATCH 2/3] Respawn: move lastsafelap check to K_UpdateDistanceFromFinishLine - Order of operations; it is possible in specific circumstances to respawn (K_DoIngameRespawn) before the lap increments - In this case, the lap would be reset to lastsafelap and then incremented afterward - This would allow someone to skip the first lap - It was possible to do this in many maps where the finish line intersects a respawn line, by driving into the corner where the lines meet --- src/k_kart.c | 8 ++++++++ src/k_respawn.c | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index d26eca203..269cab338 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9669,6 +9669,14 @@ void K_UpdateDistanceFromFinishLine(player_t *const player) waypoint_t *finishline = K_GetFinishLineWaypoint(); waypoint_t *nextwaypoint = NULL; + if (player->respawn.state == RESPAWNST_MOVE && + player->respawn.init == true && + player->lastsafelap < player->laps) + { + player->laps = player->lastsafelap; + player->cheatchecknum = player->lastsafecheatcheck; + } + if (player->spectator) { // Don't update waypoints while spectating diff --git a/src/k_respawn.c b/src/k_respawn.c index 058052d8e..3fd1283ca 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -318,12 +318,6 @@ void K_DoIngameRespawn(player_t *player) player->respawn.fast = true; player->respawn.returnspeed = 0; - if (player->lastsafelap < player->laps) - { - player->laps = player->lastsafelap; - player->cheatchecknum = player->lastsafecheatcheck; - } - player->respawn.airtimer = player->airtime; player->respawn.truedeath = !!(player->pflags & PF_FAULT); From 0dd359ba5a957c31d75e7bea98cef132b554a3d7 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 23 Feb 2024 22:54:32 -0800 Subject: [PATCH 3/3] Respawn: don't let Ring Shooter send you behind the finish line Because lap decrement does not happen when respawning, this would you skip a lap. --- src/k_respawn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k_respawn.c b/src/k_respawn.c index 3fd1283ca..cf8b92965 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -178,8 +178,10 @@ void K_DoIngameRespawn(player_t *player) { if (player->respawn.fromRingShooter == true) { + waypoint_t *finishline = K_GetFinishLineWaypoint(); waypoint_t *prevWP = player->respawn.wp; - while (prevWP->numprevwaypoints > 0) + // Laps don't decrement while respawning, so don't cross behind the finish line + while (prevWP->numprevwaypoints > 0 && prevWP != finishline) { prevWP = prevWP->prevwaypoints[0]; if (K_GetWaypointIsSpawnpoint(prevWP) == true)