From a82c19adb1cb68e78f7eeb12e09e2c58d99f0cb1 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Sat, 19 Mar 2016 16:19:58 +0000
Subject: [PATCH] Fix sprites displaying behind "closed doors" when slopes are
 present.

For the record, thok barriers count as "closed doors" in SRB2 level contexts
---
 src/r_segs.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/r_segs.c b/src/r_segs.c
index 72315982d9..9ecb7708e1 100644
--- a/src/r_segs.c
+++ b/src/r_segs.c
@@ -1947,21 +1947,25 @@ void R_StoreWallRange(INT32 start, INT32 stop)
 			ds_p->silhouette |= SIL_TOP;
 		}
 
-#ifdef ESLOPE
-		// This causes issues with slopes.
-		if (!(frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope))
-#endif
 		//SoM: 3/25/2000: This code fixes an automap bug that didn't check
 		// frontsector->ceiling and backsector->floor to see if a door was closed.
 		// Without the following code, sprites get displayed behind closed doors.
 		{
+#ifdef ESLOPE
+			if (doorclosed || (worldhigh <= worldbottom && worldhighslope <= worldbottomslope))
+#else
 			if (doorclosed || backsector->ceilingheight <= frontsector->floorheight)
+#endif
 			{
 				ds_p->sprbottomclip = negonearray;
 				ds_p->bsilheight = INT32_MAX;
 				ds_p->silhouette |= SIL_BOTTOM;
 			}
+#ifdef ESLOPE
+			if (doorclosed || (worldlow >= worldtop && worldlowslope >= worldtopslope))
+#else
 			if (doorclosed || backsector->floorheight >= frontsector->ceilingheight)
+#endif
 			{                   // killough 1/17/98, 2/8/98
 				ds_p->sprtopclip = screenheightarray;
 				ds_p->tsilheight = INT32_MIN;
-- 
GitLab