From 787afd0553e80bf34503f32c929a70d2dd0593db Mon Sep 17 00:00:00 2001
From: spherallic <spherallic@gmail.com>
Date: Fri, 5 Apr 2024 15:10:51 +0200
Subject: [PATCH] Enable rudimentary 3D floor mode support

---
 Build/Configurations/Includes/SRB222_common.cfg      |  4 ++++
 Source/Plugins/3DFloorMode/BuilderPlug.cs            |  4 ++--
 .../3DFloorMode/Controls/ThreeDFloorControl.cs       | 12 ++++++------
 Source/Plugins/3DFloorMode/ThreeDFloor.cs            | 12 ++++++------
 Source/Plugins/3DFloorMode/ThreeDFloorMode.cs        |  1 +
 5 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/Build/Configurations/Includes/SRB222_common.cfg b/Build/Configurations/Includes/SRB222_common.cfg
index 90c85cdea..cc1a0b5ba 100644
--- a/Build/Configurations/Includes/SRB222_common.cfg
+++ b/Build/Configurations/Includes/SRB222_common.cfg
@@ -100,6 +100,10 @@ mapformat_udmf
 	// Disable Doom-related modes that don't make sense for SRB2
 	soundsupport = false;
 	automapsupport = false;
+	
+	// Enables support for 3D floors (not really, since support for 3D floors is pretty much hard-coded, but
+	// this tells plugins that the game supports 3D floors)
+	effect3dfloorsupport = true;
 
 	// When this is set to true, sectors with the same tag will light up when a line is highlighted
 	linetagindicatesectors = false;
diff --git a/Source/Plugins/3DFloorMode/BuilderPlug.cs b/Source/Plugins/3DFloorMode/BuilderPlug.cs
index 102d7d9c2..08254b428 100644
--- a/Source/Plugins/3DFloorMode/BuilderPlug.cs
+++ b/Source/Plugins/3DFloorMode/BuilderPlug.cs
@@ -197,7 +197,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
 		{
 			base.OnMapNewEnd();
 
-			controlsectorarea = new ControlSectorArea(-512, 0, 512, 0, 64, 56);
+			controlsectorarea = new ControlSectorArea(-512, 0, 512, 0, 32, 28);
 			BuilderPlug.Me.ControlSectorArea.LoadConfig();
 
 			slopevertexgroups.Clear();
@@ -209,7 +209,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
 		{
 			base.OnMapOpenEnd();
 
-			controlsectorarea = new ControlSectorArea(-512, 0, 512, 0, 64, 56);
+			controlsectorarea = new ControlSectorArea(-512, 0, 512, 0, 32, 28);
 			BuilderPlug.Me.ControlSectorArea.LoadConfig();
 
 			// Try to find the slope data sector and store slope information in it
diff --git a/Source/Plugins/3DFloorMode/Controls/ThreeDFloorControl.cs b/Source/Plugins/3DFloorMode/Controls/ThreeDFloorControl.cs
index 891c32bb6..802539b95 100644
--- a/Source/Plugins/3DFloorMode/Controls/ThreeDFloorControl.cs
+++ b/Source/Plugins/3DFloorMode/Controls/ThreeDFloorControl.cs
@@ -78,9 +78,9 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
 			sectorCeilingHeight.Text = General.Settings.DefaultCeilingHeight.ToString();
 			sectorFloorHeight.Text = General.Settings.DefaultFloorHeight.ToString();
 
-			typeArgument.Setup(General.Map.Config.LinedefActions[160].Args[1]);
-			flagsArgument.Setup(General.Map.Config.LinedefActions[160].Args[2]);
-			alphaArgument.Setup(General.Map.Config.LinedefActions[160].Args[3]);
+			typeArgument.Setup(General.Map.Config.LinedefActions[100].Args[4]);
+			flagsArgument.Setup(General.Map.Config.LinedefActions[100].Args[3]);
+			alphaArgument.Setup(General.Map.Config.LinedefActions[100].Args[1]);
 
 			typeArgument.SetDefaultValue();
 			flagsArgument.SetDefaultValue();
@@ -161,9 +161,9 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
 			sectorFloorHeight.Text = threeDFloor.BottomHeight.ToString();
 			borderHeightLabel.Text = (threeDFloor.TopHeight - threeDFloor.BottomHeight).ToString();
 
-			typeArgument.Setup(General.Map.Config.LinedefActions[160].Args[1]);
-			flagsArgument.Setup(General.Map.Config.LinedefActions[160].Args[2]);
-			alphaArgument.Setup(General.Map.Config.LinedefActions[160].Args[3]);
+			typeArgument.Setup(General.Map.Config.LinedefActions[100].Args[4]);
+			flagsArgument.Setup(General.Map.Config.LinedefActions[100].Args[3]);
+			alphaArgument.Setup(General.Map.Config.LinedefActions[100].Args[1]);
 
 			typeArgument.SetValue(threeDFloor.Type);
 			flagsArgument.SetValue(threeDFloor.Flags);
diff --git a/Source/Plugins/3DFloorMode/ThreeDFloor.cs b/Source/Plugins/3DFloorMode/ThreeDFloor.cs
index 440814067..932c6f742 100644
--- a/Source/Plugins/3DFloorMode/ThreeDFloor.cs
+++ b/Source/Plugins/3DFloorMode/ThreeDFloor.cs
@@ -136,9 +136,9 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
 				{
 					bordertexture = sd.MiddleTexture;
 					udmftag = sd.Line.Args[0];
-					type = sd.Line.Args[1];
-					flags = sd.Line.Args[2];
-					alpha = sd.Line.Args[3];
+					type = sd.Line.Args[4];
+					flags = sd.Line.Args[3];
+					alpha = sd.Line.Args[1];
 					linedefproperties = new LinedefProperties(sd.Line);
 					sectorproperties = new SectorProperties(sector);
 
@@ -199,9 +199,9 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
 
 			line.Action = 100;
 			line.Args[0] = tag;
-			line.Args[1] = type;
-			line.Args[2] = flags;
-			line.Args[3] = alpha;
+			line.Args[4] = type;
+			line.Args[3] = flags;
+			line.Args[1] = alpha;
 		}
 
 		public void UpdateGeometry()
diff --git a/Source/Plugins/3DFloorMode/ThreeDFloorMode.cs b/Source/Plugins/3DFloorMode/ThreeDFloorMode.cs
index 823d53021..529205a2d 100644
--- a/Source/Plugins/3DFloorMode/ThreeDFloorMode.cs
+++ b/Source/Plugins/3DFloorMode/ThreeDFloorMode.cs
@@ -46,6 +46,7 @@ namespace CodeImp.DoomBuilder.ThreeDFloorMode
 			  RequiredMapFeatures = new[] { "Effect3DFloorSupport" },
 			  UseByDefault = true,
 			  SafeStartMode = false,
+			  Optional = false,
 			  Volatile = false)]
 
 	public class ThreeDFloorHelperMode : ClassicMode
-- 
GitLab