From 54b3aff09f06ed25da1fbab7059c0fd0e717872d 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.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_things.c b/src/r_things.c index eb4e5f63b..79510bff8 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1989,7 +1989,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);