aboutsummaryrefslogtreecommitdiff
path: root/src/SBaseCommon.cpp
diff options
context:
space:
mode:
authorLadislav Zezula <zezula@volny.cz>2022-10-03 20:06:22 +0200
committerGitHub <noreply@github.com>2022-10-03 20:06:22 +0200
commit3846f0b8e2c47320c6b499492496f3e3f2e76821 (patch)
tree59610e60d94b65d8439d979802a5852d9b48c745 /src/SBaseCommon.cpp
parent88b18d4d097ef6cabb4f99f3a48db172064ea119 (diff)
parent305583053bf2796adf3162cf617020c250d7faf7 (diff)
Merge pull request #265 from ladislav-zezula/LZ_LocaleAndPlatformv9.24
Locale&platform problems fixed
Diffstat (limited to 'src/SBaseCommon.cpp')
-rw-r--r--src/SBaseCommon.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/SBaseCommon.cpp b/src/SBaseCommon.cpp
index 4b2bd6d..77590d6 100644
--- a/src/SBaseCommon.cpp
+++ b/src/SBaseCommon.cpp
@@ -23,8 +23,7 @@ char StormLibCopyright[] = "StormLib v " STORMLIB_VERSION_STRING " Copyright Lad
DWORD g_dwMpqSignature = ID_MPQ; // Marker for MPQ header
DWORD g_dwHashTableKey = MPQ_KEY_HASH_TABLE; // Key for hash table
DWORD g_dwBlockTableKey = MPQ_KEY_BLOCK_TABLE; // Key for block table
-LCID g_lcFileLocale = LANG_NEUTRAL; // File locale
-USHORT wPlatform = 0; // File platform
+LCID g_lcFileLocale = 0; // Compound of file locale and platform
//-----------------------------------------------------------------------------
// Conversion to uppercase/lowercase
@@ -737,12 +736,13 @@ TMPQFile * IsValidFileHandle(HANDLE hFile)
// Hash table and block table manipulation
// Attempts to search a free hash entry, or an entry whose names and locale matches
-TMPQHash * FindFreeHashEntry(TMPQArchive * ha, DWORD dwStartIndex, DWORD dwName1, DWORD dwName2, LCID lcLocale)
+TMPQHash * FindFreeHashEntry(TMPQArchive * ha, DWORD dwStartIndex, DWORD dwName1, DWORD dwName2, LCID lcFileLocale)
{
TMPQHash * pDeletedEntry = NULL; // If a deleted entry was found in the continuous hash range
TMPQHash * pFreeEntry = NULL; // If a free entry was found in the continuous hash range
DWORD dwHashIndexMask = HASH_INDEX_MASK(ha);
DWORD dwIndex;
+ USHORT Locale = SFILE_LOCALE(lcFileLocale);
// Set the initial index
dwStartIndex = dwIndex = (dwStartIndex & dwHashIndexMask);
@@ -757,7 +757,7 @@ TMPQHash * FindFreeHashEntry(TMPQArchive * ha, DWORD dwStartIndex, DWORD dwName1
TMPQHash * pHash = ha->pHashTable + dwIndex;
// If we found a matching entry, return that one
- if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->lcLocale == lcLocale)
+ if(pHash->dwName1 == dwName1 && pHash->dwName2 == dwName2 && pHash->Locale == Locale)
return pHash;
// If we found a deleted entry, remember it but keep searching
@@ -849,7 +849,7 @@ TMPQHash * GetNextHashEntry(TMPQArchive * ha, TMPQHash * pFirstHash, TMPQHash *
TMPQHash * AllocateHashEntry(
TMPQArchive * ha,
TFileEntry * pFileEntry,
- LCID lcLocale)
+ LCID lcFileLocale)
{
TMPQHash * pHash;
DWORD dwStartIndex = ha->pfnHashString(pFileEntry->szFileName, MPQ_HASH_TABLE_INDEX);
@@ -857,14 +857,15 @@ TMPQHash * AllocateHashEntry(
DWORD dwName2 = ha->pfnHashString(pFileEntry->szFileName, MPQ_HASH_NAME_B);
// Attempt to find a free hash entry
- pHash = FindFreeHashEntry(ha, dwStartIndex, dwName1, dwName2, lcLocale);
+ pHash = FindFreeHashEntry(ha, dwStartIndex, dwName1, dwName2, lcFileLocale);
if(pHash != NULL)
{
// Fill the free hash entry
pHash->dwName1 = dwName1;
pHash->dwName2 = dwName2;
- pHash->lcLocale = (USHORT)lcLocale;
- pHash->Platform = 0;
+ pHash->Locale = SFILE_LOCALE(lcFileLocale);
+ pHash->Platform = SFILE_PLATFORM(lcFileLocale);
+ pHash->Reserved = 0;
pHash->dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable);
}