mirror of
https://github.com/ladislav-zezula/StormLib.git
synced 2026-02-04 21:36:24 +01:00
+ Removed back reference of FileTable -> HashTable, as it is logically incorrect
+ Optimized patching process so it consimes less memory + Added hash table and block table defragmenting for malformed War3 maps
This commit is contained in:
@@ -185,7 +185,6 @@ static TFileEntry * FindPatchEntry(TMPQArchive * ha, TFileEntry * pFileEntry)
|
||||
TFileEntry * pPatchEntry = NULL;
|
||||
TFileEntry * pTempEntry;
|
||||
char szFileName[MAX_PATH];
|
||||
LCID lcLocale = pFileEntry->lcLocale;
|
||||
|
||||
// Go while there are patches
|
||||
while(ha->haPatch != NULL)
|
||||
@@ -200,7 +199,7 @@ static TFileEntry * FindPatchEntry(TMPQArchive * ha, TFileEntry * pFileEntry)
|
||||
strcat(szFileName, pFileEntry->szFileName);
|
||||
|
||||
// Try to find the file there
|
||||
pTempEntry = GetFileEntryExact(ha, szFileName, lcLocale);
|
||||
pTempEntry = GetFileEntryExact(ha, szFileName, 0, NULL);
|
||||
if(pTempEntry != NULL)
|
||||
pPatchEntry = pTempEntry;
|
||||
}
|
||||
@@ -218,7 +217,7 @@ static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData)
|
||||
TFileEntry * pFileEntry;
|
||||
const char * szFileName;
|
||||
HANDLE hFile;
|
||||
char szPseudoName[20];
|
||||
char szNameBuff[MAX_PATH];
|
||||
DWORD dwBlockIndex;
|
||||
size_t nPrefixLength;
|
||||
|
||||
@@ -260,11 +259,11 @@ static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData)
|
||||
if(szFileName == NULL)
|
||||
{
|
||||
// Open the file by its pseudo-name.
|
||||
// This also generates the file name with a proper extension
|
||||
sprintf(szPseudoName, "File%08u.xxx", (unsigned int)dwBlockIndex);
|
||||
if(SFileOpenFileEx((HANDLE)hs->ha, szPseudoName, SFILE_OPEN_BASE_FILE, &hFile))
|
||||
sprintf(szNameBuff, "File%08u.xxx", (unsigned int)dwBlockIndex);
|
||||
if(SFileOpenFileEx((HANDLE)hs->ha, szNameBuff, SFILE_OPEN_BASE_FILE, &hFile))
|
||||
{
|
||||
szFileName = (pFileEntry->szFileName != NULL) ? pFileEntry->szFileName : szPseudoName;
|
||||
SFileGetFileName(hFile, szNameBuff);
|
||||
szFileName = szNameBuff;
|
||||
SFileCloseFile(hFile);
|
||||
}
|
||||
}
|
||||
@@ -276,12 +275,11 @@ static int DoMPQSearch(TMPQSearch * hs, SFILE_FIND_DATA * lpFindFileData)
|
||||
if(CheckWildCard(szFileName + nPrefixLength, hs->szSearchMask))
|
||||
{
|
||||
// Fill the found entry. hash entry and block index are taken from the base MPQ
|
||||
lpFindFileData->dwHashIndex = pFileEntry->dwHashIndex;
|
||||
lpFindFileData->dwBlockIndex = dwBlockIndex;
|
||||
lpFindFileData->dwFileSize = pPatchEntry->dwFileSize;
|
||||
lpFindFileData->dwFileFlags = pPatchEntry->dwFlags;
|
||||
lpFindFileData->dwCompSize = pPatchEntry->dwCmpSize;
|
||||
lpFindFileData->lcLocale = pPatchEntry->lcLocale;
|
||||
lpFindFileData->lcLocale = 0; // pPatchEntry->lcLocale;
|
||||
|
||||
// Fill the filetime
|
||||
lpFindFileData->dwFileTimeHi = (DWORD)(pPatchEntry->FileTime >> 32);
|
||||
|
||||
Reference in New Issue
Block a user