Skip to content

Commit c093c80

Browse files
authored
Merge pull request #212 from marchc1/bsp-improvements
Change BSP constants to what Garry's Mod uses
2 parents 452c789 + 5d7ca27 commit c093c80

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎Source.Common/Formats/BSP/BSPFile.cs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ public static class BSPFileCommon
3232
public const int MAX_DISP_CORNER_NEIGHBORS = 4;
3333

3434
public const int MAX_MAP_MODELS = 4096;
35-
public const int MAX_MAP_BRUSHES = 16384;
35+
public const int MAX_MAP_BRUSHES = 65535;
3636
public const int MAX_MAP_ENTITIES = 8192;
3737
public const int MAX_MAP_TEXINFO = 32768;
3838
public const int MAX_MAP_TEXDATA = 8192;
39-
public const int MAX_MAP_DISPINFO = 2048;
39+
public const int MAX_MAP_DISPINFO = 16384;
4040
public const int MAX_MAP_DISP_VERTS = (MAX_MAP_DISPINFO * ((1 << MAX_MAP_DISP_POWER) + 1) * ((1 << MAX_MAP_DISP_POWER) + 1));
4141
public const int MAX_MAP_DISP_TRIS = ((1 << MAX_MAP_DISP_POWER) * (1 << MAX_MAP_DISP_POWER) * 2);
4242
public const int MAX_DISPVERTS = ((1 << MAX_MAP_DISP_POWER) + 1) * ((1 << MAX_MAP_DISP_POWER) + 1);
@@ -46,7 +46,7 @@ public static class BSPFileCommon
4646
public const int MAX_MAP_AREAPORTALS = 1024;
4747
public const int MAX_MAP_PLANES = 65536;
4848
public const int MAX_MAP_NODES = 65536;
49-
public const int MAX_MAP_BRUSHSIDES = 163840;
49+
public const int MAX_MAP_BRUSHSIDES = 655350;
5050
public const int MAX_MAP_LEAFS = 65536;
5151
public const int MAX_MAP_VERTS = 65536;
5252
public const int MAX_MAP_VERTNORMALS = 256000;
@@ -62,7 +62,7 @@ public static class BSPFileCommon
6262
public const int MAX_MAP_SURFEDGES = 512000;
6363
public const int MAX_MAP_LIGHTING = 0x1000000;
6464
public const int MAX_MAP_VISIBILITY = 0x1000000;
65-
public const int MAX_MAP_TEXTURES = 1024;
65+
public const int MAX_MAP_TEXTURES = 8192;
6666
public const int MAX_MAP_WORLDLIGHTS = 8192;
6767
public const int MAX_MAP_CUBEMAPSAMPLES = 1024;
6868
public const int MAX_MAP_OVERLAYS = 8192;

‎Source.Engine/DispMapload.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ public static bool DispInfo_LoadDisplacements(Model world, MaterialSystem_SortIn
375375

376376
DispInfo_ReleaseMaterialSystemObjects(world);
377377

378-
Span<BSPDDispInfo> tempDisps = stackalloc BSPDDispInfo[BSPFileCommon.MAX_MAP_DISPINFO];
378+
ErrorIfNot(numDisplacements <= BSPFileCommon.MAX_MAP_DISPINFO, $"DispInfo_LoadDisplacements: too many displacements ({numDisplacements})");
379+
Span<BSPDDispInfo> tempDisps = new BSPDDispInfo[numDisplacements];
379380
dispInfos.LoadLumpData(tempDisps);
380381

381382
DispInfo_LinkToParentFaces(world, tempDisps, numDisplacements);

0 commit comments

Comments
 (0)