From ac549eddeb4d6b145a29485c57585a0649aedbc1 Mon Sep 17 00:00:00 2001
From: MascaraSnake <jonassauer27@gmail.com>
Date: Fri, 12 Jun 2020 09:28:41 +0200
Subject: [PATCH] Revamp alpha setup for crumbling FOFs

---
 extras/conf/udb/Includes/SRB222_linedefs.cfg | 17 +++++----
 src/p_setup.c                                | 37 ++++++++++++--------
 src/p_spec.c                                 | 26 +++++++-------
 src/p_spec.h                                 | 10 +++---
 4 files changed, 51 insertions(+), 39 deletions(-)

diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg
index 884865f952..95986acc76 100644
--- a/extras/conf/udb/Includes/SRB222_linedefs.cfg
+++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg
@@ -1873,22 +1873,27 @@ udmf
 				type = 13;
 			}
 			arg1
+			{
+				title = "Alpha";
+				default = 255;
+			}
+			arg2
 			{
 				title = "Tangibility";
 				type = 12;
 				enum = "tangibility";
 			}
-			arg2
+			arg3
 			{
 				title = "Flags";
 				type = 12;
 				enum
 				{
-					1 = "Translucent";
-					2 = "No shadow";
-					4 = "No respawn";
-					8 = "Air bobbing";
-					16 = "Float on water";
+					1 = "No shadow";
+					2 = "No respawn";
+					4 = "Air bobbing";
+					8 = "Float on water";
+					16 = "Cut cyan flat pixels";
 				}
 			}
 		}
diff --git a/src/p_setup.c b/src/p_setup.c
index 0ef1a9793a..e0f64fcba0 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -3180,31 +3180,38 @@ static void P_ConvertBinaryMap(void)
 		case 179: //FOF: Crumbling, no respawn, floating
 		case 180: //FOF: Crumbling, respawn, air bobbing
 			lines[i].args[0] = lines[i].tag;
-			if (lines[i].special >= 172 && lines[i].special <= 175)
-			{
-				lines[i].args[1] |= TMFT_INTANGIBLEBOTTOM;
-				if (lines[i].flags & ML_NOCLIMB)
-					lines[i].args[2] |= TMFC_NOSHADE;
-			}
+
+			//Alpha
 			if (lines[i].special >= 174 && lines[i].special <= 175)
 			{
-				lines[i].args[2] |= TMFC_TRANSLUCENT;
 				if (sides[lines[i].sidenum[0]].toptexture > 0)
-					lines[i].alpha = (sides[lines[i].sidenum[0]].toptexture << FRACBITS)/255;
+					lines[i].args[1] = sides[lines[i].sidenum[0]].toptexture;
 				else
-					lines[i].alpha = FRACUNIT/2;
+					lines[i].args[1] = 128;
 			}
+			else
+				lines[i].args[1] = 255;
+
+			if (lines[i].special >= 172 && lines[i].special <= 175)
+			{
+				lines[i].args[2] |= TMFT_INTANGIBLEBOTTOM;
+				if (lines[i].flags & ML_NOCLIMB)
+					lines[i].args[3] |= TMFC_NOSHADE;
+			}
+
 			if (lines[i].special % 2 == 1)
-				lines[i].args[2] |= TMFC_NORETURN;
+				lines[i].args[3] |= TMFC_NORETURN;
 			if (lines[i].special == 176 || lines[i].special == 177 || lines[i].special == 180)
-				lines[i].args[2] |= TMFC_AIRBOB;
+				lines[i].args[3] |= TMFC_AIRBOB;
 			if (lines[i].special >= 176 && lines[i].special <= 179)
-				lines[i].args[2] |= TMFC_FLOATBOB;
+				lines[i].args[3] |= TMFC_FLOATBOB;
+			if (lines[i].flags & ML_EFFECT6)
+				lines[i].args[3] |= TMFC_SPLAT;
 
 			if (lines[i].flags & ML_EFFECT1)
-				lines[i].args[1] |= TMFT_DONTBLOCKOTHERS;
+				lines[i].args[2] |= TMFT_DONTBLOCKOTHERS;
 			if (lines[i].flags & ML_EFFECT2)
-				lines[i].args[1] |= TMFT_DONTBLOCKPLAYER;
+				lines[i].args[2] |= TMFT_DONTBLOCKPLAYER;
 
 			lines[i].special = 170;
 			break;
@@ -3338,7 +3345,7 @@ static void P_ConvertBinaryMap(void)
 			//Translucency
 			if (lines[i].special == 253 || lines[i].special == 256)
 			{
-				lines[i].args[2] = TMFC_TRANSLUCENT;
+				lines[i].args[2] = 1;
 				if (sides[lines[i].sidenum[0]].toptexture > 0)
 					lines[i].alpha = (sides[lines[i].sidenum[0]].toptexture << FRACBITS)/255;
 				else
diff --git a/src/p_spec.c b/src/p_spec.c
index 84d399a55c..2e72902712 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -6713,33 +6713,33 @@ void P_SpawnSpecials(boolean fromnetsave)
 				ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CRUMBLE;
 
 				//Tangibility settings
-				if (lines[i].args[1] & TMFT_INTANGIBLETOP)
+				if (lines[i].args[2] & TMFT_INTANGIBLETOP)
 					ffloorflags |= FF_REVERSEPLATFORM;
-				if (lines[i].args[1] & TMFT_INTANGIBLEBOTTOM)
+				if (lines[i].args[2] & TMFT_INTANGIBLEBOTTOM)
 					ffloorflags |= FF_PLATFORM;
-				if (lines[i].args[1] & TMFT_DONTBLOCKPLAYER)
+				if (lines[i].args[2] & TMFT_DONTBLOCKPLAYER)
 					ffloorflags &= ~FF_BLOCKPLAYER;
-				if (lines[i].args[1] & TMFT_DONTBLOCKOTHERS)
+				if (lines[i].args[2] & TMFT_DONTBLOCKOTHERS)
 					ffloorflags &= ~FF_BLOCKOTHERS;
 
 				//Flags
-				if (lines[i].args[2] & TMFC_TRANSLUCENT)
-					ffloorflags |= FF_TRANSLUCENT;
-				if (lines[i].args[2] & TMFC_NOSHADE)
+				if (lines[i].args[3] & TMFC_NOSHADE)
 					ffloorflags |= FF_NOSHADE;
-				if (lines[i].args[2] & TMFC_NORETURN)
+				if (lines[i].args[3] & TMFC_NORETURN)
 					ffloorflags |= FF_NORETURN;
-				if (lines[i].args[2] & TMFC_FLOATBOB)
+				if (lines[i].args[3] & TMFC_FLOATBOB)
 					ffloorflags |= FF_FLOATBOB;
+				if (lines[i].args[3] & TMFC_SPLAT)
+					ffloorflags |= FF_SPLAT;
 
 				//If translucent or player can enter it, cut inner walls
-				if ((ffloorflags & FF_TRANSLUCENT) || (lines[i].args[1] & TMFT_VISIBLEFROMINSIDE))
+				if (lines[i].args[1] < 0xff || (lines[i].args[2] & TMFT_VISIBLEFROMINSIDE))
 					ffloorflags |= FF_CUTEXTRA|FF_EXTRA;
 				else
 					ffloorflags |= FF_CUTLEVEL;
 
 				//If player can enter it, render insides
-				if (lines[i].args[1] & TMFT_VISIBLEFROMINSIDE)
+				if (lines[i].args[2] & TMFT_VISIBLEFROMINSIDE)
 				{
 					if (ffloorflags & FF_RENDERPLANES)
 						ffloorflags |= FF_BOTHPLANES;
@@ -6747,8 +6747,8 @@ void P_SpawnSpecials(boolean fromnetsave)
 						ffloorflags |= FF_ALLSIDES;
 				}
 
-				P_AddFakeFloorsByLine(i, (ffloorflags & FF_TRANSLUCENT) ? (lines[i].alpha * 0xff) >> FRACBITS : 0xff, ffloorflags, secthinkers);
-				if (lines[i].args[2] & TMFC_AIRBOB)
+				P_AddFakeFloorsByLine(i, lines[i].args[1], ffloorflags, secthinkers);
+				if (lines[i].args[3] & TMFC_AIRBOB)
 					P_AddAirbob(lines[i].frontsector, lines[i].args[0], 16*FRACUNIT, false, false, false);
 				break;
 
diff --git a/src/p_spec.h b/src/p_spec.h
index 16f992780b..59aeb9f4d8 100644
--- a/src/p_spec.h
+++ b/src/p_spec.h
@@ -63,11 +63,11 @@ typedef enum
 
 typedef enum
 {
-	TMFC_TRANSLUCENT = 1,
-	TMFC_NOSHADE     = 1<<1,
-	TMFC_NORETURN    = 1<<2,
-	TMFC_AIRBOB      = 1<<3,
-	TMFC_FLOATBOB    = 1<<4,
+	TMFC_NOSHADE     = 1,
+	TMFC_NORETURN    = 1<<1,
+	TMFC_AIRBOB      = 1<<2,
+	TMFC_FLOATBOB    = 1<<3,
+	TMFC_SPLAT       = 1<<4,
 } textmapfofcrumbling_t;
 
 typedef enum
-- 
GitLab