| 2322 | #endif |
| 2323 | |
| 2324 | int LoadAnyHashTable(TMPQArchive * ha) |
| 2325 | { |
| 2326 | TMPQHeader * pHeader = ha->pHeader; |
| 2327 | |
| 2328 | // If the MPQ archive is empty, don't bother trying to load anything |
| 2329 | if(pHeader->dwHashTableSize == 0 && pHeader->HetTableSize64 == 0) |
| 2330 | return CreateHashTable(ha, HASH_TABLE_SIZE_DEFAULT); |
| 2331 | |
| 2332 | #ifdef FULL |
| 2333 | // Try to load HET table |
| 2334 | if(pHeader->HetTablePos64 != 0) |
| 2335 | ha->pHetTable = LoadHetTable(ha); |
| 2336 | #endif |
| 2337 | // Try to load classic hash table |
| 2338 | if(pHeader->dwHashTableSize) |
| 2339 | ha->pHashTable = LoadHashTable(ha); |
| 2340 | |
| 2341 | // At least one of the tables must be present |
| 2342 | if(ha->pHetTable == NULL && ha->pHashTable == NULL) |
| 2343 | return ERROR_FILE_CORRUPT; |
| 2344 | |
| 2345 | // Set the maximum file count to the size of the hash table. |
| 2346 | // Note: We don't care about HET table limits, because HET table is rebuilt |
| 2347 | // after each file add/rename/delete. |
| 2348 | ha->dwMaxFileCount = (ha->pHashTable != NULL) ? pHeader->dwHashTableSize : HASH_TABLE_SIZE_MAX; |
| 2349 | return ERROR_SUCCESS; |
| 2350 | } |
| 2351 | |
| 2352 | static int BuildFileTable_Classic(TMPQArchive * ha) |
| 2353 | { |
no test coverage detected