From 607aeb3a525cad0e1fc1f5a957c6405aa105f09d Mon Sep 17 00:00:00 2001
From: MascaraSnake <jonassauer27@gmail.com>
Date: Mon, 27 Apr 2020 10:29:29 +0200
Subject: [PATCH] Adapt setup of air bobbing FOFs

---
 extras/conf/udb/Includes/SRB222_linedefs.cfg | 32 ++++++++++++++++++
 src/p_setup.c                                | 14 ++++++++
 src/p_spec.c                                 | 34 ++++++++++++--------
 src/p_spec.h                                 |  7 ++++
 4 files changed, 73 insertions(+), 14 deletions(-)

diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg
index 506dd15152..d7f9048695 100644
--- a/extras/conf/udb/Includes/SRB222_linedefs.cfg
+++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg
@@ -1583,6 +1583,38 @@ udmf
 			}
 		}
 
+		150
+		{
+			title = "Air Bobbing";
+			prefix = "(150)";
+			arg0
+			{
+				title = "Target sector tag";
+				type = 13;
+			}
+			arg1
+			{
+				title = "Bobbing distance";
+			}
+			arg2
+			{
+				title = "Flags";
+				type = 12;
+				enum
+				{
+					1 = "Raise";
+					2 = "Require spindash";
+					4 = "Dynamic";
+				}
+			}
+			arg3
+			{
+				title = "Tangibility";
+				type = 12;
+				enum = "tangibility";
+			}
+		}
+
 		170
 		{
 			title = "Crumbling";
diff --git a/src/p_setup.c b/src/p_setup.c
index 10b3ae80b4..d8c65f1b88 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -2931,6 +2931,20 @@ static void P_ConvertBinaryMap(void)
 
 			lines[i].special = 100;
 			break;
+		case 150: //FOF: Air bobbing
+		case 151: //FOF: Air bobbing (adjustable)
+		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*FRACUNIT : P_AproxDistance(lines[i].dx, lines[i].dy);
+			if (lines[i].special == 152)
+				lines[i].args[2] |= TMFB_REVERSE;
+			if (lines[i].flags & ML_NOCLIMB)
+				lines[i].args[2] |= TMFB_SPINDASH;
+			if (lines[i].special == 153)
+				lines[i].args[3] |= TMFB_DYNAMIC;
+			lines[i].special = 150;
+			break;
 		case 170: //FOF: Crumbling, respawn
 		case 171: //FOF: Crumbling, no respawn
 		case 172: //FOF: Crumbling, respawn, intangible from bottom
diff --git a/src/p_spec.c b/src/p_spec.c
index b564d4557e..3522823164 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -6735,20 +6735,26 @@ void P_SpawnSpecials(boolean fromnetsave)
 				break;
 
 			case 150: // Air bobbing platform
-			case 151: // Adjustable air bobbing platform
-			{
-				fixed_t dist = (lines[i].special == 150) ? 16*FRACUNIT : P_AproxDistance(lines[i].dx, lines[i].dy);
-				P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
-				P_AddAirbob(lines[i].frontsector, lines + i, dist, false, !!(lines[i].flags & ML_NOCLIMB), false);
-				break;
-			}
-			case 152: // Adjustable air bobbing platform in reverse
-				P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
-				P_AddAirbob(lines[i].frontsector, lines + i, P_AproxDistance(lines[i].dx, lines[i].dy), true, !!(lines[i].flags & ML_NOCLIMB), false);
-				break;
-			case 153: // Dynamic Sinking Platform
-				P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL, secthinkers);
-				P_AddAirbob(lines[i].frontsector, lines + i, P_AproxDistance(lines[i].dx, lines[i].dy), false, !!(lines[i].flags & ML_NOCLIMB), true);
+				ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL;
+
+				//Tangibility settings
+				if (lines[i].args[3] & TMFT_INTANGIBLETOP)
+					ffloorflags |= FF_REVERSEPLATFORM;
+				if (lines[i].args[3] & TMFT_INTANGIBLEBOTTOM)
+					ffloorflags |= FF_PLATFORM;
+				if (lines[i].args[3] & TMFT_DONTBLOCKPLAYER)
+					ffloorflags &= ~FF_BLOCKPLAYER;
+				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, ffloorflags, secthinkers);
+				P_AddAirbob(lines[i].frontsector, lines + i, lines[i].args[1], !!(lines[i].args[2] & TMFB_REVERSE), !!(lines[i].args[2] & TMFB_SPINDASH), !!(lines[i].args[2] & TMFB_DYNAMIC));
 				break;
 
 			case 160: // Float/bob platform
diff --git a/src/p_spec.h b/src/p_spec.h
index 34f3c40688..cd3e8f737a 100644
--- a/src/p_spec.h
+++ b/src/p_spec.h
@@ -54,6 +54,13 @@ typedef enum
 	TMFW_GOOWATER     = 1<<5,
 } textmapfofwater_t;
 
+typedef enum
+{
+	TMFB_REVERSE  = 1,
+	TMFB_SPINDASH = 1<<1,
+	TMFB_DYNAMIC  = 1<<2,
+} textmapfofbobbing_t;
+
 typedef enum
 {
 	TMFC_TRANSLUCENT = 1,
-- 
GitLab