From 7198cc46fd23947a914642ed619a4e4de38f6315 Mon Sep 17 00:00:00 2001
From: MascaraSnake <jonassauer27@gmail.com>
Date: Mon, 27 Apr 2020 11:05:27 +0200
Subject: [PATCH] Adapt setup of water bobbing FOF

---
 extras/conf/udb/Includes/SRB222_linedefs.cfg | 19 ++++++++++++-
 src/p_setup.c                                | 10 +++++++
 src/p_spec.c                                 | 29 +++++++++++++++++---
 3 files changed, 53 insertions(+), 5 deletions(-)

diff --git a/extras/conf/udb/Includes/SRB222_linedefs.cfg b/extras/conf/udb/Includes/SRB222_linedefs.cfg
index d7f9048695..96e7116412 100644
--- a/extras/conf/udb/Includes/SRB222_linedefs.cfg
+++ b/extras/conf/udb/Includes/SRB222_linedefs.cfg
@@ -397,7 +397,7 @@ doom
 		}
 		160
 		{
-			title = "Floating, Bobbing";
+			title = "Water Bobbing";
 			prefix = "(160)";
 		}
 		190
@@ -1615,6 +1615,23 @@ udmf
 			}
 		}
 
+		160
+		{
+			title = "Water Bobbing";
+			prefix = "(160)";
+			arg0
+			{
+				title = "Target sector tag";
+				type = 13;
+			}
+			arg1
+			{
+				title = "Tangibility";
+				type = 12;
+				enum = "tangibility";
+			}
+		}
+
 		170
 		{
 			title = "Crumbling";
diff --git a/src/p_setup.c b/src/p_setup.c
index 844e50972a..30e5729823 100644
--- a/src/p_setup.c
+++ b/src/p_setup.c
@@ -2954,6 +2954,16 @@ static void P_ConvertBinaryMap(void)
 
 			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
 		case 172: //FOF: Crumbling, respawn, intangible from bottom
diff --git a/src/p_spec.c b/src/p_spec.c
index 3522823164..86bc46f699 100644
--- a/src/p_spec.c
+++ b/src/p_spec.c
@@ -6734,7 +6734,7 @@ void P_SpawnSpecials(boolean fromnetsave)
 				P_AddFakeFloorsByLine(i, ffloorflags, secthinkers);
 				break;
 
-			case 150: // Air bobbing platform
+			case 150: // FOF (Air bobbing)
 				ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL;
 
 				//Tangibility settings
@@ -6757,11 +6757,32 @@ void P_SpawnSpecials(boolean fromnetsave)
 				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
-				P_AddFakeFloorsByLine(i, FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CUTLEVEL|FF_FLOATBOB, secthinkers);
+			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 (ffloorflags & FF_RENDERPLANES)
+						ffloorflags |= FF_BOTHPLANES;
+					if (ffloorflags & FF_RENDERSIDES)
+						ffloorflags |= FF_ALLSIDES;
+				}
+
+				P_AddFakeFloorsByLine(i, ffloorflags, secthinkers);
 				break;
 
-			case 170: // Crumbling platform
+			case 170: // FOF (Crumbling)
 				ffloorflags = FF_EXISTS|FF_SOLID|FF_RENDERALL|FF_CRUMBLE;
 
 				//Tangibility settings
-- 
GitLab