From 76a3cf6b4e16989cdd18f7d9a64ddff71575d738 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias <alam@srb2.org> Date: Wed, 25 Oct 2023 07:52:51 -0400 Subject: [PATCH] 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 --- src/p_user.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index ac53b00d2..2c4754ab3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -862,6 +862,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) for (i = 0; i < MAXPLAYERS; i++) { + tic_t marebegunat; if (!playeringame[i] || !players[i].mo || players[i].spectator) continue; @@ -883,8 +884,12 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) P_AddPlayerScore(&players[i], (players[i].spheres) * 50); } + marebegunat = player->marebegunat; + if (marebegunat > INT32_MAX) + marebegunat = 0; + // 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); // transfer scores anyway @@ -898,6 +903,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) } else if (oldmare != player->mare) { + tic_t marebegunat; /// \todo Handle multi-mare special stages. // Spheres bonus P_AddPlayerScore(player, (player->spheres) * 50); @@ -910,8 +916,12 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime) player->finishedspheres = (INT16)(player->spheres); player->finishedrings = (INT16)(player->rings); + marebegunat = player->marebegunat; + if (marebegunat > INT32_MAX) + marebegunat = 0; + // 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)); // Starting a new mare, transfer scores