From f8c51ccde341582e831f19dbd5ece3e68c87a4aa Mon Sep 17 00:00:00 2001
From: MascaraSnake <jonassauer27@gmail.com>
Date: Tue, 14 Apr 2020 10:13:38 +0200
Subject: [PATCH] Implement FOF types 220-222

---
 extras/conf/udb/Includes/SRB222_linedefs.cfg | 32 ++++++++++++++++++
 src/p_setup.c                                | 25 ++++++++++++++
 src/p_spec.c                                 | 35 +++++++++++---------
 3 files changed, 76 insertions(+), 16 deletions(-)

diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg
index 0847826d43..1ee245d088 100644
--- a/extras/conf/udb/Includes/SRB222_linedefs.cfg
+++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg
@@ -1611,6 +1611,38 @@ udmf
 			}
 		}
 
+		220
+		{
+			title = "Intangible";
+			prefix = "(220)";
+			arg0
+			{
+				title = "Target sector tag";
+				type = 13;
+			}
+			arg1
+			{
+				title = "Visibility";
+				type = 12;
+				enum
+				{
+					1 = "Don't render planes";
+					2 = "Don't render sides";
+					4 = "Don't render insides";
+				}
+			}
+			arg2
+			{
+				title = "Appearance";
+				type = 12;
+				enum
+				{
+					1 = "Translucent";
+					2 = "No shadow";
+				}
+			}
+		}
+
 		223
 		{
 			title = "Intangible, Invisible";
diff --git a/src/p_setup.c b/src/p_setup.c
index 7c8a8c1473..55eacc6e48 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -2931,6 +2931,31 @@ static void P_ConvertBinaryMap(void)
 		case 223: //FOF: Intangible, invisible
 			lines[i].args[0] = lines[i].tag;
 			break;
+		case 220: //FOF: Intangible, opaque
+		case 221: //FOF: Intangible, translucent
+		case 222: //FOF: Intangible, sides only
+			lines[i].args[0] = lines[i].tag;
+
+			//Visibility
+			if (lines[i].special == 222)
+				lines[i].args[1] |= 1; //Don't render planes
+			if (lines[i].special != 220)
+				lines[i].args[1] |= 4; //Don't render insides
+
+			//Appearance
+			if (lines[i].special == 221)
+			{
+				lines[i].args[2] |= 1; //Translucent
+				if (sides[lines[i].sidenum[0]].toptexture > 0)
+					lines[i].alpha = (sides[lines[i].sidenum[0]].toptexture << FRACBITS)/255;
+				else
+					lines[i].alpha = FRACUNIT/2;
+			}
+			if (lines[i].special != 220 && !(lines[i].flags & ML_NOCLIMB))
+				lines[i].args[2] |= 2; //Don't cast shadow
+
+			lines[i].special = 220;
+            break;
 		case 250: //FOF: Mario block
 			lines[i].args[0] = lines[i].tag;
 			if (lines[i].flags & ML_NOCLIMB) //Brick block
diff --git a/src/p_spec.c b/src/p_spec.c
index 5288d27732..2bcd2a9e5b 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -6959,24 +6959,27 @@ void P_SpawnSpecials(boolean fromnetsave)
 				P_AddFakeFloorsByLine(i, ffloorflags, secthinkers);
 				break;
 
-			case 220: // Like opaque water, but not swimmable. (Good for snow effect on FOFs)
-				P_AddFakeFloorsByLine(i, FF_EXISTS|FF_RENDERALL|FF_BOTHPLANES|FF_ALLSIDES|FF_CUTEXTRA|FF_EXTRA|FF_CUTSPRITES, secthinkers);
-				break;
-
-			case 221: // FOF (intangible, translucent)
-				// If line has no-climb set, give it shadows, otherwise don't
-				ffloorflags = FF_EXISTS|FF_RENDERALL|FF_TRANSLUCENT|FF_EXTRA|FF_CUTEXTRA|FF_CUTSPRITES;
-				if (!(lines[i].flags & ML_NOCLIMB))
-					ffloorflags |= FF_NOSHADE;
+			case 220: //Intangible
+				ffloorflags = FF_EXISTS|FF_RENDERALL|FF_CUTEXTRA|FF_EXTRA|FF_CUTSPRITES;
 
-				P_AddFakeFloorsByLine(i, ffloorflags, secthinkers);
-				break;
+				//Visibility settings
+				if (lines[i].args[1] & 1) //Don't render planes
+					ffloorflags &= ~FF_RENDERPLANES;
+				if (lines[i].args[1] & 2) //Don't render sides
+					ffloorflags &= ~FF_RENDERSIDES;
+				if (!(lines[i].args[1] & 4)) //Render insides
+				{
+					if (ffloorflags & FF_RENDERPLANES)
+						ffloorflags |= FF_BOTHPLANES;
+					if (ffloorflags & FF_RENDERSIDES)
+						ffloorflags |= FF_ALLSIDES;
+				}
 
-			case 222: // FOF with no floor/ceiling (good for GFZGRASS effect on FOFs)
-				// If line has no-climb set, give it shadows, otherwise don't
-				ffloorflags = FF_EXISTS|FF_RENDERSIDES|FF_ALLSIDES;
-				if (!(lines[i].flags & ML_NOCLIMB))
-					ffloorflags |= FF_NOSHADE|FF_CUTSPRITES;
+				//Appearance settings
+				if ((lines[i].args[2] & 1) && (ffloorflags & FF_RENDERALL)) //Translucent
+					ffloorflags |= FF_TRANSLUCENT;
+				if (lines[i].args[2] & 2) //Don't cast shadow
+					ffloorflags |= FF_NOSHADE;
 
 				P_AddFakeFloorsByLine(i, ffloorflags, secthinkers);
 				break;
-- 
GitLab