mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Use integer arithmetic for pwrlv avg calculation
This fixes an oversight with pwrlv average calculation that causes the total to overflow with enough players or high enough pwrlv. Hopefully this might fix that bug where pwrlv is shown as negative on the server select menu. Maintainer note: This is still imprecise but it fixes the overflow without potentially disrupting game code.
This commit is contained in:
parent
8326292a3f
commit
5fbe9f9827
1 changed files with 3 additions and 3 deletions
|
|
@ -138,7 +138,7 @@ INT16 K_PowerLevelPlacementScore(player_t *player)
|
|||
|
||||
INT16 K_CalculatePowerLevelAvg(void)
|
||||
{
|
||||
fixed_t avg = 0;
|
||||
INT32 avg = 0;
|
||||
UINT8 div = 0;
|
||||
SINT8 t = PWRLV_DISABLED;
|
||||
UINT8 i;
|
||||
|
|
@ -166,7 +166,7 @@ INT16 K_CalculatePowerLevelAvg(void)
|
|||
|| clientpowerlevels[i][t] == 0) // splitscreen player
|
||||
continue;
|
||||
|
||||
avg += (clientpowerlevels[i][t] << FRACBITS);
|
||||
avg += clientpowerlevels[i][t];
|
||||
div++;
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ INT16 K_CalculatePowerLevelAvg(void)
|
|||
|
||||
avg /= div;
|
||||
|
||||
return (INT16)(avg >> FRACBITS);
|
||||
return (INT16)avg;
|
||||
}
|
||||
|
||||
void K_UpdatePowerLevels(player_t *player, UINT8 lap, boolean forfeit)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue