From 44923c2b2aa0ad9409c69a34820eb45243e1f5f3 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Fri, 3 May 2024 00:57:05 -0700
Subject: [PATCH] Line sweep polyobject sides

Gremlin III vanquished for Balloon Park elephants.
---
 src/g_demo.cpp  | 1 +
 src/p_map.c     | 4 ++--
 src/p_polyobj.c | 4 ++++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/g_demo.cpp b/src/g_demo.cpp
index 4e0bfd4374..3055f035c6 100644
--- a/src/g_demo.cpp
+++ b/src/g_demo.cpp
@@ -164,6 +164,7 @@ demoghost *ghosts = NULL;
 // - 0x000A (Ring Racers v2.0)
 //   - A bug was preventing control after ending a drift.
 //     Older behavior is kept around for staff ghost compat.
+//   - Also, polyobject bounce-back was fixed!
 
 #define DEMOVERSION 0x000B
 
diff --git a/src/p_map.c b/src/p_map.c
index 84126fb8d3..bb7868dd44 100644
--- a/src/p_map.c
+++ b/src/p_map.c
@@ -2186,6 +2186,8 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re
 		}
 	}
 
+	P_ClearTestLines();
+
 	// The bounding box is extended by MAXRADIUS
 	// because mobj_ts are grouped into mapblocks
 	// based on their origin point, and can overlap
@@ -2323,8 +2325,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y, TryMoveResult_t *re
 
 	validcount++;
 
-	P_ClearTestLines();
-
 	// check lines
 	for (bx = xl; bx <= xh; bx++)
 	{
diff --git a/src/p_polyobj.c b/src/p_polyobj.c
index 80f03d0f73..82eb95432e 100644
--- a/src/p_polyobj.c
+++ b/src/p_polyobj.c
@@ -201,6 +201,10 @@ boolean P_BBoxInsidePolyobj(polyobj_t *po, fixed_t *bbox)
 	{
 		if (P_BoxOnLineSide(bbox, po->lines[i]) == 0)
 			return false;
+		if (g_tm.sweep && !G_CompatLevel(0x000A))
+		{
+			P_TestLine(po->lines[i]);
+		}
 	}
 
 	return true;
-- 
GitLab