From 1ba91ef853ec14d9e5096179831d35d7e6b787c8 Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 5 Mar 2024 04:27:23 -0800 Subject: [PATCH] Respawn: only ignore finish lines when traveling back to first waypoint This fixes lightsnaking through a finish line on sprint maps not giving you a lap. - On circuit maps, lightsnake stops at the finish line waypoint (there's only one finish line) - On sprint maps, there are multiple finish lines but you can't have multiple finish line waypoints, therefore lightsnake goes right through - So we have to make sure the player can cross a finish line while in lightsnake to account for this - Because lightsnake sends you back to the respawn waypoint in a straight line, it may inadvertently cross a finish line and remove a lap - So here's the change: the player should no-clip through the finish line ONLY while traveling back to the first waypoint - Because after that, lightsnake follows the map's waypoints and is intentionally crossing sprint maps' finish lines --- src/p_spec.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/p_spec.c b/src/p_spec.c index ff68cc509..c4ca508ed 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1906,12 +1906,31 @@ void P_SwitchWeather(preciptype_t newWeather) P_SpawnPrecipitation(); } +static boolean K_IgnoreFinishLine(player_t *player) +{ + // Lightsnake travels to the first waypoint in a straight + // line (init). + // This has the potential to inadvertently cross a finish + // line and remove a lap (happened on Hardhat Havoc). + // After the first waypoint, lightsnake follows the + // waypoints in order so it's not an issue there. + if (player->respawn.state == RESPAWNST_MOVE && player->respawn.init == true) + return true; + + // If potential lap cheating has been detected, do not + // interact with the finish line at all. + if (player->bigwaypointgap) + return true; + + return false; +} + // Passed over the finish line forwards static void K_HandleLapIncrement(player_t *player) { if (player) { - if (player->respawn.state == RESPAWNST_MOVE || player->bigwaypointgap) + if (K_IgnoreFinishLine(player)) return; if (!G_TimeAttackStart() && leveltime < starttime && !(gametyperules & GTR_ROLLINGSTART)) { @@ -2184,7 +2203,7 @@ static void K_HandleLapDecrement(player_t *player) { if (player) { - if (player->respawn.state == RESPAWNST_MOVE || player->bigwaypointgap) + if (K_IgnoreFinishLine(player)) return; if ((player->cheatchecknum == 0) && (player->laps > 0)) {