From 2292bd9b3ed54e39eb308ab38578ace30baa425c Mon Sep 17 00:00:00 2001 From: wfowler Date: Fri, 16 Apr 2021 01:59:06 -0600 Subject: [PATCH] Daikatana has 21 lumps, not 16. Add MOHAA lump referencing static models from leaves. --- LibBSP/Source/Structs/BSP/BSP.cs | 22 ++++++++++++++++++- LibBSP/Source/Structs/Common/Lumps/NumList.cs | 17 ++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/LibBSP/Source/Structs/BSP/BSP.cs b/LibBSP/Source/Structs/BSP/BSP.cs index 4ddfd11..d1a64f2 100644 --- a/LibBSP/Source/Structs/BSP/BSP.cs +++ b/LibBSP/Source/Structs/BSP/BSP.cs @@ -102,6 +102,7 @@ namespace LibBSP { // MoHAA private Lump _lodTerrains; private Lump _staticModels; + private NumList _leafStaticModels; // CoD private Lump _patches; private Lump _patchVerts; @@ -495,6 +496,23 @@ namespace LibBSP { } } + /// + /// A object containing the Leaf Static Models lump, if available. + /// These are a list of MOHAA static model indices, referenced by leaves. + /// + public NumList leafStaticModels { + get { + if (_leafStaticModels == null) { + NumList.DataType type; + int index = NumList.GetIndexForLeafStaticModelsLump(version, out type); + if (index >= 0) { + _leafStaticModels = NumList.LumpFactory(reader.ReadLump(this[index]), type, this, this[index]); + } + } + return _leafStaticModels; + } + } + /// /// A of objects in the BSP file, if available. /// @@ -727,7 +745,6 @@ namespace LibBSP { case MapType.Quake: { return 15; } - case MapType.Daikatana: case MapType.Quake2: { return 16; } @@ -742,6 +759,9 @@ namespace LibBSP { case MapType.SiN: { return 20; } + case MapType.Daikatana: { + return 21; + } case MapType.SoF: { return 22; } diff --git a/LibBSP/Source/Structs/Common/Lumps/NumList.cs b/LibBSP/Source/Structs/Common/Lumps/NumList.cs index 0b10af5..50e7745 100644 --- a/LibBSP/Source/Structs/Common/Lumps/NumList.cs +++ b/LibBSP/Source/Structs/Common/Lumps/NumList.cs @@ -344,6 +344,23 @@ namespace LibBSP { return -1; } + /// + /// Gets the index for the leaf static models indices lump in the BSP file for a specific map format, and the type of data the format uses. + /// + /// The map type. + /// out parameter that will contain the data type this version uses. + /// Index for this lump, or -1 if the format doesn't have this lump or it's not implemented. + public static int GetIndexForLeafStaticModelsLump(MapType version, out DataType dataType) { + switch (version) { + case MapType.MOHAA: { + dataType = DataType.UInt16; + return 26; + } + } + dataType = DataType.Invalid; + return -1; + } + /// /// Gets the index for the texture table lump in the BSP file for a specific map format, and the type of data the format uses. ///