From ef0ff01ef133740fa025146172a0fe48cb54eb1d Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 14 Sep 2022 22:38:12 -0700 Subject: [PATCH 1/2] FixedDiv2: divide numerator before taking absolute value to avoid INT32_MIN overflow to 0 --- src/m_fixed.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_fixed.h b/src/m_fixed.h index 9f3bb2910..021f84d89 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -204,7 +204,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedInt(fixed_t a) */ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedDiv(fixed_t a, fixed_t b) { - if ((abs(a) >> (FRACBITS-2)) >= abs(b)) + if ((abs(a / (FRACUNIT/4))) >= abs(b)) return (a^b) < 0 ? INT32_MIN : INT32_MAX; return FixedDiv2(a, b); From 6af7df8d4022ff80a34258c754de0151f96707e3 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 14 Sep 2022 23:02:55 -0700 Subject: [PATCH 2/2] Fix -Wsign-compare --- src/k_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index ca3aaa2c3..968ba8632 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -657,7 +657,7 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) const INT32 startDist = (DEFAULT_WAYPOINT_RADIUS * 2 * mapobjectscale) / FRACUNIT; const INT32 maxDist = startDist * 4; // This function gets very laggy when it goes far distances, and going too far isn't very helpful anyway. - const INT32 distance = min(((speed / FRACUNIT) * futuresight) + startDist, maxDist); + const INT32 distance = min(((speed / FRACUNIT) * (INT32)futuresight) + startDist, maxDist); // Halves radius when encountering a wall on your way to your destination. fixed_t radreduce = FRACUNIT;