From 9d4f57ddfbf853c41ff171b44e18934c6fc426f8 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 28 Feb 2024 18:13:01 -0800 Subject: [PATCH] Auto respawn after 35 tics if distancetofinish jumped too much --- src/d_player.h | 1 + src/k_hud.cpp | 5 +++++ src/k_kart.c | 18 ++++++++++++++++++ src/p_saveg.c | 2 ++ 4 files changed, 26 insertions(+) diff --git a/src/d_player.h b/src/d_player.h index e164e1afe..8847b16b4 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -671,6 +671,7 @@ struct player_t mobj_t *ringShooter; // DEZ respawner object tic_t airtime; // Used to track just air time, but has evolved over time into a general "karted" timer. Rename this variable? tic_t lastairtime; + UINT8 bigwaypointgap; // timer counts down if finish line distance gap is too big to update waypoint UINT8 startboost; // (0 to 125) - Boost you get from start of race UINT8 dropdashboost; // Boost you get when holding A while respawning diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 02b14779e..2cb721138 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -5527,6 +5527,11 @@ static void K_DrawWaypointDebugger(void) put("Cheat Check:", "{} / {}", stplyr->cheatchecknum, numcheatchecks); put("Last Safe Cheat Check:", "{}", stplyr->lastsafecheatcheck); } + + if (stplyr->bigwaypointgap) + { + put("Auto Respawn Timer:", "{}", stplyr->bigwaypointgap); + } } static void K_DrawBotDebugger(void) diff --git a/src/k_kart.c b/src/k_kart.c index d770b324c..ab61d7cc5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8709,6 +8709,13 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) K_DoIngameRespawn(player); } + if (player->bigwaypointgap) + { + player->bigwaypointgap--; + if (!player->bigwaypointgap) + K_DoIngameRespawn(player); + } + if (player->tripwireUnstuck && !player->mo->hitlag) player->tripwireUnstuck--; @@ -9874,6 +9881,17 @@ static void K_UpdatePlayerWaypoints(player_t *const player) player->currentwaypoint = old_currentwaypoint; player->nextwaypoint = old_nextwaypoint; K_UpdateDistanceFromFinishLine(player); + + // Start the auto respawn timer when the distance jumps. + if (!player->bigwaypointgap) + { + player->bigwaypointgap = 35; + } + } + else + { + // Reset the auto respawn timer if distance changes are back to normal. + player->bigwaypointgap = 0; } // Respawn point should only be updated when we're going to a nextwaypoint diff --git a/src/p_saveg.c b/src/p_saveg.c index dec635e2e..83ac301ad 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -417,6 +417,7 @@ static void P_NetArchivePlayers(savebuffer_t *save) WRITEUINT32(save->p, K_GetWaypointHeapIndex(players[i].nextwaypoint)); WRITEUINT32(save->p, players[i].airtime); WRITEUINT32(save->p, players[i].lastairtime); + WRITEUINT8(save->p, players[i].bigwaypointgap); WRITEUINT8(save->p, players[i].startboost); WRITEUINT8(save->p, players[i].dropdashboost); @@ -996,6 +997,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save) players[i].nextwaypoint = (waypoint_t *)(size_t)READUINT32(save->p); players[i].airtime = READUINT32(save->p); players[i].lastairtime = READUINT32(save->p); + players[i].bigwaypointgap = READUINT8(save->p); players[i].startboost = READUINT8(save->p); players[i].dropdashboost = READUINT8(save->p);