Expand description
The Hash Table Parsing
Instead of storing file names, for quick access MoPaQs use a fixed, power of two-size hash table of files in the archive. A file is uniquely identified by its file path, its language, and its platform. The home entry for a file in the hash table is computed as a hash of the file path. In the event of a collision (the home entry is occupied by another file), progressive overflow is used, and the file is placed in the next available hash table entry. Searches for a desired file in the hash table proceed from the home entry for the file until either the file is found, the entire hash table is searched, or an empty hash table entry (FileBlockIndex of 0xffffffff) is encountered. The hash table is always encrypted, using the hash of “(hash table)” as the key. Prior to Starcraft 2, the hash table is stored uncompressed. In Starcraft 2, however, the table may optionally be compressed. If the offset of the block table is not equal to the offset of the hash table plus the uncompressed size, Starcraft 2 interprets the hash table as being compressed (not imploded). This calculation assumes that the block table immediately follows the hash table, and will fail or crash otherwise. NOTES:
- MPyQ uses struct_format: ‘2I2HI’
- The format above claims the [
MPQHashTableEntry.platform
] is a u16. - The devklog.net website claims the [
MPQHashTableEntry.platform
] field is u8 - In this implementation the u16 MPyQ version is honored.
- The format above claims the [
Structs§
- MPQHash
Table Entry - The hash table entry definition