From aac2a46e78757631e47aa8f5c6b24422f7ca13c9 Mon Sep 17 00:00:00 2001
From: spherallic <spherallic@gmail.com>
Date: Mon, 8 May 2023 13:35:44 +0200
Subject: [PATCH] Correct some player height checks for SRB2

---
 Source/Core/Editing/ClassicMode.cs    | 3 ++-
 Source/Core/VisualModes/VisualMode.cs | 7 ++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Source/Core/Editing/ClassicMode.cs b/Source/Core/Editing/ClassicMode.cs
index 31832ebc..7a9725dc 100644
--- a/Source/Core/Editing/ClassicMode.cs
+++ b/Source/Core/Editing/ClassicMode.cs
@@ -718,7 +718,8 @@ namespace CodeImp.DoomBuilder.Editing
 				}
 
 				//41 = player's height in Doom. Is that so in all other games as well?
-				if (s.CeilHeight - s.FloorHeight < 41)
+				//Nope, standard player height is 48 in SRB2
+				if (s.CeilHeight - s.FloorHeight < 48)
 				{
 					General.MainWindow.DisplayStatus(StatusType.Warning, "Can't test from current position: sector is too low!");
 					return false;
diff --git a/Source/Core/VisualModes/VisualMode.cs b/Source/Core/VisualModes/VisualMode.cs
index 63c239d2..b62842fd 100644
--- a/Source/Core/VisualModes/VisualMode.cs
+++ b/Source/Core/VisualModes/VisualMode.cs
@@ -191,10 +191,10 @@ namespace CodeImp.DoomBuilder.VisualModes
 					if(nearestsector != null)
 					{
 						int sectorheight = nearestsector.CeilHeight - nearestsector.FloorHeight;
-						if(sectorheight < 41)
+						if(sectorheight < 48)
 							posz = nearestsector.FloorHeight + Math.Max(16, sectorheight / 2);
 						else if(General.Map.VisualCamera.Position.z < nearestsector.FloorHeight + 41)
-							posz = nearestsector.FloorHeight + 41; // same as in doom
+							posz = nearestsector.FloorHeight + 48; // same as in ~~doom~~ SRB2
 						else if(General.Map.VisualCamera.Position.z > nearestsector.CeilHeight)
 							posz = nearestsector.CeilHeight - 4;
 					}
@@ -322,7 +322,8 @@ namespace CodeImp.DoomBuilder.VisualModes
 				}
 
 				//41 = player's height in Doom. Is that so in all other games as well?
-				if(s.CeilHeight - s.FloorHeight < 41) 
+				//Nope, standard player height is 48 in SRB2
+				if (s.CeilHeight - s.FloorHeight < 48) 
 				{
 					General.MainWindow.DisplayStatus(StatusType.Warning, "Can't test from current position: sector is too low!");
 					return false;
-- 
GitLab