| 2484 | } |
| 2485 | |
| 2486 | DWORD LoadAnyHashTable(TMPQArchive * ha) |
| 2487 | { |
| 2488 | TMPQHeader * pHeader = ha->pHeader; |
| 2489 | |
| 2490 | // If the MPQ archive is empty, don't bother trying to load anything |
| 2491 | if(pHeader->dwHashTableSize == 0 && pHeader->HetTableSize64 == 0) |
| 2492 | return CreateHashTable(ha, HASH_TABLE_SIZE_DEFAULT); |
| 2493 | |
| 2494 | // Try to load HET table |
| 2495 | if(pHeader->HetTablePos64 != 0) |
| 2496 | ha->pHetTable = LoadHetTable(ha); |
| 2497 | |
| 2498 | // Try to load classic hash table |
| 2499 | // Note that we load the classic hash table even when HET table exists, |
| 2500 | // because if the MPQ gets modified and saved, hash table must be there |
| 2501 | if(pHeader->dwHashTableSize) |
| 2502 | ha->pHashTable = LoadHashTable(ha); |
| 2503 | |
| 2504 | // At least one of the tables must be present |
| 2505 | if(ha->pHetTable == NULL && ha->pHashTable == NULL) |
| 2506 | return ERROR_FILE_CORRUPT; |
| 2507 | |
| 2508 | // Set the maximum file count to the size of the hash table. |
| 2509 | // Note: We don't care about HET table limits, because HET table is rebuilt |
| 2510 | // after each file add/rename/delete. |
| 2511 | ha->dwMaxFileCount = (ha->pHashTable != NULL) ? pHeader->dwHashTableSize : HASH_TABLE_SIZE_MAX; |
| 2512 | return ERROR_SUCCESS; |
| 2513 | } |
| 2514 | |
| 2515 | static DWORD BuildFileTable_Classic(TMPQArchive * ha) |
| 2516 | { |
no test coverage detected