From 2c75e46855ce3054604d7c73fb64dc6563b714c8 Mon Sep 17 00:00:00 2001 From: Anonimus Date: Wed, 1 Oct 2025 11:10:00 -0400 Subject: [PATCH] Return to 32-bit land --- src/k_odds.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/k_odds.c b/src/k_odds.c index 385a14ca4..dda137ac0 100644 --- a/src/k_odds.c +++ b/src/k_odds.c @@ -899,8 +899,7 @@ UINT32 K_CalculateInitalPDIS(const player_t *player, UINT8 pingame) { UINT8 i; - // Hacky solution to the overflow problem: use 64-bit integers! - UINT64 pdis = 0; + UINT32 pdis = 0; if (!K_UsingLegacyCheckpoints()) { @@ -1029,6 +1028,7 @@ UINT32 K_CalculateInitalPDIS(const player_t *player, UINT8 pingame) // Add the distance to the player behind you. // At a (relative to map) integer scale using basic distancing // arithmetic; more accurate and less concern for overflows. + // TODO: Overflow-safe addition (caps at UINT32_MAX). pdis += K_IntDistanceForMap( secondPlayer->mo->x, secondPlayer->mo->y, @@ -1047,17 +1047,9 @@ UINT32 K_CalculateInitalPDIS(const player_t *player, UINT8 pingame) } // Exaggerate odds; don't you love the legacy system? :Trollic: - pdis = FixedMul64(pdis, LEGACYODDSEXAGGERATE); + pdis = FixedMul(pdis, LEGACYODDSEXAGGERATE); - // Clamp pdis to the highest 32-bit integer. - // This is a shitty solution for overflow prevention, but it's an overflow prevention - // nonethless. - if (pdis > UINT32_MAX) - { - pdis = UINT32_MAX; - } - - return (UINT32)(pdis); + return pdis; } #undef LEGACYODDSEXAGGERATE