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

Function GetNextHashEntry

3rdParty/StormLib/src/SBaseCommon.cpp:718–745  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

716}
717
718TMPQHash * GetNextHashEntry(TMPQArchive * ha, TMPQHash * pFirstHash, TMPQHash * pHash)
719{
720 DWORD dwHashIndexMask = HASH_INDEX_MASK(ha);
721 DWORD dwStartIndex = (DWORD)(pFirstHash - ha->pHashTable);
722 DWORD dwName1 = pHash->dwName1;
723 DWORD dwName2 = pHash->dwName2;
724 DWORD dwIndex = (DWORD)(pHash - ha->pHashTable);
725
726 // Now go for any next entry that follows the pHash,
727 // until either free hash entry was found, or the start entry was reached
728 for(;;)
729 {
730 // Move to the next hash entry. Stop searching
731 // if we got reached the original hash entry
732 dwIndex = (dwIndex + 1) & dwHashIndexMask;
733 if(dwIndex == dwStartIndex)
734 return NULL;
735 pHash = ha->pHashTable + dwIndex;
736
737 // If the entry matches, we found it.
738 if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize)
739 return pHash;
740
741 // If that hash entry is a free entry, it means we haven't found the file
742 if(pHash->dwBlockIndex == HASH_ENTRY_FREE)
743 return NULL;
744 }
745}
746
747// Allocates an entry in the hash table
748TMPQHash * AllocateHashEntry(

Callers 3

GetHashEntryLocaleFunction · 0.85
GetHashEntryExactFunction · 0.85
SFileEnumLocalesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected