MCPcopy Create free account
hub / github.com/Kenix3/libultraship / LoadAnyHashTable

Function LoadAnyHashTable

extern/StormLib/src/SBaseFileTable.cpp:2486–2513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2484}
2485
2486DWORD 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
2515static DWORD BuildFileTable_Classic(TMPQArchive * ha)
2516{

Callers 1

SFileOpenArchiveFunction · 0.85

Calls 3

CreateHashTableFunction · 0.85
LoadHetTableFunction · 0.85
LoadHashTableFunction · 0.85

Tested by

no test coverage detected