| 17 | /*****************************************************************************/ |
| 18 | |
| 19 | static 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 | |
| 46 | static const char * GetPatchFileName(TMPQArchive * ha, const char * szFileName, char * szBuffer) |
| 47 | { |