can not use max() on player->marbeguant

player->marebegunat is tic_t, which in unsigned.
Let just about INT32_MAX to see if it in - number space
This commit is contained in:
Alam Ed Arias 2023-10-25 07:52:51 -04:00
parent 8f71c2fb2e
commit 76a3cf6b4e

View file

@ -862,6 +862,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
tic_t marebegunat;
if (!playeringame[i] || !players[i].mo || players[i].spectator) if (!playeringame[i] || !players[i].mo || players[i].spectator)
continue; continue;
@ -883,8 +884,12 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
P_AddPlayerScore(&players[i], (players[i].spheres) * 50); P_AddPlayerScore(&players[i], (players[i].spheres) * 50);
} }
marebegunat = player->marebegunat;
if (marebegunat > INT32_MAX)
marebegunat = 0;
// Add score to leaderboards now // Add score to leaderboards now
player->lastmaretime = leveltime - max(0, player->marebegunat); player->lastmaretime = leveltime - marebegunat;
G_AddTempNightsRecords(player, players[i].marescore, player->lastmaretime, players[i].mare + 1); G_AddTempNightsRecords(player, players[i].marescore, player->lastmaretime, players[i].mare + 1);
// transfer scores anyway // transfer scores anyway
@ -898,6 +903,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
} }
else if (oldmare != player->mare) else if (oldmare != player->mare)
{ {
tic_t marebegunat;
/// \todo Handle multi-mare special stages. /// \todo Handle multi-mare special stages.
// Spheres bonus // Spheres bonus
P_AddPlayerScore(player, (player->spheres) * 50); P_AddPlayerScore(player, (player->spheres) * 50);
@ -910,8 +916,12 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
player->finishedspheres = (INT16)(player->spheres); player->finishedspheres = (INT16)(player->spheres);
player->finishedrings = (INT16)(player->rings); player->finishedrings = (INT16)(player->rings);
marebegunat = player->marebegunat;
if (marebegunat > INT32_MAX)
marebegunat = 0;
// Add score to temp leaderboards // Add score to temp leaderboards
player->lastmaretime = leveltime - max(0, player->marebegunat); player->lastmaretime = leveltime - marebegunat;
G_AddTempNightsRecords(player, player->marescore, player->lastmaretime, (UINT8)(oldmare + 1)); G_AddTempNightsRecords(player, player->marescore, player->lastmaretime, (UINT8)(oldmare + 1));
// Starting a new mare, transfer scores // Starting a new mare, transfer scores