From 6019b8b96a0f8bfce53ec92c3bdf9e33c9a84678 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 2 Jun 2023 16:09:47 -0700 Subject: [PATCH] R_ProjectSprite: fix overflow in sideways perspective clipping Multiplications of perspective values can easily overflow and flip sign bit at far distances. Instead, divide the left operand. --- src/r_things.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.cpp b/src/r_things.cpp index adb407973..f37ced90f 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2037,7 +2037,7 @@ static void R_ProjectSprite(mobj_t *thing) tz2 = FixedMul(MINZ, this_scale); } - if (tx2 < -(FixedMul(tz2, fovtan[viewssnum])<<2) || tx > FixedMul(tz, fovtan[viewssnum])<<2) // too far off the side? + if ((tx2 / 4) < -(FixedMul(tz2, fovtan[viewssnum])) || (tx / 4) > FixedMul(tz, fovtan[viewssnum])) // too far off the side? return; yscale = FixedDiv(projectiony[viewssnum], tz);