+ Fixed patching bug

This commit is contained in:
Zezula Ladislav
2017-08-29 15:08:02 +02:00
parent adac4aa0f5
commit 431570180b
2 changed files with 41 additions and 27 deletions

View File

@@ -175,26 +175,30 @@ static bool FileWasFoundBefore(
static TFileEntry * FindPatchEntry(TMPQArchive * ha, TFileEntry * pFileEntry)
{
TFileEntry * pPatchEntry = NULL;
TFileEntry * pPatchEntry = pFileEntry;
TFileEntry * pTempEntry;
char szFileName[MAX_PATH+1];
// Go while there are patches
while(ha->haPatch != NULL)
// Can't find patch entry for a file that doesn't have name
if(pFileEntry->szFileName != NULL && pFileEntry->szFileName[0] != 0)
{
// Move to the patch archive
ha = ha->haPatch;
szFileName[0] = 0;
// Go while there are patches
while(ha->haPatch != NULL)
{
// Move to the patch archive
ha = ha->haPatch;
szFileName[0] = 0;
// Prepare the prefix for the file name
if(ha->pPatchPrefix != NULL)
StringCopyA(szFileName, ha->pPatchPrefix->szPatchPrefix, MAX_PATH);
StringCatA(szFileName, pFileEntry->szFileName, MAX_PATH);
// Prepare the prefix for the file name
if(ha->pPatchPrefix != NULL)
StringCopyA(szFileName, ha->pPatchPrefix->szPatchPrefix, MAX_PATH);
StringCatA(szFileName, pFileEntry->szFileName, MAX_PATH);
// Try to find the file there
pTempEntry = GetFileEntryExact(ha, szFileName, 0, NULL);
if(pTempEntry != NULL)
pPatchEntry = pTempEntry;
// Try to find the file there
pTempEntry = GetFileEntryExact(ha, szFileName, 0, NULL);
if(pTempEntry != NULL)
pPatchEntry = pTempEntry;
}
}
// Return the found patch entry
@@ -225,9 +229,8 @@ static bool DoMPQSearch_FileEntry(
// DebugBreak();
// Find a patch to this file
// Note: This either succeeds or returns pFileEntry
pPatchEntry = FindPatchEntry(ha, pFileEntry);
if(pPatchEntry == NULL)
pPatchEntry = pFileEntry;
// Prepare the block index
dwBlockIndex = (DWORD)(pFileEntry - ha->pFileTable);