From 69ed0994905166144ecef59e7d76ccf6a40ce368 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 29 Feb 2024 18:26:23 -0800 Subject: [PATCH 1/2] Symmetrical safelap behavior - Do not increment lap during lightsnake - Symmetrical with decrement behavior - Let lap be restored to higher safelap - Prevent headaches if lap is erroneously decremented --- src/k_kart.c | 2 +- src/p_spec.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0444d3c11..e65e68945 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -10858,7 +10858,7 @@ void K_UpdateAllPlayerPositions(void) if (player->respawn.state == RESPAWNST_MOVE && player->respawn.init == true && - player->lastsafelap < player->laps) + player->lastsafelap != player->laps) { player->laps = player->lastsafelap; player->cheatchecknum = player->lastsafecheatcheck; diff --git a/src/p_spec.c b/src/p_spec.c index 41b0f4841..0eae90798 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1911,6 +1911,8 @@ static void K_HandleLapIncrement(player_t *player) { if (player) { + if (player->respawn.state == RESPAWNST_MOVE) + return; if (!G_TimeAttackStart() && leveltime < starttime && !(gametyperules & GTR_ROLLINGSTART)) { // freeze 'em until fault penalty is over From 664244990830afcf0c836726a15423cdb243c9df Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 29 Feb 2024 18:29:47 -0800 Subject: [PATCH 2/2] Improve finish line distance big jump prevention - Freeze finish line distance (instead of recalculating it from old nextwaypoint) - Reset auto respawn timer right before it runs out (instead of AS SOON as finish line distance returns to normal) - Do not ever update respawn waypoint while auto respawn timer is ticking - Do not interact with finish line while auto respawn timer is ticking --- src/k_kart.c | 13 +++++++++---- src/p_spec.c | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e65e68945..36ae478ce 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9884,16 +9884,17 @@ static void K_UpdatePlayerWaypoints(player_t *const player) K_UpdateDistanceFromFinishLine(player); // Respawning should be a full reset. + // So should touching the first waypoint ever. UINT32 delta = u32_delta(player->distancetofinish, player->distancetofinishprev); - if (player->respawn.state == RESPAWNST_NONE && delta > distance_threshold) + if (player->respawn.state == RESPAWNST_NONE && delta > distance_threshold && old_currentwaypoint != NULL) { CONS_Debug(DBG_GAMELOGIC, "Player %s: waypoint ID %d too far away (%u > %u)\n", sizeu1(player - players), K_GetWaypointID(player->nextwaypoint), delta, distance_threshold); - // Distance jump is too great, keep the old waypoints and recalculate distance. + // Distance jump is too great, keep the old waypoints and old distance. player->currentwaypoint = old_currentwaypoint; player->nextwaypoint = old_nextwaypoint; - K_UpdateDistanceFromFinishLine(player); + player->distancetofinish = player->distancetofinishprev; // Start the auto respawn timer when the distance jumps. if (!player->bigwaypointgap) @@ -9904,11 +9905,15 @@ static void K_UpdatePlayerWaypoints(player_t *const player) else { // Reset the auto respawn timer if distance changes are back to normal. - player->bigwaypointgap = 0; + if (player->bigwaypointgap == 1) + { + player->bigwaypointgap = 0; + } } // Respawn point should only be updated when we're going to a nextwaypoint if ((updaterespawn) && + (player->bigwaypointgap == 0) && (player->respawn.state == RESPAWNST_NONE) && (player->nextwaypoint != old_nextwaypoint) && (K_GetWaypointIsSpawnpoint(player->nextwaypoint)) && diff --git a/src/p_spec.c b/src/p_spec.c index 0eae90798..ff68cc509 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1911,7 +1911,7 @@ static void K_HandleLapIncrement(player_t *player) { if (player) { - if (player->respawn.state == RESPAWNST_MOVE) + if (player->respawn.state == RESPAWNST_MOVE || player->bigwaypointgap) return; if (!G_TimeAttackStart() && leveltime < starttime && !(gametyperules & GTR_ROLLINGSTART)) { @@ -2184,7 +2184,7 @@ static void K_HandleLapDecrement(player_t *player) { if (player) { - if (player->respawn.state == RESPAWNST_MOVE) + if (player->respawn.state == RESPAWNST_MOVE || player->bigwaypointgap) return; if ((player->cheatchecknum == 0) && (player->laps > 0)) {