Add VBSP wrapper, extraction, and use it

This commit is contained in:
Matt Nadareski
2022-12-26 10:58:16 -08:00
parent 50fe127a8d
commit 2875f7ff7a
5 changed files with 352 additions and 22 deletions

View File

@@ -419,6 +419,25 @@ namespace Test
pak.Print();
}
// VBSP
else if (IsVBSP(magic))
{
// Build the archive information
Console.WriteLine("Creating VBSP deserializer");
Console.WriteLine();
var vbsp = VBSP.Create(stream);
if (vbsp == null)
{
Console.WriteLine("Something went wrong parsing VBSP");
Console.WriteLine();
return;
}
// Print the VBSP info to screen
vbsp.Print();
}
// VPK
else if (IsVPK(magic))
{
@@ -571,6 +590,17 @@ namespace Test
return magic[0] == 'P' && magic[1] == 'E' && magic[2] == '\0' && magic[3] == '\0';
}
/// <summary>
/// Determine if the magic bytes indicate a VBSP
/// </summary>
private static bool IsVBSP(byte[] magic)
{
if (magic == null || magic.Length < 4)
return false;
return magic[0] == 'V' && magic[1] == 'B' && magic[2] == 'S' && magic[3] == 'P';
}
/// <summary>
/// Determine if the magic bytes indicate a VPK
/// </summary>