mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Don't attempt to use adjusted EXP counter in invalid contexts
- Introduces new function K_GetDisplayEXP
- Replaces duplicated code between HUD and tally
- Returns UINT16_MAX in div/0 case for invalid result (resolves #1458)
- Hides EXP HUD/tally if no EXP can be earned
This commit is contained in:
parent
f7131d8e86
commit
396244780a
4 changed files with 44 additions and 9 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
23
src/k_kart.c
23
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());
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue