diff --git a/BurnOutSharp.Builders/GCF.cs b/BurnOutSharp.Builders/GCF.cs index 13b4ac2a..cb9209f0 100644 --- a/BurnOutSharp.Builders/GCF.cs +++ b/BurnOutSharp.Builders/GCF.cs @@ -8,40 +8,6 @@ namespace BurnOutSharp.Builders { public static class GCF { - #region Constants - - /// - /// The item is a file. - /// - public const int HL_GCF_FLAG_FILE = 0x00004000; - - /// - /// The item is encrypted. - /// - public const int HL_GCF_FLAG_ENCRYPTED = 0x00000100; - - /// - /// Backup the item before overwriting it. - /// - public const int HL_GCF_FLAG_BACKUP_LOCAL = 0x00000040; - - /// - /// The item is to be copied to the disk. - /// - public const int HL_GCF_FLAG_COPY_LOCAL = 0x0000000A; - - /// - /// Don't overwrite the item if copying it to the disk and the item already exists. - /// - public const int HL_GCF_FLAG_COPY_LOCAL_NO_OVERWRITE = 0x00000001; - - /// - /// The maximum data allowed in a 32 bit checksum. - /// - public const int HL_GCF_CHECKSUM_LENGTH = 0x00008000; - - #endregion - #region Byte Data /// @@ -602,7 +568,7 @@ namespace BurnOutSharp.Builders directoryEntry.NameOffset = data.ReadUInt32(); directoryEntry.ItemSize = data.ReadUInt32(); directoryEntry.ChecksumIndex = data.ReadUInt32(); - directoryEntry.DirectoryFlags = data.ReadUInt32(); + directoryEntry.DirectoryFlags = (HL_GCF_FLAG)data.ReadUInt32(); directoryEntry.ParentIndex = data.ReadUInt32(); directoryEntry.NextIndex = data.ReadUInt32(); directoryEntry.FirstIndex = data.ReadUInt32(); diff --git a/BurnOutSharp.Models/GCF/Constants.cs b/BurnOutSharp.Models/GCF/Constants.cs new file mode 100644 index 00000000..19fcc316 --- /dev/null +++ b/BurnOutSharp.Models/GCF/Constants.cs @@ -0,0 +1,10 @@ +namespace BurnOutSharp.Models.GCF +{ + public static class Constants + { + /// + /// The maximum data allowed in a 32 bit checksum. + /// + public const int HL_GCF_CHECKSUM_LENGTH = 0x00008000; + } +} \ No newline at end of file diff --git a/BurnOutSharp.Models/GCF/DirectoryEntry.cs b/BurnOutSharp.Models/GCF/DirectoryEntry.cs index 1c72a2ca..892b00ed 100644 --- a/BurnOutSharp.Models/GCF/DirectoryEntry.cs +++ b/BurnOutSharp.Models/GCF/DirectoryEntry.cs @@ -26,7 +26,7 @@ namespace BurnOutSharp.Models.GCF /// /// Flags for the directory item. (0x00000000 == Folder). /// - public uint DirectoryFlags; + public HL_GCF_FLAG DirectoryFlags; /// /// Index of the parent directory item. (0xFFFFFFFF == None). diff --git a/BurnOutSharp.Models/GCF/Enums.cs b/BurnOutSharp.Models/GCF/Enums.cs new file mode 100644 index 00000000..70cb773b --- /dev/null +++ b/BurnOutSharp.Models/GCF/Enums.cs @@ -0,0 +1,33 @@ +using System; + +namespace BurnOutSharp.Models.GCF +{ + [Flags] + public enum HL_GCF_FLAG : uint + { + /// + /// Don't overwrite the item if copying it to the disk and the item already exists. + /// + HL_GCF_FLAG_COPY_LOCAL_NO_OVERWRITE = 0x00000001, + + /// + /// The item is to be copied to the disk. + /// + HL_GCF_FLAG_COPY_LOCAL = 0x0000000A, + + /// + /// Backup the item before overwriting it. + /// + HL_GCF_FLAG_BACKUP_LOCAL = 0x00000040, + + /// + /// The item is encrypted. + /// + HL_GCF_FLAG_ENCRYPTED = 0x00000100, + + /// + /// The item is a file. + /// + HL_GCF_FLAG_FILE = 0x00004000, + } +} \ No newline at end of file diff --git a/BurnOutSharp.Wrappers/GCF.cs b/BurnOutSharp.Wrappers/GCF.cs index af8f5196..9976cf04 100644 --- a/BurnOutSharp.Wrappers/GCF.cs +++ b/BurnOutSharp.Wrappers/GCF.cs @@ -320,14 +320,14 @@ namespace BurnOutSharp.Wrappers var directoryMapEntry = DirectoryMapEntries[i]; // If we have a directory, skip for now - if ((directoryEntry.DirectoryFlags & Builders.GCF.HL_GCF_FLAG_FILE) == 0) + if (!directoryEntry.DirectoryFlags.HasFlag(Models.GCF.HL_GCF_FLAG.HL_GCF_FLAG_FILE)) continue; // Otherwise, start building the file info var fileInfo = new FileInfo() { Size = directoryEntry.ItemSize, - Encrypted = (directoryEntry.DirectoryFlags & Builders.GCF.HL_GCF_FLAG_ENCRYPTED) != 0, + Encrypted = directoryEntry.DirectoryFlags.HasFlag(Models.GCF.HL_GCF_FLAG.HL_GCF_FLAG_ENCRYPTED), }; var pathParts = new List { directoryEntry.Name }; var blockEntries = new List();