From 20bbd1814b072d79e70a1af8bdf22dce6d8ba549 Mon Sep 17 00:00:00 2001 From: march <106459595+marchc1@users.noreply.github.com> Date: Sun, 18 Oct 2026 15:31:26 -0700 Subject: [PATCH 1/2] Change BSP constants to what Garry's Mod uses --- Source.Common/Formats/BSP/BSPFile.cs | 6 +++--- Source.Engine/DispMapload.cs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source.Common/Formats/BSP/BSPFile.cs b/Source.Common/Formats/BSP/BSPFile.cs index 1f211ebe0..1fd84cb26 100644 --- a/Source.Common/Formats/BSP/BSPFile.cs +++ b/Source.Common/Formats/BSP/BSPFile.cs @@ -32,11 +32,11 @@ public static class BSPFileCommon public const int MAX_DISP_CORNER_NEIGHBORS = 4; public const int MAX_MAP_MODELS = 4096; - public const int MAX_MAP_BRUSHES = 16384; + public const int MAX_MAP_BRUSHES = 65535; public const int MAX_MAP_ENTITIES = 8192; public const int MAX_MAP_TEXINFO = 32768; public const int MAX_MAP_TEXDATA = 8192; - public const int MAX_MAP_DISPINFO = 2048; + public const int MAX_MAP_DISPINFO = 16384; public const int MAX_MAP_DISP_VERTS = (MAX_MAP_DISPINFO * ((1 << MAX_MAP_DISP_POWER) + 1) * ((1 << MAX_MAP_DISP_POWER) + 1)); public const int MAX_MAP_DISP_TRIS = ((1 << MAX_MAP_DISP_POWER) * (1 << MAX_MAP_DISP_POWER) * 2); public const int MAX_DISPVERTS = ((1 << MAX_MAP_DISP_POWER) + 1) * ((1 << MAX_MAP_DISP_POWER) + 1); @@ -62,7 +62,7 @@ public static class BSPFileCommon public const int MAX_MAP_SURFEDGES = 512000; public const int MAX_MAP_LIGHTING = 0x1000000; public const int MAX_MAP_VISIBILITY = 0x1000000; - public const int MAX_MAP_TEXTURES = 1024; + public const int MAX_MAP_TEXTURES = 8192; public const int MAX_MAP_WORLDLIGHTS = 8192; public const int MAX_MAP_CUBEMAPSAMPLES = 1024; public const int MAX_MAP_OVERLAYS = 8192; diff --git a/Source.Engine/DispMapload.cs b/Source.Engine/DispMapload.cs index 1c80655ee..ac158bb95 100644 --- a/Source.Engine/DispMapload.cs +++ b/Source.Engine/DispMapload.cs @@ -375,7 +375,8 @@ public static bool DispInfo_LoadDisplacements(Model world, MaterialSystem_SortIn DispInfo_ReleaseMaterialSystemObjects(world); - Span tempDisps = stackalloc BSPDDispInfo[BSPFileCommon.MAX_MAP_DISPINFO]; + ErrorIfNot(numDisplacements <= BSPFileCommon.MAX_MAP_DISPINFO, $"DispInfo_LoadDisplacements: too many displacements ({numDisplacements})"); + Span tempDisps = new BSPDDispInfo[numDisplacements]; dispInfos.LoadLumpData(tempDisps); DispInfo_LinkToParentFaces(world, tempDisps, numDisplacements); From 5d7ca27a146096429fbfaf61dc112bb13e2fcef6 Mon Sep 17 00:00:00 2001 From: march <106459595+marchc1@users.noreply.github.com> Date: Sun, 18 Oct 2026 18:56:59 -0700 Subject: [PATCH 2/2] BRUSHSIDES -> 655350 --- Source.Common/Formats/BSP/BSPFile.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source.Common/Formats/BSP/BSPFile.cs b/Source.Common/Formats/BSP/BSPFile.cs index 1fd84cb26..45a17c2fd 100644 --- a/Source.Common/Formats/BSP/BSPFile.cs +++ b/Source.Common/Formats/BSP/BSPFile.cs @@ -46,7 +46,7 @@ public static class BSPFileCommon public const int MAX_MAP_AREAPORTALS = 1024; public const int MAX_MAP_PLANES = 65536; public const int MAX_MAP_NODES = 65536; - public const int MAX_MAP_BRUSHSIDES = 163840; + public const int MAX_MAP_BRUSHSIDES = 655350; public const int MAX_MAP_LEAFS = 65536; public const int MAX_MAP_VERTS = 65536; public const int MAX_MAP_VERTNORMALS = 256000;