MCPcopy Create free account
hub / github.com/diasurgical/devilution / FindHashIndex

Function FindHashIndex

3rdParty/StormLib/src/SFileOpenFileEx.cpp:19–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17/*****************************************************************************/
18
19static DWORD FindHashIndex(TMPQArchive * ha, DWORD dwFileIndex)
20{
21 TMPQHash * pHashTableEnd;
22 TMPQHash * pHash;
23 DWORD dwFirstIndex = HASH_ENTRY_FREE;
24
25 // Should only be called if the archive has hash table
26 assert(ha->pHashTable != NULL);
27
28 // Multiple hash table entries can point to the file table entry.
29 // We need to search all of them
30 pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize;
31 for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++)
32 {
33 if(MPQ_BLOCK_INDEX(pHash) == dwFileIndex)
34 {
35 // Duplicate hash entry found
36 if(dwFirstIndex != HASH_ENTRY_FREE)
37 return HASH_ENTRY_FREE;
38 dwFirstIndex = (DWORD)(pHash - ha->pHashTable);
39 }
40 }
41
42 // Return the hash table entry index
43 return dwFirstIndex;
44}
45
46static const char * GetPatchFileName(TMPQArchive * ha, const char * szFileName, char * szBuffer)
47{

Callers 1

SFileOpenFileExFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected