mirror of
https://github.com/ladislav-zezula/StormLib.git
synced 2026-02-03 04:56:25 +01:00
lcLocale -> lcFileLocale. Now also contains platform
This commit is contained in:
@@ -765,11 +765,13 @@ static bool IsValidHashEntry1(TMPQArchive * ha, TMPQHash * pHash, TMPQBlock * pB
|
||||
// 2) A hash table entry with the neutral|matching locale and neutral|matching platform
|
||||
// 3) NULL
|
||||
// Storm_2016.dll: 15020940
|
||||
static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale, BYTE Platform)
|
||||
static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcFileLocale)
|
||||
{
|
||||
TMPQHash * pFirstHash = GetFirstHashEntry(ha, szFileName);
|
||||
TMPQHash * pBestEntry = NULL;
|
||||
TMPQHash * pHash = pFirstHash;
|
||||
USHORT Locale = SFILE_LOCALE(lcFileLocale);
|
||||
BYTE Platform = SFILE_PLATFORM(lcFileLocale);
|
||||
|
||||
// Parse the found hashes
|
||||
while(pHash != NULL)
|
||||
@@ -778,13 +780,13 @@ static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName,
|
||||
// If the hash entry matches both locale and platform, return it immediately
|
||||
// Only do that for non-0 locale&platform, because for loc&plat=0, there's different
|
||||
// processing in Warcraft III vs. Starcraft, which is abused by some protectors.
|
||||
if((lcLocale || Platform) && pHash->lcLocale == lcLocale && pHash->Platform == Platform)
|
||||
if((Locale || Platform) && pHash->Locale == Locale && pHash->Platform == Platform)
|
||||
return pHash;
|
||||
|
||||
// Storm_2016.dll: 150209D9
|
||||
// If (locale matches or is neutral) AND (platform matches or is neutral), remember this as the best entry
|
||||
// Also remember the first matching entry for Starcraft maps
|
||||
if(pHash->lcLocale == 0 || pHash->lcLocale == lcLocale)
|
||||
if(pHash->Locale == 0 || pHash->Locale == Locale)
|
||||
{
|
||||
if(pHash->Platform == 0 || pHash->Platform == Platform)
|
||||
{
|
||||
@@ -803,16 +805,17 @@ static TMPQHash * GetHashEntryLocale(TMPQArchive * ha, const char * szFileName,
|
||||
// Returns a hash table entry in the following order:
|
||||
// 1) A hash table entry with the preferred locale
|
||||
// 2) NULL
|
||||
static TMPQHash * GetHashEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale)
|
||||
static TMPQHash * GetHashEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcFileLocale)
|
||||
{
|
||||
TMPQHash * pFirstHash = GetFirstHashEntry(ha, szFileName);
|
||||
TMPQHash * pHash = pFirstHash;
|
||||
USHORT Locale = SFILE_LOCALE(lcFileLocale);
|
||||
|
||||
// Parse the found hashes
|
||||
while(pHash != NULL)
|
||||
{
|
||||
// If the locales match, return it
|
||||
if(pHash->lcLocale == lcLocale)
|
||||
if(pHash->Locale == Locale)
|
||||
return pHash;
|
||||
|
||||
// Get the next hash entry for that file
|
||||
@@ -1967,7 +1970,7 @@ void FreeBetTable(TMPQBetTable * pBetTable)
|
||||
//-----------------------------------------------------------------------------
|
||||
// Support for file table
|
||||
|
||||
TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex)
|
||||
TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID lcFileLocale, LPDWORD PtrHashIndex)
|
||||
{
|
||||
TMPQHash * pHash;
|
||||
DWORD dwFileIndex;
|
||||
@@ -1977,7 +1980,7 @@ TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID
|
||||
// we will need the pointer to hash table entry
|
||||
if(ha->pHashTable != NULL)
|
||||
{
|
||||
pHash = GetHashEntryLocale(ha, szFileName, lcLocale, 0);
|
||||
pHash = GetHashEntryLocale(ha, szFileName, lcFileLocale);
|
||||
if(pHash != NULL && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize)
|
||||
{
|
||||
if(PtrHashIndex != NULL)
|
||||
@@ -1998,7 +2001,7 @@ TFileEntry * GetFileEntryLocale(TMPQArchive * ha, const char * szFileName, LCID
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex)
|
||||
TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID lcFileLocale, LPDWORD PtrHashIndex)
|
||||
{
|
||||
TMPQHash * pHash;
|
||||
DWORD dwFileIndex;
|
||||
@@ -2006,7 +2009,7 @@ TFileEntry * GetFileEntryExact(TMPQArchive * ha, const char * szFileName, LCID l
|
||||
// If the hash table is present, find the entry from hash table
|
||||
if(ha->pHashTable != NULL)
|
||||
{
|
||||
pHash = GetHashEntryExact(ha, szFileName, lcLocale);
|
||||
pHash = GetHashEntryExact(ha, szFileName, lcFileLocale);
|
||||
if(pHash != NULL && MPQ_BLOCK_INDEX(pHash) < ha->dwFileTableSize)
|
||||
{
|
||||
if(PtrHashIndex != NULL)
|
||||
@@ -2062,7 +2065,7 @@ void AllocateFileName(TMPQArchive * ha, TFileEntry * pFileEntry, const char * sz
|
||||
}
|
||||
}
|
||||
|
||||
TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcLocale, LPDWORD PtrHashIndex)
|
||||
TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID lcFileLocale, LPDWORD PtrHashIndex)
|
||||
{
|
||||
TFileEntry * pFileTableEnd = ha->pFileTable + ha->dwFileTableSize;
|
||||
TFileEntry * pFreeEntry = NULL;
|
||||
@@ -2109,10 +2112,10 @@ TFileEntry * AllocateFileEntry(TMPQArchive * ha, const char * szFileName, LCID l
|
||||
if(ha->pHashTable != NULL)
|
||||
{
|
||||
// Make sure that the entry is not there yet
|
||||
assert(GetHashEntryExact(ha, szFileName, lcLocale) == NULL);
|
||||
assert(GetHashEntryExact(ha, szFileName, lcFileLocale) == NULL);
|
||||
|
||||
// Find a free hash table entry for the name
|
||||
pHash = AllocateHashEntry(ha, pFreeEntry, lcLocale);
|
||||
pHash = AllocateHashEntry(ha, pFreeEntry, lcFileLocale);
|
||||
if(pHash == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -2139,7 +2142,7 @@ DWORD RenameFileEntry(
|
||||
{
|
||||
TFileEntry * pFileEntry = hf->pFileEntry;
|
||||
TMPQHash * pHashEntry = hf->pHashEntry;
|
||||
LCID lcLocale = 0;
|
||||
LCID lcFileLocale = 0;
|
||||
|
||||
// If the archive hash hash table, we need to free the hash table entry
|
||||
if(ha->pHashTable != NULL)
|
||||
@@ -2150,12 +2153,12 @@ DWORD RenameFileEntry(
|
||||
return ERROR_NOT_SUPPORTED;
|
||||
|
||||
// Save the locale
|
||||
lcLocale = pHashEntry->lcLocale;
|
||||
lcFileLocale = SFILE_MAKE_LCID(pHashEntry->Locale, pHashEntry->Platform);
|
||||
|
||||
// Mark the hash table entry as deleted
|
||||
pHashEntry->dwName1 = 0xFFFFFFFF;
|
||||
pHashEntry->dwName2 = 0xFFFFFFFF;
|
||||
pHashEntry->lcLocale = 0xFFFF;
|
||||
pHashEntry->Locale = 0xFFFF;
|
||||
pHashEntry->Platform = 0xFF;
|
||||
pHashEntry->Reserved = 0xFF;
|
||||
pHashEntry->dwBlockIndex = HASH_ENTRY_DELETED;
|
||||
@@ -2173,7 +2176,7 @@ DWORD RenameFileEntry(
|
||||
if(ha->pHashTable != NULL)
|
||||
{
|
||||
// Since we freed one hash entry before, this must succeed
|
||||
hf->pHashEntry = AllocateHashEntry(ha, pFileEntry, lcLocale);
|
||||
hf->pHashEntry = AllocateHashEntry(ha, pFileEntry, lcFileLocale);
|
||||
assert(hf->pHashEntry != NULL);
|
||||
}
|
||||
|
||||
@@ -2196,7 +2199,7 @@ DWORD DeleteFileEntry(TMPQArchive * ha, TMPQFile * hf)
|
||||
// Mark the hash table entry as deleted
|
||||
pHashEntry->dwName1 = 0xFFFFFFFF;
|
||||
pHashEntry->dwName2 = 0xFFFFFFFF;
|
||||
pHashEntry->lcLocale = 0xFFFF;
|
||||
pHashEntry->Locale = 0xFFFF;
|
||||
pHashEntry->Platform = 0xFF;
|
||||
pHashEntry->Reserved = 0xFF;
|
||||
pHashEntry->dwBlockIndex = HASH_ENTRY_DELETED;
|
||||
@@ -2928,7 +2931,7 @@ DWORD RebuildFileTable(TMPQArchive * ha, DWORD dwNewHashTableSize)
|
||||
if(IsValidHashEntry(ha, pHash))
|
||||
{
|
||||
pFileEntry = ha->pFileTable + MPQ_BLOCK_INDEX(pHash);
|
||||
AllocateHashEntry(ha, pFileEntry, pHash->lcLocale);
|
||||
AllocateHashEntry(ha, pFileEntry, SFILE_MAKE_LCID(pHash->Locale, pHash->Platform));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user