From ba7d97733dc9dd3529689ee81ce21afe63fb3e9d Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Mon, 26 Mar 2018 00:33:17 -0400
Subject: [PATCH 1/2] Fix NiGHTS drone loop detection by using pl->flyangle

(cherry picked from commit 67e438128435aca992e2d45aa1f35603c5501984)
---
 src/p_map.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/p_map.c b/src/p_map.c
index f319acea8..acaa2a997 100644
--- a/src/p_map.c
+++ b/src/p_map.c
@@ -777,14 +777,14 @@ static boolean PIT_CheckThing(mobj_t *thing)
 		// not (your direction) xor (stored direction)
 		// In other words, you can't u-turn and respawn rings near the drone.
 		if (pl->bonustime && (pl->pflags & PF_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && (
-		   !(pl->anotherflyangle >= 90 &&   pl->anotherflyangle <= 270)
+		   !(pl->flyangle >= 90 &&   pl->flyangle <= 270)
 		^ (droneobj->extravalue1 >= 90 && droneobj->extravalue1 <= 270)
 		))
 		{
 			// Reload all the fancy ring stuff!
 			P_ReloadRings();
 		}
-		droneobj->extravalue1 = pl->anotherflyangle;
+		droneobj->extravalue1 = pl->flyangle;
 		droneobj->extravalue2 = (INT32)leveltime + TICRATE;
 	}
 

From 25361713dc2841e0e4ef22923489faf9364bf200 Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Mon, 26 Mar 2018 01:04:02 -0400
Subject: [PATCH 2/2] NiGHTS drone loop: Change flyangle comparison to fix
 detection from vertical angles

Use > 90 && < 270 instead of >= 90 && <= 270. Fixes a bug where if you fly directly up (flyangle 90) or directly down (flyangle 270), that registers as a backwards direction, so you trigger the loop detection by flying BACKWARDS, not FORWARDS. This edge case (only possible via JUMPTOAXIS) should default to FORWARDS looping.

(cherry picked from commit ce215195f89bf52e5c2e2ddd7d5444685edf835d)
---
 src/p_map.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/p_map.c b/src/p_map.c
index acaa2a997..28c6045c7 100644
--- a/src/p_map.c
+++ b/src/p_map.c
@@ -777,8 +777,8 @@ static boolean PIT_CheckThing(mobj_t *thing)
 		// not (your direction) xor (stored direction)
 		// In other words, you can't u-turn and respawn rings near the drone.
 		if (pl->bonustime && (pl->pflags & PF_NIGHTSMODE) && (INT32)leveltime > droneobj->extravalue2 && (
-		   !(pl->flyangle >= 90 &&   pl->flyangle <= 270)
-		^ (droneobj->extravalue1 >= 90 && droneobj->extravalue1 <= 270)
+		   !(pl->flyangle > 90 &&   pl->flyangle < 270)
+		^ (droneobj->extravalue1 > 90 && droneobj->extravalue1 < 270)
 		))
 		{
 			// Reload all the fancy ring stuff!