using System.Runtime.InteropServices;
namespace SabreTools.Data.Models.MoPaQ
{
///
/// The HET table is present if the HetTablePos64 member of MPQ header is
/// set to nonzero. This table can fully replace hash table. Depending on
/// MPQ size, the pair of HET&BET table can be more efficient than Hash&Block
/// table. HET table can be encrypted and compressed.
///
///
public sealed class HetTable
{
// TODO: Extract this out and make in common between HET and BET
#region Common Table Headers
///
/// 'HET\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; }
///
/// Maximum number of files in the MPQ
///
public uint MaxFileCount { get; set; }
///
/// Size of the hash table (in bytes)
///
public uint HashTableSize { get; set; }
///
/// Effective size of the hash entry (in bits)
///
public uint HashEntrySize { get; set; }
///
/// Total size of file index (in bits)
///
public uint TotalIndexSize { get; set; }
///
/// Extra bits in the file index
///
public uint IndexSizeExtra { get; set; }
///
/// Effective size of the file index (in bits)
///
public uint IndexSize { get; set; }
///
/// Size of the block index subtable (in bytes)
///
public uint BlockTableSize { get; set; }
///
/// HET hash table. Each entry is 8 bits.
///
/// Size is derived from HashTableSize
public byte[] HashTable { get; set; } = [];
///
/// Array of file indexes. Bit size of each entry is taken from dwTotalIndexSize.
/// Table size is taken from dwHashTableSize.
///
public byte[][] FileIndexes { get; set; } = [];
}
}