Add and use VBSP constants

This commit is contained in:
Matt Nadareski
2022-12-28 15:22:16 -08:00
parent fbf629dd8b
commit c48522e6c0
3 changed files with 33 additions and 25 deletions

View File

@@ -2,30 +2,12 @@ using System.IO;
using System.Text;
using BurnOutSharp.Models.VBSP;
using BurnOutSharp.Utilities;
using static BurnOutSharp.Models.VBSP.Constants;
namespace BurnOutSharp.Builders
{
public static class VBSP
{
#region Constants
/// <summary>
/// Total number of lumps in the package
/// </summary>
public const int HL_VBSP_LUMP_COUNT = 64;
/// <summary>
/// Index for the entities lump
/// </summary>
public const int HL_VBSP_LUMP_ENTITIES = 0;
/// <summary>
/// Index for the pakfile lump
/// </summary>
public const int HL_VBSP_LUMP_PAKFILE = 40;
#endregion
#region Byte Data
/// <summary>
@@ -101,7 +83,7 @@ namespace BurnOutSharp.Builders
byte[] signature = data.ReadBytes(4);
header.Signature = Encoding.ASCII.GetString(signature);
if (header.Signature != "VBSP")
if (header.Signature != SignatureString)
return null;
header.Version = data.ReadInt32();

View File

@@ -0,0 +1,26 @@
namespace BurnOutSharp.Models.VBSP
{
public static class Constants
{
public static readonly byte[] SignatureBytes = new byte[] { 0x56, 0x42, 0x53, 0x50 };
public const string SignatureString = "VBSP";
public const uint SignatureUInt32 = 0x50534256;
/// <summary>
/// Total number of lumps in the package
/// </summary>
public const int HL_VBSP_LUMP_COUNT = 64;
/// <summary>
/// Index for the entities lump
/// </summary>
public const int HL_VBSP_LUMP_ENTITIES = 0;
/// <summary>
/// Index for the pakfile lump
/// </summary>
public const int HL_VBSP_LUMP_PAKFILE = 40;
}
}

View File

@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using static BurnOutSharp.Models.VBSP.Constants;
namespace BurnOutSharp.Wrappers
{
@@ -138,10 +138,10 @@ namespace BurnOutSharp.Wrappers
string specialLumpName = string.Empty;
switch (i)
{
case Builders.VBSP.HL_VBSP_LUMP_ENTITIES:
case HL_VBSP_LUMP_ENTITIES:
specialLumpName = " (entities)";
break;
case Builders.VBSP.HL_VBSP_LUMP_PAKFILE:
case HL_VBSP_LUMP_PAKFILE:
specialLumpName = " (pakfile)";
break;
}
@@ -211,10 +211,10 @@ namespace BurnOutSharp.Wrappers
string filename = $"lump_{index}.bin";
switch (index)
{
case Builders.VBSP.HL_VBSP_LUMP_ENTITIES:
case HL_VBSP_LUMP_ENTITIES:
filename = "entities.ent";
break;
case Builders.VBSP.HL_VBSP_LUMP_PAKFILE:
case HL_VBSP_LUMP_PAKFILE:
filename = "pakfile.zip";
break;
}