From 61388459302db4cd328f48fcc972e776d842a02c Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Sun, 21 Jun 2015 16:58:34 +0100
Subject: [PATCH] Removed all "-1"s from R_PointToAngle and R_PointToAngle2, in
 order to allow ALL basic compass directions at the least to be given the
 right angle by these functions.

Note: Before this change, North and West directions would be returned as ANGLE_90-1 and ANGLE_180-1. This caused the pusher polyobjects in THZ2 to slowly move sideways as a side-effect (and probably caused similar bugs in the past too, these functions have barely been touched in a decade it turns out.)
---
 src/r_main.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/r_main.c b/src/r_main.c
index 1edcb815b5..19a6b5cba6 100644
--- a/src/r_main.c
+++ b/src/r_main.c
@@ -316,13 +316,13 @@ angle_t R_PointToAngle(fixed_t x, fixed_t y)
 	x >= 0 ?
 	y >= 0 ?
 		(x > y) ? tantoangle[SlopeDiv(y,x)] :                          // octant 0
-		ANGLE_90-1-tantoangle[SlopeDiv(x,y)] :                         // octant 1
+		ANGLE_90-tantoangle[SlopeDiv(x,y)] :                           // octant 1
 		x > (y = -y) ? 0-tantoangle[SlopeDiv(y,x)] :                   // octant 8
 		ANGLE_270+tantoangle[SlopeDiv(x,y)] :                          // octant 7
-		y >= 0 ? (x = -x) > y ? ANGLE_180-1-tantoangle[SlopeDiv(y,x)] :// octant 3
+		y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDiv(y,x)] :  // octant 3
 		ANGLE_90 + tantoangle[SlopeDiv(x,y)] :                         // octant 2
-		(x = -x) > (y = -y) ? ANGLE_180+tantoangle[ SlopeDiv(y,x)] :   // octant 4
-		ANGLE_270-1-tantoangle[SlopeDiv(x,y)] :                        // octant 5
+		(x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDiv(y,x)] :    // octant 4
+		ANGLE_270-tantoangle[SlopeDiv(x,y)] :                          // octant 5
 		0;
 }
 
@@ -332,13 +332,13 @@ angle_t R_PointToAngle2(fixed_t pviewx, fixed_t pviewy, fixed_t x, fixed_t y)
 	x >= 0 ?
 	y >= 0 ?
 		(x > y) ? tantoangle[SlopeDiv(y,x)] :                          // octant 0
-		ANGLE_90-1-tantoangle[SlopeDiv(x,y)] :                         // octant 1
+		ANGLE_90-tantoangle[SlopeDiv(x,y)] :                           // octant 1
 		x > (y = -y) ? 0-tantoangle[SlopeDiv(y,x)] :                   // octant 8
 		ANGLE_270+tantoangle[SlopeDiv(x,y)] :                          // octant 7
-		y >= 0 ? (x = -x) > y ? ANGLE_180-1-tantoangle[SlopeDiv(y,x)] :// octant 3
+		y >= 0 ? (x = -x) > y ? ANGLE_180-tantoangle[SlopeDiv(y,x)] :  // octant 3
 		ANGLE_90 + tantoangle[SlopeDiv(x,y)] :                         // octant 2
-		(x = -x) > (y = -y) ? ANGLE_180+tantoangle[ SlopeDiv(y,x)] :   // octant 4
-		ANGLE_270-1-tantoangle[SlopeDiv(x,y)] :                        // octant 5
+		(x = -x) > (y = -y) ? ANGLE_180+tantoangle[SlopeDiv(y,x)] :    // octant 4
+		ANGLE_270-tantoangle[SlopeDiv(x,y)] :                          // octant 5
 		0;
 }
 
-- 
GitLab