mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-04-27 08:40:35 +00:00
Add and use VPK constants
This commit is contained in:
@@ -3,30 +3,12 @@ using System.IO;
|
||||
using System.Text;
|
||||
using BurnOutSharp.Models.VPK;
|
||||
using BurnOutSharp.Utilities;
|
||||
using static BurnOutSharp.Models.VPK.Constants;
|
||||
|
||||
namespace BurnOutSharp.Builders
|
||||
{
|
||||
public static class VPK
|
||||
{
|
||||
#region Constants
|
||||
|
||||
/// <summary>
|
||||
/// VPK header signature as an integer
|
||||
/// </summary>
|
||||
public const int HL_VPK_SIGNATURE = 0x55aa1234;
|
||||
|
||||
/// <summary>
|
||||
/// Index indicating that there is no archive
|
||||
/// </summary>
|
||||
public const int HL_VPK_NO_ARCHIVE = 0x7fff;
|
||||
|
||||
/// <summary>
|
||||
/// Length of a VPK checksum in bytes
|
||||
/// </summary>
|
||||
public const int HL_VPK_CHECKSUM_LENGTH = 0x00008000;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Byte Data
|
||||
|
||||
/// <summary>
|
||||
@@ -147,7 +129,7 @@ namespace BurnOutSharp.Builders
|
||||
Header header = new Header();
|
||||
|
||||
header.Signature = data.ReadUInt32();
|
||||
if (header.Signature != HL_VPK_SIGNATURE)
|
||||
if (header.Signature != SignatureUInt32)
|
||||
return null;
|
||||
|
||||
header.Version = data.ReadUInt32();
|
||||
|
||||
21
BurnOutSharp.Models/VPK/Constants.cs
Normal file
21
BurnOutSharp.Models/VPK/Constants.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace BurnOutSharp.Models.VPK
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly byte[] SignatureBytes = new byte[] { 0x34, 0x12, 0xaa, 0x55 };
|
||||
|
||||
public const string SignatureString = "4\u0012\u00aaU";
|
||||
|
||||
public const uint SignatureUInt32 = 0x55aa1234;
|
||||
|
||||
/// <summary>
|
||||
/// Index indicating that there is no archive
|
||||
/// </summary>
|
||||
public const int HL_VPK_NO_ARCHIVE = 0x7fff;
|
||||
|
||||
/// <summary>
|
||||
/// Length of a VPK checksum in bytes
|
||||
/// </summary>
|
||||
public const int HL_VPK_CHECKSUM_LENGTH = 0x00008000;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using BurnOutSharp.Utilities;
|
||||
using static BurnOutSharp.Models.VPK.Constants;
|
||||
|
||||
namespace BurnOutSharp.Wrappers
|
||||
{
|
||||
@@ -83,7 +84,7 @@ namespace BurnOutSharp.Wrappers
|
||||
int archiveCount = DirectoryItems
|
||||
.Select(di => di.DirectoryEntry)
|
||||
.Select(de => de.ArchiveIndex)
|
||||
.Where(ai => ai != Builders.VPK.HL_VPK_NO_ARCHIVE)
|
||||
.Where(ai => ai != HL_VPK_NO_ARCHIVE)
|
||||
.Max();
|
||||
|
||||
// Build the list of archive filenames to populate
|
||||
@@ -342,7 +343,7 @@ namespace BurnOutSharp.Wrappers
|
||||
|
||||
// If we have an item with no archive
|
||||
byte[] data;
|
||||
if (directoryItem.DirectoryEntry.ArchiveIndex == Builders.VPK.HL_VPK_NO_ARCHIVE)
|
||||
if (directoryItem.DirectoryEntry.ArchiveIndex == HL_VPK_NO_ARCHIVE)
|
||||
{
|
||||
if (directoryItem.PreloadData == null)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user