9 Commits
1.5.2 ... 1.5.4

Author SHA1 Message Date
Matt Nadareski
6b0c4c3024 Bump version 2024-11-27 21:15:05 -05:00
Matt Nadareski
4b54d0f4dc Fix build 2024-11-27 21:09:01 -05:00
Matt Nadareski
2bc1cfc5d0 Cleanup from issues in Serialization 2024-11-27 21:03:50 -05:00
Matt Nadareski
362abfdc64 Remove layout from CopyrightRecord 2024-11-27 10:38:58 -05:00
Matt Nadareski
a06ff8f8b3 Bump version 2024-11-20 14:03:14 -05:00
Matt Nadareski
7269e91913 Partially add VBSP lump 40 2024-11-19 14:34:32 -05:00
Matt Nadareski
c118271565 Add VBSP lump 29 2024-11-19 14:30:54 -05:00
Matt Nadareski
71ccbc6ab1 Fix issues found during Serialization update 2024-11-19 12:47:09 -05:00
Matt Nadareski
ed5c1a7173 Use array-of-array instead of multidimensional array 2024-11-18 23:35:47 -05:00
37 changed files with 201 additions and 69 deletions

View File

@@ -5,7 +5,6 @@ namespace SabreTools.Models.AACS
/// <summary>
/// This record type is undocumented but found in real media key blocks
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public sealed class CopyrightRecord : Record
{
/// <summary>

View File

@@ -1,3 +1,5 @@
using System.Runtime.InteropServices;
namespace SabreTools.Models.BDPlus
{
/// <see href="https://github.com/mwgoldsmith/bdplus/blob/master/src/libbdplus/bdsvm/loader.c"/>
@@ -6,40 +8,39 @@ namespace SabreTools.Models.BDPlus
/// <summary>
/// "BDSVM_CC"
/// </summary>
/// <remarks>8 bytes</remarks>
public string? Signature { get; set; }
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 8)]
public string? Signature;
/// <summary>
/// Unknown data
/// </summary>
/// <remarks>5 bytes</remarks>
public byte[]? Unknown1 { get; set; }
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 5)]
public byte[]? Unknown1 = new byte[5];
/// <summary>
/// Version year
/// </summary>
public ushort Year { get; set; }
public ushort Year;
/// <summary>
/// Version month
/// </summary>
public byte Month { get; set; }
public byte Month;
/// <summary>
/// Version day
/// </summary>
public byte Day { get; set; }
public byte Day;
/// <summary>
/// Unknown data
/// </summary>
/// <remarks>4 bytes</remarks>
public byte[]? Unknown2 { get; set; }
public uint Unknown2;
/// <summary>
/// Length
/// </summary>
public uint Length { get; set; }
public uint Length;
/// <summary>
/// Length bytes of data

View File

@@ -34,6 +34,11 @@ namespace SabreTools.Models.BSP
/// </summary>
public VerticesLump? VerticesLump { get; set; }
/// <summary>
/// LUMP_VISIBILITY [4]
/// </summary>
public VisibilityLump? VisibilityLump { get; set; }
/// <summary>
/// LUMP_NODES [5]
/// </summary>

View File

@@ -17,6 +17,7 @@ namespace SabreTools.Models.BSP
/// Lumps
/// </summary>
/// <remarks>15 entries</remarks>
public BspLumpEntry[]? Lumps { get; set; }
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Constants.BSP_HEADER_LUMPS)]
public BspLumpEntry[]? Lumps;
}
}

View File

@@ -27,17 +27,17 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Defines bounding box
/// </summary>
public Vector3D Mins;
public Vector3D? Mins;
/// <summary>
/// Defines bounding box
/// </summary>
public Vector3D Maxs;
public Vector3D? Maxs;
/// <summary>
/// Coordinates to move the coordinate system
/// </summary>
public Vector3D OriginVector;
public Vector3D? OriginVector;
/// <summary>
/// Index into nodes array

View File

@@ -22,7 +22,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// S-vector
/// </summary>
public Vector3D SVector;
public Vector3D? SVector;
/// <summary>
/// Texture shift in the S direction
@@ -32,7 +32,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// T-vector
/// </summary>
public Vector3D TVector;
public Vector3D? TVector;
/// <summary>
/// Texture shift in the T direction

View File

@@ -7,7 +7,7 @@ namespace SabreTools.Models.BSP
/// </summary>
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
[StructLayout(LayoutKind.Sequential)]
public struct ColorRGBExp32
public class ColorRGBExp32
{
public byte Red;

View File

@@ -8,7 +8,7 @@ namespace SabreTools.Models.BSP
/// </summary>
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
[StructLayout(LayoutKind.Sequential)]
public struct CompressedLightCube
public class CompressedLightCube
{
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
public ColorRGBExp32[]? Colors;

View File

@@ -25,7 +25,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Start position used for orientation
/// </summary>
public Vector3D startPosition;
public Vector3D? StartPosition;
/// <summary>
/// Index into LUMP_DISP_VERTS.

View File

@@ -18,7 +18,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Vector field defining displacement volume.
/// </summary>
public Vector3D Vec;
public Vector3D? Vec;
/// <summary>
/// Displacement distances.

View File

@@ -16,7 +16,7 @@ namespace SabreTools.Models.BSP
[StructLayout(LayoutKind.Sequential)]
public sealed class LeafAmbientLighting
{
public CompressedLightCube Cube;
public CompressedLightCube? Cube;
/// <summary>
/// Fixed point fraction of leaf bounds

View File

@@ -13,6 +13,6 @@ namespace SabreTools.Models.BSP
/// Lightmap RGB values
/// </summary>
/// <remarks>Array of 3-byte values</remarks>
public byte[,]? Lightmap { get; set; }
public byte[][]? Lightmap { get; set; }
}
}

View File

@@ -27,12 +27,12 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Minima of all vertices
/// </summary>
public Vector3D Mins;
public Vector3D? Mins;
/// <summary>
/// Maxima of all vertices
/// </summary>
public Vector3D Maxs;
public Vector3D? Maxs;
/// <remarks>Since v1</remarks>
public int Area;

View File

@@ -41,6 +41,6 @@ namespace SabreTools.Models.BSP
/// <summary>
/// <see cref="VertexIndexCount">
/// </summary>
public int[]? VertexIndices;
public int[]? VertexIndicies;
}
}

View File

@@ -41,8 +41,8 @@ namespace SabreTools.Models.BSP
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
public Vector3D[]? UVPoints = new Vector3D[4];
public Vector3D Origin;
public Vector3D? Origin;
public Vector3D BasisNormal;
public Vector3D? BasisNormal;
}
}

View File

@@ -0,0 +1,43 @@
namespace SabreTools.Models.BSP
{
/// <summary>
/// The Pakfile lump (Lump 40) is a special lump that can contains
/// multiple files which are embedded into the bsp file. Usually,
/// they contain special texture (.vtf) and material (.vmt) files
/// which are used to store the reflection maps from env_cubemap
/// entities in the map; these files are built and placed in the
/// Pakfile lump when the buildcubemaps console command is executed.
/// The Pakfile can optionally contain such things as custom textures
/// and prop models used in the map, and are placed into the bsp file
/// by using the BSPZIP program (or alternate programs such as Pakrat).
/// These files are integrated into the game engine's file system
/// and will be loaded preferentially before externally located
/// files are used.
///
/// The format of the Pakfile lump is identical to that used by the
/// Zip compression utility when no compression is specified (i.e.,
/// the individual files are stored in uncompressed format). In some
/// branches, such as , LZMA compression can be used as well. If the
/// Pakfile lump is extracted and written to a file, it can therefore
/// be opened with WinZip and similar programs.
///
/// The header public/zip_uncompressed.h defines the structures
/// present in the Pakfile lump. The last element in the lump is a
/// ZIP_EndOfCentralDirRecord structure. This points to an array of
/// ZIP_FileHeader structures immediately preceeding it, one for each
/// file present in the Pak. Each of these headers then point to
/// ZIP_LocalFileHeader structures that are followed by that file's
/// data.
///
/// The Pakfile lump is usually the last element of the bsp file.
/// </summary>
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
public sealed class PakfileLump
{
/// <summary>
/// Pakfile data
/// </summary>
/// TODO: Split and/or decompress data?
public byte[]? Data;
}
}

View File

@@ -0,0 +1,11 @@
namespace SabreTools.Models.BSP
{
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
public sealed class PhysCollideLump : Lump
{
/// <summary>
/// Models
/// </summary>
public PhysModel[]? Models { get; set; }
}
}

View File

@@ -0,0 +1,42 @@
using System.Runtime.InteropServices;
namespace SabreTools.Models.BSP
{
/// <summary>
/// The physcollide lump (Lump 29) contains physics data for the world.
/// </summary>
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class PhysModel
{
/// <summary>
/// Perhaps the index of the model to which this physics model applies?
/// </summary>
public int ModelIndex;
/// <summary>
/// Total size of the collision data sections
/// </summary>
public int DataSize;
/// <summary>
/// Size of the text section
/// </summary>
public int KeydataSize;
/// <summary>
/// Number of collision data sections
/// </summary>
public int SolidCount;
/// <summary>
/// Collision data of length <see cref="SolidCount"/>
/// </summary>
public PhysSolid[]? Solids;
/// <summary>
/// Key data of size <see cref="KeydataSize"/>
/// </summary>
public byte[]? TextData;
}
}

View File

@@ -0,0 +1,25 @@
using System.Runtime.InteropServices;
namespace SabreTools.Models.BSP
{
/// <summary>
/// The last two parts appear to be identical to the PHY file format,
/// which means their exact contents are unknown. Note that the
/// compactsurfaceheader_t structure contains the data size of each
/// collision data section (including the rest of the header)
/// </summary>
/// <see href="https://developer.valvesoftware.com/wiki/BSP_(Source)"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class PhysSolid
{
/// <summary>
/// Size of the collision data
/// </summary>
public int Size;
/// <summary>
/// Collision data of length <see cref="Size"/>
/// </summary>
public byte[]? CollisionData;
}
}

View File

@@ -25,7 +25,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// The planes normal vector
/// </summary>
public Vector3D NormalVector;
public Vector3D? NormalVector;
/// <summary>
/// Plane equation is: vNormal * X = fDist

View File

@@ -8,7 +8,7 @@ namespace SabreTools.Models.BSP
/// from the cardinal Z axis.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct QAngle
public class QAngle
{
public float X { get; set; }
public float Y { get; set; }

View File

@@ -19,6 +19,6 @@ namespace SabreTools.Models.BSP
/// Model name
/// </summary>
/// <remarks>[dictEntries][128]</remarks>
public char[,]? Name;
public char[][]? Name;
}
}

View File

@@ -39,12 +39,12 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Origin
/// </summary>
public Vector3D Origin;
public Vector3D? Origin;
/// <summary>
/// Orientation (pitch yaw roll)
/// </summary>
public QAngle Angles;
public QAngle? Angles;
#endregion
@@ -90,7 +90,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// For lighting
/// </summary>
public Vector3D LightingOrigin;
public Vector3D? LightingOrigin;
#endregion
@@ -151,7 +151,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Per instance color and alpha modulation
/// </summary>
public ColorRGBExp32 DiffuseModulation;
public ColorRGBExp32? DiffuseModulation;
#endregion

View File

@@ -16,7 +16,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// RGB reflectivity
/// </summary>
public Vector3D Reflectivity;
public Vector3D? Reflectivity;
/// <summary>
/// Index into TexdataStringTable

View File

@@ -153,7 +153,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// LUMP_DISPINFO [26]
/// </summary>
public DispInfosLump? DispInfoLump { get; set; }
public DispInfosLump? DispInfosLump { get; set; }
/// <summary>
/// LUMP_ORIGINALFACES [27]
@@ -166,8 +166,10 @@ namespace SabreTools.Models.BSP
/// TODO: Find definition and implement
// public PhysDispLump? PhysDispLump { get; set; }
// TODO: Implement Lump 29
// https://developer.valvesoftware.com/wiki/BSP_(Source)#Physics
/// <summary>
/// LUMP_PHYSCOLLIDE [29]
/// </summary>
public PhysCollideLump? PhysCollideLump { get; set; }
/// <summary>
/// LUMP_VERTNORMALS [30]
@@ -190,7 +192,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// LUMP_DISP_VERTS [33]
/// </summary>
public DispVertsLump? DispVertLump { get; set; }
public DispVertsLump? DispVertsLump { get; set; }
/// <summary>
/// LUMP_DISP_LIGHTMAP_SAMPLE_POSITIONS [34]
@@ -227,8 +229,10 @@ namespace SabreTools.Models.BSP
/// TODO: Find definition and implement
// public PrimIndicesLump? PrimIndicesLump { get; set; }
// TODO: Implement Lump 40
// https://developer.valvesoftware.com/wiki/BSP_(Source)#Pakfile
/// <summary>
/// LUMP_PAKFILE [40]
/// </summary>
public PakfileLump? PakfileLump { get; set; }
/// <summary>
/// LUMP_CLIPPORTALVERTS [41]
@@ -239,7 +243,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// LUMP_CUBEMAPS [42]
/// </summary>
public CubemapsLump? CubemapLump { get; set; }
public CubemapsLump? CubemapsLump { get; set; }
/// <summary>
/// LUMP_TEXDATA_STRING_DATA [43]
@@ -304,7 +308,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// LUMP_WORLDLIGHTS_HDR [54]
/// </summary>
public WorldLightsLump? WorldLightsLump { get; set; }
public WorldLightsLump? HDRWorldLightsLump { get; set; }
/// <summary>
/// LUMP_LEAF_AMBIENT_LIGHTING_HDR [55]
@@ -353,7 +357,7 @@ namespace SabreTools.Models.BSP
// public PhysLevelLump? PhysLevelLump { get; set; }
/// <summary>
/// LUMP_DISP_MULTIBLEND [64]
/// LUMP_DISP_MULTIBLEND [63]
/// </summary>
/// TODO: Find definition and implement
// public DispMultiBlendLump? DispMultiBlendLump { get; set; }

View File

@@ -83,7 +83,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Precaculated light info for entities.
/// </summary>
public CompressedLightCube AmbientLighting;
public CompressedLightCube? AmbientLighting;
#endregion

View File

@@ -15,17 +15,17 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Bounding box
/// </summary>
public Vector3D Mins;
public Vector3D? Mins;
/// <summary>
/// Bounding box
/// </summary>
public Vector3D Maxs;
public Vector3D? Maxs;
/// <summary>
/// For sounds or lights
/// </summary>
public Vector3D OriginVector;
public Vector3D? OriginVector;
/// <summary>
/// Index into nodes

View File

@@ -22,7 +22,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Texture S-vector
/// </summary>
public Vector3D TextureSVector;
public Vector3D? TextureSVector;
/// <summary>
/// Texture shift in the S direction
@@ -32,7 +32,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Texture T-vector
/// </summary>
public Vector3D TextureTVector;
public Vector3D? TextureTVector;
/// <summary>
/// Texture shift in the T direction
@@ -42,7 +42,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Lightmap S-vector
/// </summary>
public Vector3D LightmapSVector;
public Vector3D? LightmapSVector;
/// <summary>
/// Lightmap shift in the S direction
@@ -52,7 +52,7 @@ namespace SabreTools.Models.BSP
/// <summary>
/// Lightmap T-vector
/// </summary>
public Vector3D LightmapTVector;
public Vector3D? LightmapTVector;
/// <summary>
/// Lightmap shift in the T direction

View File

@@ -8,7 +8,7 @@ namespace SabreTools.Models.BSP
/// spec and the code of the hlbsp project.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct Vector3D
public class Vector3D
{
public float X { get; set; }
public float Y { get; set; }

View File

@@ -17,6 +17,6 @@ namespace SabreTools.Models.BSP
public int NumClusters { get; set; }
/// <remarks>[numclusters][2]</remarks>
public int[,]? ByteOffsets { get; set; }
public int[][]? ByteOffsets { get; set; }
}
}

View File

@@ -14,14 +14,14 @@ namespace SabreTools.Models.BSP
[StructLayout(LayoutKind.Sequential)]
public sealed class WorldLight
{
public Vector3D Origin;
public Vector3D? Origin;
public Vector3D Intensity;
public Vector3D? Intensity;
/// <summary>
/// For surfaces and spotlights
/// </summary>
public Vector3D Normal;
public Vector3D? Normal;
public int Cluster;

View File

@@ -1,4 +1,6 @@
namespace SabreTools.Models.LinearExecutable
using System.Runtime.InteropServices;
namespace SabreTools.Models.LinearExecutable
{
/// <summary>
/// The resident and non-resident name tables define the ASCII names and ordinal
@@ -25,6 +27,7 @@
/// </summary>
/// <see href="https://faydoc.tripod.com/formats/exe-LE.htm"/>
/// <see href="http://www.edm2.com/index.php/LX_-_Linear_eXecutable_Module_Format_Description"/>
[StructLayout(LayoutKind.Sequential)]
public sealed class NonResidentNamesTableEntry
{
/// <summary>
@@ -39,7 +42,7 @@
/// signifies that additional information is contained in the linear EXE module and
/// will be used in the future for parameter type checking.
/// </remarks>
public byte Length { get; set; } // TODO: Remove in lieu of AnsiBStr
public byte Length { get; set; }
/// <summary>
/// ASCII String.

View File

@@ -7,7 +7,7 @@
<NoWarn>CS0618</NoWarn>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.5.2</Version>
<Version>1.5.4</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>

View File

@@ -24,7 +24,7 @@ namespace SabreTools.Models.WAD3
public CharInfo[] FontInfo = new CharInfo[256];
/// <remarks>[width][height]</remarks>
public byte[,]? Data;
public byte[][]? Data;
/// <summary>
/// Number of colors used in the palette (always 256 for GoldSrc)
@@ -35,6 +35,6 @@ namespace SabreTools.Models.WAD3
/// The color palette for the mipmaps (always 256 * 3 = 768 for GoldSrc)
/// </summary>
/// <remarks>[ColorsUsed][3]</remarks>
public byte[,]? Palette { get; set; }
public byte[][]? Palette { get; set; }
}
}

View File

@@ -1,5 +1,3 @@
using System.Runtime.InteropServices;
namespace SabreTools.Models.WAD3
{
/// <see href="https://twhl.info/wiki/page/Specification:_WAD3"/>
@@ -9,6 +7,6 @@ namespace SabreTools.Models.WAD3
/// Raw image data. Each byte points to an index in the palette
/// </summary>
/// <remarks>[width][height]</remarks>
public byte[,]? Data { get; set; }
public byte[][]? Data { get; set; }
}
}

View File

@@ -43,6 +43,6 @@ namespace SabreTools.Models.WAD3
/// The color palette for the mipmaps (always 256 * 3 = 768 for GoldSrc)
/// </summary>
/// <remarks>[ColorsUsed][3]</remarks>
public byte[,]? Palette { get; set; }
public byte[][]? Palette { get; set; }
}
}

View File

@@ -17,7 +17,7 @@ namespace SabreTools.Models.WAD3
/// Raw image data. Each byte points to an index in the palette
/// </summary>
/// <remarks>[height][width]</remarks>
public byte[,]? Data { get; set; }
public byte[][]? Data { get; set; }
/// <summary>
/// Number of colors used in the palette (always 256 for GoldSrc)
@@ -28,6 +28,6 @@ namespace SabreTools.Models.WAD3
/// The color palette for the mipmaps (always 256 * 3 = 768 for GoldSrc)
/// </summary>
/// <remarks>[ColorsUsed][3]</remarks>
public byte[,]? Palette { get; set; }
public byte[][]? Palette { get; set; }
}
}