From 0821f7fb2168c6d063b05f7620baf28c35a52524 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Thu, 1 Aug 2019 18:56:00 +0100
Subject: [PATCH] Add openfloorrover and openceilingrover vars so that
 PIT_CheckLine can update tmfloorrover and tmceilingrover properly via
 P_LineOpening

...which should hopefully stop that issue where you just teleport back to the ground. Assuming this works as expected.

Also this is untested lol.
---
 src/p_maputl.c | 13 +++++++++++++
 src/p_maputl.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/src/p_maputl.c b/src/p_maputl.c
index 0ca84096ab..4dafbcc7fe 100644
--- a/src/p_maputl.c
+++ b/src/p_maputl.c
@@ -311,6 +311,7 @@ fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
 #ifdef ESLOPE
 pslope_t *opentopslope, *openbottomslope;
 #endif
+ffloor_t *openfloorrover, *openceilingrover;
 
 // P_CameraLineOpening
 // P_LineOpening, but for camera
@@ -517,6 +518,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 	I_Assert(front != NULL);
 	I_Assert(back != NULL);
 
+	openfloorrover = openceilingrover = NULL;
+
 	{ // Set open and high/low values here
 		fixed_t frontheight, backheight;
 
@@ -641,6 +644,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 			pslope_t *ceilingslope = opentopslope;
 			pslope_t *floorslope = openbottomslope;
 #endif
+			ffloor_t *floorrover = NULL;
+			ffloor_t *ceilingrover = NULL;
 
 			// Check for frontsector's fake floors
 			for (rover = front->ffloors; rover; rover = rover->next)
@@ -668,6 +673,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 #ifdef ESLOPE
 						ceilingslope = *rover->b_slope;
 #endif
+						ceilingrover = rover;
 					}
 					else if (bottomheight < highestceiling)
 						highestceiling = bottomheight;
@@ -680,6 +686,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 #ifdef ESLOPE
 						floorslope = *rover->t_slope;
 #endif
+						floorrover = rover;
 					}
 					else if (topheight > lowestfloor)
 						lowestfloor = topheight;
@@ -712,6 +719,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 #ifdef ESLOPE
 						ceilingslope = *rover->b_slope;
 #endif
+						ceilingrover = rover;
 					}
 					else if (bottomheight < highestceiling)
 						highestceiling = bottomheight;
@@ -724,6 +732,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 #ifdef ESLOPE
 						floorslope = *rover->t_slope;
 #endif
+						floorrover = rover;
 					}
 					else if (topheight > lowestfloor)
 						lowestfloor = topheight;
@@ -743,6 +752,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 #ifdef ESLOPE
 					ceilingslope = NULL;
 #endif
+					ceilingrover = NULL;
 				}
 				else if (polysec->floorheight < highestceiling && delta1 >= delta2)
 					highestceiling = polysec->floorheight;
@@ -752,6 +762,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 #ifdef ESLOPE
 					floorslope = NULL;
 #endif
+					floorrover = NULL;
 				}
 				else if (polysec->ceilingheight > lowestfloor && delta1 < delta2)
 					lowestfloor = polysec->ceilingheight;
@@ -765,6 +776,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 #ifdef ESLOPE
 				openbottomslope = floorslope;
 #endif
+				openfloorrover = floorrover;
 			}
 
 			if (lowestceiling < opentop) {
@@ -772,6 +784,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 #ifdef ESLOPE
 				opentopslope = ceilingslope;
 #endif
+				openceilingrover = floorrover;
 			}
 
 			if (lowestfloor > lowfloor)
diff --git a/src/p_maputl.h b/src/p_maputl.h
index 1fcb68d4c7..5042817c54 100644
--- a/src/p_maputl.h
+++ b/src/p_maputl.h
@@ -58,6 +58,7 @@ extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling;
 #ifdef ESLOPE
 extern pslope_t *opentopslope, *openbottomslope;
 #endif
+extern ffloor_t *openfloorrover, *openceilingrover;
 
 void P_LineOpening(line_t *plinedef, mobj_t *mobj);
 
-- 
GitLab