From bbc53964aed49b232888077689db4072c31bed57 Mon Sep 17 00:00:00 2001 From: Alug Date: Thu, 2 Jul 2026 19:42:58 +0200 Subject: [PATCH] hack for kartdebugcheckpoint display see comment --- src/k_hud.c | 6 ++++- src/k_kart.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/k_kart.h | 2 ++ 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index e378e55f1..d4d3fa3ee 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4583,7 +4583,11 @@ static void K_drawCheckpointDebugger(void) else V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Skip: %d)", stplyr->starpostnum, numstarposts, ((numstarposts/2) + stplyr->starpostnum))); - V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); + // really gnarly hack + const INT32 prevcheck = (stprevnextchecks[0] != INT32_MAX) ? stprevnextchecks[0]: stplyr->kartstuff[k_prevcheck]; + const INT32 nextcheck = (stprevnextchecks[1] != INT32_MAX) ? stprevnextchecks[1]: stplyr->kartstuff[k_nextcheck]; + + V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", prevcheck, nextcheck)); } // determines if gametype info (laps/bumpers) should be hidden diff --git a/src/k_kart.c b/src/k_kart.c index 98f5004db..6a9ab79ea 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6294,6 +6294,64 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_brakedrift] = 0; } +INT32 stprevnextchecks[2] = {INT32_MAX, INT32_MAX}; // there wont be any map this big, wont there?..... + +// K_KartUpdatePosition has a bug where whatever player comes last in the players array +// gets its distance calculations applied twice +// since we cannot fix this due to compat concerns (kartstuff is exposed after all) +// we gotta do this shit hack to atleast fix the debugcheckpoint display +static void K_KartUpdatePositionDebugHack(player_t *player, player_t *otherplayer) +{ + mobj_t *mo; + fixed_t pmo; + fixed_t ppcd, pncd; + + // dont need this crap + if (!cv_kartdebugcheckpoint.value) + return; + + // not checking against ourselves + if (player != otherplayer) + return; + + // dont care if its not first displayplayer + // since this is only used for the debug display + if (player != &players[displayplayers[0]]) + return; + + ppcd = pncd = 0; + stprevnextchecks[0] = stprevnextchecks[1] = 0; + + // This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now) + for (mo = waypointcap; mo != NULL; mo = mo->tracer) + { + const boolean isprevcheckpointp = mo->health == player->starpostnum; + const boolean isnextcheckpointp = mo->health == (player->starpostnum + 1); + + if ((isprevcheckpointp || isnextcheckpointp) && (!mo->movecount || mo->movecount == player->laps+1)) + { + pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x, + mo->y - player->mo->y), + mo->z - player->mo->z) / FRACUNIT; + + if (isprevcheckpointp) + { + stprevnextchecks[0] += pmo; + ppcd++; + } + + if (isnextcheckpointp) + { + stprevnextchecks[1] += pmo; + pncd++; + } + } + } + + if (ppcd > 1) stprevnextchecks[0] /= ppcd; + if (pncd > 1) stprevnextchecks[1] /= pncd; +} + // // K_KartUpdatePosition // @@ -6305,6 +6363,9 @@ void K_KartUpdatePosition(player_t *player) fixed_t pmo, imo; mobj_t *mo; + // always reset this + stprevnextchecks[0] = stprevnextchecks[1] = INT32_MAX; + if (player->spectator || !player->mo) return; @@ -6405,6 +6466,9 @@ void K_KartUpdatePosition(player_t *player) if (players[i].starposttime < player->starposttime) position++; } + + // stupid hack + K_KartUpdatePositionDebugHack(player, &players[i]); } } else if (G_BattleGametype()) diff --git a/src/k_kart.h b/src/k_kart.h index cfe98fe29..ba8bc84b8 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -33,6 +33,8 @@ extern consvar_t cv_bananajitter; extern consvar_t cv_bananthrowroll; extern consvar_t cv_airsparks; +extern INT32 stprevnextchecks[2]; + boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush);