aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SBaseCommon.cpp15
-rw-r--r--src/SFileOpenFileEx.cpp2
2 files changed, 16 insertions, 1 deletions
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp
index 95bdeb4..5483f55 100644
--- a/src/SBaseCommon.cpp
+++ b/src/SBaseCommon.cpp
@@ -255,6 +255,21 @@ DWORD HashStringLower(const char * szFileName, DWORD dwHashType)
//-----------------------------------------------------------------------------
// Calculates the hash table size for a given amount of files
+// Returns the nearest higher power of two.
+// If the value is already a power of two, returns the same value
+//static DWORD GetNearestPowerOfTwo(DWORD dwValue)
+//{
+// dwValue --;
+//
+// dwValue |= dwValue >> 1;
+// dwValue |= dwValue >> 2;
+// dwValue |= dwValue >> 4;
+// dwValue |= dwValue >> 8;
+// dwValue |= dwValue >> 16;
+//
+// return dwValue + 1;
+//}
+
DWORD GetHashTableSizeForFileCount(DWORD dwFileCount)
{
DWORD dwPowerOfTwo = HASH_TABLE_SIZE_MIN;
diff --git a/src/SFileOpenFileEx.cpp b/src/SFileOpenFileEx.cpp
index afbfc78..9ce0ae2 100644
--- a/src/SFileOpenFileEx.cpp
+++ b/src/SFileOpenFileEx.cpp
@@ -30,7 +30,7 @@ static DWORD FindHashIndex(TMPQArchive * ha, DWORD dwFileIndex)
pHashTableEnd = ha->pHashTable + ha->pHeader->dwHashTableSize;
for(pHash = ha->pHashTable; pHash < pHashTableEnd; pHash++)
{
- if(pHash->dwBlockIndex == dwFileIndex)
+ if(MPQ_BLOCK_INDEX(pHash) == dwFileIndex)
{
// Duplicate hash entry found
if(dwFirstIndex != HASH_ENTRY_FREE)