diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 225c748b1..6dcff1430 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -3116,17 +3116,19 @@ static void K_drawKartTeamScores(void) } } -static void K_drawKartLaps(void) +static boolean K_drawKartLaps(void) { INT32 splitflags = V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_SPLITSCREEN; INT32 bump = 0; boolean drewsticker = false; + UINT16 displayEXP = K_GetDisplayEXP(stplyr); + // Jesus Christ. // I do not understand the way this system of offsets is laid out at all, // so it's probably going to be pretty bad to maintain. Sorry. - if (numlaps != 1) + if (numlaps != 1 && displayEXP != UINT16_MAX) { if (r_splitscreen > 1) bump = 27; @@ -3196,10 +3198,12 @@ static void K_drawKartLaps(void) } } - UINT16 displayEXP = std::clamp(FixedMul(std::max(stplyr->exp, FRACUNIT/2), (500/K_GetNumGradingPoints())*stplyr->gradingpointnum), 0, 999); - // EXP - if (r_splitscreen > 1) + if (displayEXP == UINT16_MAX) + { + ; + } + else if (r_splitscreen > 1) { INT32 fx = 0, fy = 0, fr = 0; INT32 flipflag = 0; @@ -3263,6 +3267,8 @@ static void K_drawKartLaps(void) Draw row = Draw(LAPS_X+23+bump, LAPS_Y+3).flags(V_HUDTRANS|V_SLIDEIN|splitflags).font(Draw::Font::kThinTimer); row.text("{:03}", displayEXP); } + + return drewsticker; } #define RINGANIM_FLIPFRAME (RINGANIM_NUMFRAMES/2) @@ -6823,8 +6829,7 @@ void K_drawKartHUD(void) { if (gametyperules & GTR_CIRCUIT) { - K_drawKartLaps(); - gametypeinfoshown = true; + gametypeinfoshown = K_drawKartLaps(); } else if (gametyperules & GTR_BUMPERS) { diff --git a/src/k_kart.c b/src/k_kart.c index f1a2aebec..4bf1b8110 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -15237,6 +15237,29 @@ fixed_t K_GetExpAdjustment(player_t *player) return result; } +UINT16 K_GetDisplayEXP(player_t *player) +{ + UINT32 numgradingpoints = K_GetNumGradingPoints(); + + if (!numgradingpoints) + return UINT16_MAX; + + fixed_t result = max(player->exp, FRACUNIT/2); + result = FixedMul(result, (500/numgradingpoints)*player->gradingpointnum); + + // bro where is. bro where is std::clamp + if (result < 0) + { + result = 0; + } + else if (result > 999) + { + result = 999; + } + + return result; +} + UINT32 K_GetNumGradingPoints(void) { return numlaps * (1 + Obj_GetCheckpointCount()); diff --git a/src/k_kart.h b/src/k_kart.h index 81bb5c9a4..0a8953ce2 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -298,6 +298,8 @@ boolean K_PlayerCanUseItem(player_t *player); fixed_t K_GetExpAdjustment(player_t *player); +UINT16 K_GetDisplayEXP(player_t *player); + UINT32 K_GetNumGradingPoints(void); #ifdef __cplusplus diff --git a/src/k_tally.cpp b/src/k_tally.cpp index b095ff202..d6fbe90e3 100644 --- a/src/k_tally.cpp +++ b/src/k_tally.cpp @@ -343,8 +343,13 @@ void level_tally_t::Init(player_t *player) if ((gametypes[gt]->rules & GTR_CIRCUIT) == GTR_CIRCUIT) { - laps = std::clamp(FixedMul(std::max(stplyr->exp, FRACUNIT/2), (500/K_GetNumGradingPoints())*player->gradingpointnum), 0, 999); - totalLaps = 500; + UINT16 displayEXP = K_GetDisplayEXP(player); + + if (displayEXP != UINT16_MAX) + { + laps = displayEXP; + totalLaps = 500; + } } if (battleprisons)