fix calculating exp before gradingpointnum increment

fix leftover lappoints code affecting exp
This commit is contained in:
Ashnal 2025-05-17 21:13:15 -04:00
parent 2c97f2bf1e
commit f2d323111f
5 changed files with 9 additions and 40 deletions

View file

@ -950,7 +950,7 @@ struct player_t
UINT8 laps; // Number of laps (optional)
UINT8 latestlap;
UINT32 exp; // Points given from laps and checkpoints
INT32 gradingfactor;
fixed_t gradingfactor;
UINT16 gradingpointnum; // how many grading points, checkpoint and finishline, you've passed
INT32 cheatchecknum; // The number of the last cheatcheck you hit
INT32 checkpointId; // Players respawn here, objects/checkpoint.cpp

View file

@ -4235,7 +4235,9 @@ void K_CheckpointCrossAward(player_t *player)
return;
player->gradingfactor += K_GetGradingMultAdjustment(player);
player->gradingpointnum++;
player->exp = K_GetEXP(player);
//CONS_Printf("player: %s factor: %.2f exp: %d\n", player_names[player-players], FIXED_TO_FLOAT(player->gradingfactor), player->exp);
if (!player->cangrabitems)
player->cangrabitems = 1;
@ -15493,19 +15495,14 @@ fixed_t K_GetGradingMultAdjustment(player_t *player)
return result;
}
UINT16 K_GetEXP(player_t *player)
UINT16 __attribute__((optimize("O0"))) K_GetEXP(player_t *player)
{
UINT32 numgradingpoints = K_GetNumGradingPoints();
if (!numgradingpoints)
return UINT16_MAX;
// target is where you should be if you're doing good and at a 1.0 mult
fixed_t clampedmult = max(FRACUNIT/2, min(FRACUNIT*5/4, player->gradingfactor)); // clamp between 0.5 and 1.25
fixed_t targetdisplayexp = (TARGETEXP*player->gradingpointnum/max(1,numgradingpoints))<<FRACBITS;
UINT16 displayexp = FixedMul(clampedmult, targetdisplayexp)>>FRACBITS;
return displayexp;
fixed_t targetexp = (TARGETEXP*player->gradingpointnum/max(1,numgradingpoints))<<FRACBITS;
UINT16 exp = FixedMul(clampedmult, targetexp)>>FRACBITS;
return exp;
}
UINT32 K_GetNumGradingPoints(void)

View file

@ -343,11 +343,9 @@ void level_tally_t::Init(player_t *player)
if ((gametypes[gt]->rules & GTR_CIRCUIT) == GTR_CIRCUIT)
{
UINT16 displayEXP = player->exp;
if (displayEXP != UINT16_MAX)
if (player->exp)
{
exp = displayEXP;
exp = player->exp;
totalExp = TARGETEXP;
}
}

View file

@ -665,20 +665,7 @@ void Obj_CrossCheckpoints(player_t* player, fixed_t old_x, fixed_t old_y)
player->checkpointId = chk->id();
if (D_NumPlayersInRace() > 1 && !K_IsPlayerLosing(player))
{
if (player->position == 1)
{
player->exp += 2;
}
else
{
player->exp += 1;
}
}
K_CheckpointCrossAward(player);
player->gradingpointnum++;
K_UpdatePowerLevels(player, player->laps, false);
}

View file

@ -2109,20 +2109,7 @@ static void K_HandleLapIncrement(player_t *player)
// Update power levels for this lap.
K_UpdatePowerLevels(player, player->laps, false);
if (nump > 1 && K_IsPlayerLosing(player) == false)
{
if (inDuel == false && player->position == 1) // 1st place in 1v1 uses thumbs up
{
player->exp += 2;
}
else
{
player->exp++;
}
}
K_CheckpointCrossAward(player);
player->gradingpointnum++;
if (player->position == 1 && !(gametyperules & GTR_CHECKPOINTS))
{