From: ShadowFlare Date: Wed, 16 Jan 2013 08:35:13 +0000 (-0700) Subject: Skip extra free entries in case any did not have their name data cleared X-Git-Url: https://sfsrealm.hopto.org/projects/gitweb.cgi?a=commitdiff_plain;h=HEAD;p=SFmpqapi.git Skip extra free entries in case any did not have their name data cleared --- diff --git a/SFmpqapi.cpp b/SFmpqapi.cpp index 4e87aef..5ca8bed 100644 --- a/SFmpqapi.cpp +++ b/SFmpqapi.cpp @@ -3115,16 +3115,19 @@ MPQHANDLE GetFreeHashTableEntry(MPQHANDLE hMPQ, LPCSTR lpFileName, LCID FileLoca DWORD i=dwTablePos, nFirstFree = 0xFFFFFFFF; do { - if ((mpqOpenArc->lpHashTable[i].dwBlockTableIndex&0xFFFFFFFE)==0xFFFFFFFE && (nFirstFree == 0xFFFFFFFF || mpqOpenArc->lpHashTable[i].dwBlockTableIndex == 0xFFFFFFFF)) + if ((mpqOpenArc->lpHashTable[i].dwBlockTableIndex&0xFFFFFFFE)==0xFFFFFFFE) { - if (mpqOpenArc->lpHashTable[i].dwBlockTableIndex == 0xFFFFFFFF) + if (nFirstFree == 0xFFFFFFFF || mpqOpenArc->lpHashTable[i].dwBlockTableIndex == 0xFFFFFFFF) { - if (nFirstFree == 0xFFFFFFFF) - return (MPQHANDLE)&mpqOpenArc->lpHashTable[i]; - else - return (MPQHANDLE)&mpqOpenArc->lpHashTable[nFirstFree]; + if (mpqOpenArc->lpHashTable[i].dwBlockTableIndex == 0xFFFFFFFF) + { + if (nFirstFree == 0xFFFFFFFF) + return (MPQHANDLE)&mpqOpenArc->lpHashTable[i]; + else + return (MPQHANDLE)&mpqOpenArc->lpHashTable[nFirstFree]; + } + else nFirstFree = i; } - else nFirstFree = i; } else if (mpqOpenArc->lpHashTable[i].dwNameHashA==dwNameHashA && mpqOpenArc->lpHashTable[i].dwNameHashB==dwNameHashB && mpqOpenArc->lpHashTable[i].lcLocale==FileLocale) {