From 6521496d8ab30704c33f0dff6366d18d43d86e1d Mon Sep 17 00:00:00 2001
From: MascaraSnake <jonassauer27@gmail.com>
Date: Fri, 12 Jun 2020 10:53:27 +0200
Subject: [PATCH] Revamp alpha setup for bobbing FOFs

---
 extras/conf/udb/Includes/SRB222_linedefs.cfg | 26 ++++++++-
 src/p_setup.c                                | 34 +++++++-----
 src/p_spec.c                                 | 58 +++++++++++---------
 3 files changed, 75 insertions(+), 43 deletions(-)

diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg
index 1ab8ba927..934e60962 100644
--- a/extras/conf/udb/Includes/SRB222_linedefs.cfg
+++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg
@@ -1825,9 +1825,20 @@ udmf
 			}
 			arg1
 			{
-				title = "Bobbing distance";
+				title = "Alpha";
+				default = 255;
 			}
 			arg2
+			{
+				title = "Cut cyan flat pixels?";
+				type = 11;
+				enum = "noyes";
+			}
+			arg3
+			{
+				title = "Bobbing distance";
+			}
+			arg4
 			{
 				title = "Flags";
 				type = 12;
@@ -1838,7 +1849,7 @@ udmf
 					4 = "Dynamic";
 				}
 			}
-			arg3
+			arg5
 			{
 				title = "Tangibility";
 				type = 12;
@@ -1856,6 +1867,17 @@ udmf
 				type = 13;
 			}
 			arg1
+			{
+				title = "Alpha";
+				default = 255;
+			}
+			arg2
+			{
+				title = "Cut cyan flat pixels?";
+				type = 11;
+				enum = "noyes";
+			}
+			arg3
 			{
 				title = "Tangibility";
 				type = 12;
diff --git a/src/p_setup.c b/src/p_setup.c
index 1c2550200..2eec9820a 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -3140,15 +3140,30 @@ static void P_ConvertBinaryMap(void)
 		case 152: //FOF: Reverse air bobbing (adjustable)
 		case 153: //FOF: Dynamically sinking platform
 			lines[i].args[0] = lines[i].tag;
-			lines[i].args[1] = (lines[i].special == 150) ? 16 : (P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS);
+			lines[i].args[1] = 255;
+			lines[i].args[2] = !!(lines[i].flags & ML_EFFECT6);
+			lines[i].args[3] = (lines[i].special == 150) ? 16 : (P_AproxDistance(lines[i].dx, lines[i].dy) >> FRACBITS);
 
 			//Flags
 			if (lines[i].special == 152)
-				lines[i].args[2] |= TMFB_REVERSE;
+				lines[i].args[4] |= TMFB_REVERSE;
 			if (lines[i].flags & ML_NOCLIMB)
-				lines[i].args[2] |= TMFB_SPINDASH;
+				lines[i].args[4] |= TMFB_SPINDASH;
 			if (lines[i].special == 153)
-				lines[i].args[2] |= TMFB_DYNAMIC;
+				lines[i].args[4] |= TMFB_DYNAMIC;
+
+			//Tangibility
+			if (lines[i].flags & ML_EFFECT1)
+				lines[i].args[5] |= TMFT_DONTBLOCKOTHERS;
+			if (lines[i].flags & ML_EFFECT2)
+				lines[i].args[5] |= TMFT_DONTBLOCKPLAYER;
+
+			lines[i].special = 150;
+			break;
+		case 160: //FOF: Water bobbing
+			lines[i].args[0] = lines[i].tag;
+			lines[i].args[1] = 255;
+			lines[i].args[2] = !!(lines[i].flags & ML_EFFECT6);
 
 			//Tangibility
 			if (lines[i].flags & ML_EFFECT1)
@@ -3156,17 +3171,6 @@ static void P_ConvertBinaryMap(void)
 			if (lines[i].flags & ML_EFFECT2)
 				lines[i].args[3] |= TMFT_DONTBLOCKPLAYER;
 
-			lines[i].special = 150;
-			break;
-		case 160: //FOF: Water bobbing
-			lines[i].args[0] = lines[i].tag;
-
-			//Tangibility
-			if (lines[i].flags & ML_EFFECT1)
-				lines[i].args[1] |= TMFT_DONTBLOCKOTHERS;
-			if (lines[i].flags & ML_EFFECT2)
-				lines[i].args[1] |= TMFT_DONTBLOCKPLAYER;
-
 			break;
 		case 170: //FOF: Crumbling, respawn
 		case 171: //FOF: Crumbling, no respawn
diff --git a/src/p_spec.c b/src/p_spec.c
index e03ec3205..6373478b8 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -6664,6 +6664,35 @@ void P_SpawnSpecials(boolean fromnetsave)
 			case 150: // FOF (Air bobbing)
 				ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL;
 
+				if (lines[i].args[2])
+					ffloorflags |= FF_SPLAT;
+
+				//Tangibility settings
+				if (lines[i].args[5] & TMFT_INTANGIBLETOP)
+					ffloorflags |= FF_REVERSEPLATFORM;
+				if (lines[i].args[5] & TMFT_INTANGIBLEBOTTOM)
+					ffloorflags |= FF_PLATFORM;
+				if (lines[i].args[5] & TMFT_DONTBLOCKPLAYER)
+					ffloorflags &= ~FF_BLOCKPLAYER;
+				if (lines[i].args[5] & TMFT_DONTBLOCKOTHERS)
+					ffloorflags &= ~FF_BLOCKOTHERS;
+
+				//If player can enter it, cut inner walls
+				if (lines[i].args[5] & TMFT_VISIBLEFROMINSIDE)
+					ffloorflags |= FF_CUTEXTRA|FF_EXTRA;
+				else
+					ffloorflags |= FF_CUTLEVEL;
+
+				P_AddFakeFloorsByLine(i, lines[i].args[1], ffloorflags, secthinkers);
+				P_AddAirbob(lines[i].frontsector, lines[i].args[0], lines[i].args[3] << FRACBITS, !!(lines[i].args[4] & TMFB_REVERSE), !!(lines[i].args[4] & TMFB_SPINDASH), !!(lines[i].args[4] & TMFB_DYNAMIC));
+				break;
+
+			case 160: // FOF (Water bobbing)
+				ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_FLOATBOB;
+
+				if (lines[i].args[2])
+					ffloorflags |= FF_SPLAT;
+
 				//Tangibility settings
 				if (lines[i].args[3] & TMFT_INTANGIBLETOP)
 					ffloorflags |= FF_REVERSEPLATFORM;
@@ -6674,31 +6703,8 @@ void P_SpawnSpecials(boolean fromnetsave)
 				if (lines[i].args[3] & TMFT_DONTBLOCKOTHERS)
 					ffloorflags &= ~FF_BLOCKOTHERS;
 
-				//If player can enter it, cut inner walls
-				if (lines[i].args[3] & TMFT_VISIBLEFROMINSIDE)
-					ffloorflags |= FF_CUTEXTRA|FF_EXTRA;
-				else
-					ffloorflags |= FF_CUTLEVEL;
-
-				P_AddFakeFloorsByLine(i, 0xff, ffloorflags, secthinkers);
-				P_AddAirbob(lines[i].frontsector, lines[i].args[0], lines[i].args[1] << FRACBITS, !!(lines[i].args[2] & TMFB_REVERSE), !!(lines[i].args[2] & TMFB_SPINDASH), !!(lines[i].args[2] & TMFB_DYNAMIC));
-				break;
-
-			case 160: // FOF (Water bobbing)
-				ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_FLOATBOB;
-
-				//Tangibility settings
-				if (lines[i].args[1] & TMFT_INTANGIBLETOP)
-					ffloorflags |= FF_REVERSEPLATFORM;
-				if (lines[i].args[1] & TMFT_INTANGIBLEBOTTOM)
-					ffloorflags |= FF_PLATFORM;
-				if (lines[i].args[1] & TMFT_DONTBLOCKPLAYER)
-					ffloorflags &= ~FF_BLOCKPLAYER;
-				if (lines[i].args[1] & TMFT_DONTBLOCKOTHERS)
-					ffloorflags &= ~FF_BLOCKOTHERS;
-
 				//If player can enter it, render insides
-				if (lines[i].args[1] & TMFT_VISIBLEFROMINSIDE)
+				if (lines[i].args[3] & TMFT_VISIBLEFROMINSIDE)
 				{
 					if (ffloorflags & FF_RENDERPLANES)
 						ffloorflags |= FF_BOTHPLANES;
@@ -6706,7 +6712,7 @@ void P_SpawnSpecials(boolean fromnetsave)
 						ffloorflags |= FF_ALLSIDES;
 				}
 
-				P_AddFakeFloorsByLine(i, 0xff, ffloorflags, secthinkers);
+				P_AddFakeFloorsByLine(i, lines[i].args[1], ffloorflags, secthinkers);
 				break;
 
 			case 170: // FOF (Crumbling)
@@ -6927,7 +6933,7 @@ void P_SpawnSpecials(boolean fromnetsave)
 				break;
 
 			case 258: // Laser block
-				ffloorflags = FF_EXISTS|FF_RENDERALL|FF_NOSHADE|FF_EXTRA|FF_CUTEXTRA|FF_TRANSLUCENT;
+				ffloorflags = FF_EXISTS|FF_RENDERALL|FF_NOSHADE|FF_EXTRA|FF_CUTEXTRA;
 				P_AddLaserThinker(lines[i].args[0], lines + i, !!(lines[i].args[2] & TMFL_NOBOSSES));
 				if (lines[i].args[2] & TMFL_SPLAT)
 					ffloorflags |= FF_SPLAT;