From 1530183ddf1323748938cd41919aa4816b1f68a7 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Sun, 14 Aug 2016 16:56:41 +0100
Subject: [PATCH] Fix multiple solid midtexture-related issues:

* Effect 3 (Peg Midtexture) is now accounted for properly, flipping the collision box position to match the actual rendered position of the midtexture
* Fixed incorrect application of y-offsets for non-lower unpegged midtextures collision boxes; +ve always goes up, -ve always goes down!
* Effect 4 now doesn't make midtextures solid for polyobjects at all - this "conflicted" with First Line having both Effect 4 (visible planes) and Effect 3 (intangible) simultaneously, where we kind of expect the first line's wall to not be made solid. This may be less of a problem in future SRB2 versions, but for now solid midtextures for polyobjects are disabled.
---
 src/p_maputl.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/p_maputl.c b/src/p_maputl.c
index df2bf8f5c..373679122 100644
--- a/src/p_maputl.c
+++ b/src/p_maputl.c
@@ -566,7 +566,9 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 		fixed_t thingtop = mobj->z + mobj->height;
 
 		// Check for collision with front side's midtexture if Effect 4 is set
-		if (linedef->flags & ML_EFFECT4) {
+		if (linedef->flags & ML_EFFECT4
+			&& !linedef->polyobj // don't do anything for polyobjects! ...for now
+			) {
 			side_t *side = &sides[linedef->sidenum[0]];
 			fixed_t textop, texbottom, texheight;
 			fixed_t texmid, delta1, delta2;
@@ -575,23 +577,25 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj)
 			texheight = textures[texturetranslation[side->midtexture]]->height << FRACBITS;
 
 			// Set texbottom and textop to the Z coordinates of the texture's boundaries
-#ifdef POLYOBJECTS
+#if 0 // #ifdef POLYOBJECTS
+			// don't remove this code unless solid midtextures
+			// on non-solid polyobjects should NEVER happen in the future
 			if (linedef->polyobj && (linedef->polyobj->flags & POF_TESTHEIGHT)) {
-				if (linedef->flags & ML_DONTPEGBOTTOM) {
+				if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) {
 					texbottom = back->floorheight + side->rowoffset;
 					textop = texbottom + texheight*(side->repeatcnt+1);
 				} else {
-					textop = back->ceilingheight - side->rowoffset;
+					textop = back->ceilingheight + side->rowoffset;
 					texbottom = textop - texheight*(side->repeatcnt+1);
 				}
 			} else
 #endif
 			{
-				if (linedef->flags & ML_DONTPEGBOTTOM) {
+				if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) {
 					texbottom = openbottom + side->rowoffset;
 					textop = texbottom + texheight*(side->repeatcnt+1);
 				} else {
-					textop = opentop - side->rowoffset;
+					textop = opentop + side->rowoffset;
 					texbottom = textop - texheight*(side->repeatcnt+1);
 				}
 			}
-- 
GitLab