Add and use SGA constants

This commit is contained in:
Matt Nadareski
2022-12-28 15:17:34 -08:00
parent 404b2889ff
commit fbf629dd8b
2 changed files with 18 additions and 10 deletions

View File

@@ -3,20 +3,12 @@ using System.IO;
using System.Text;
using BurnOutSharp.Models.SGA;
using BurnOutSharp.Utilities;
using static BurnOutSharp.Models.SGA.Constants;
namespace BurnOutSharp.Builders
{
public static class SGA
{
#region Constants
/// <summary>
/// Length of a SGA checksum in bytes
/// </summary>
public const int HL_SGA_CHECKSUM_LENGTH = 0x00008000;
#endregion
#region Byte Data
/// <summary>
@@ -101,7 +93,7 @@ namespace BurnOutSharp.Builders
// TODO: Use marshalling here instead of building
byte[] signatureBytes = data.ReadBytes(8);
string signature = Encoding.ASCII.GetString(signatureBytes);
if (signature != "_ARCHIVE")
if (signature != SignatureString)
return null;
ushort majorVersion = data.ReadUInt16();

View File

@@ -0,0 +1,16 @@
namespace BurnOutSharp.Models.SGA
{
public static class Constants
{
public static readonly byte[] SignatureBytes = new byte[] { 0x5f, 0x41, 0x52, 0x43, 0x48, 0x49, 0x56, 0x45 };
public const string SignatureString = "_ARCHIVE";
public const ulong SignatureUInt64 = 0x455649484352415f;
/// <summary>
/// Length of a SGA checksum in bytes
/// </summary>
public const int HL_SGA_CHECKSUM_LENGTH = 0x00008000;
}
}