using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.MoPaQ
{
///
/// The BET table is present if the BetTablePos64 member of MPQ header is set
/// to nonzero. BET table is a successor of classic block table, and can fully
/// replace it. It is also supposed to be more effective.
///
///
public sealed class BetTable
{
// TODO: Extract this out and make in common between HET and BET
#region Common Table Headers
///
/// 'BET\x1A'
///
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 4)]
public string Signature = string.Empty;
///
/// Version. Seems to be always 1
///
public uint Version { get; set; }
///
/// Size of the contained table
///
public uint DataSize { get; set; }
#endregion
///
/// Size of the entire hash table, including the header (in bytes)
///
public uint TableSize { get; set; }
///
/// Number of files in the BET table
///
public uint FileCount { get; set; }
///
/// Unknown, set to 0x10
///
public uint Unknown { get; set; }
///
/// Size of one table entry (in bits)
///
public uint TableEntrySize { get; set; }
///
/// Bit index of the file position (within the entry record)
///
public uint FilePositionBitIndex { get; set; }
///
/// Bit index of the file size (within the entry record)
///
public uint FileSizeBitIndex { get; set; }
///
/// Bit index of the compressed size (within the entry record)
///
public uint CompressedSizeBitIndex { get; set; }
///
/// Bit index of the flag index (within the entry record)
///
public uint FlagIndexBitIndex { get; set; }
///
/// Bit index of the ??? (within the entry record)
///
public uint UnknownBitIndex { get; set; }
///
/// Bit size of file position (in the entry record)
///
public uint FilePositionBitCount { get; set; }
///
/// Bit size of file size (in the entry record)
///
public uint FileSizeBitCount { get; set; }
///
/// Bit size of compressed file size (in the entry record)
///
public uint CompressedSizeBitCount { get; set; }
///
/// Bit size of flags index (in the entry record)
///
public uint FlagIndexBitCount { get; set; }
///
/// Bit size of ??? (in the entry record)
///
public uint UnknownBitCount { get; set; }
///
/// Total size of the BET hash
///
public uint TotalBetHashSize { get; set; }
///
/// Extra bits in the BET hash
///
public uint BetHashSizeExtra { get; set; }
///
/// Effective size of BET hash (in bits)
///
public uint BetHashSize { get; set; }
///
/// Size of BET hashes array, in bytes
///
public uint BetHashArraySize { get; set; }
///
/// Number of flags in the following array
///
public uint FlagCount { get; set; }
///
/// Followed by array of file flags. Each entry is 32-bit size and its meaning is the same like
///
/// Size from
public uint[] FlagsArray { get; set; } = [];
// File table. Size of each entry is taken from dwTableEntrySize.
// Size of the table is (dwTableEntrySize * dwMaxFileCount), round up to 8.
// Array of BET hashes. Table size is taken from dwMaxFileCount from HET table
}
}