From a03cc5489c1abe76dfb485640b92a7f0482f3461 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 23 Feb 2024 22:46:18 -0800 Subject: [PATCH] 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);