From 431570180b0d089143c10b40563810bb45e57300 Mon Sep 17 00:00:00 2001 From: Zezula Ladislav Date: Tue, 29 Aug 2017 15:08:02 +0200 Subject: + Fixed patching bug --- src/SFileFindFile.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/SFileFindFile.cpp b/src/SFileFindFile.cpp index 18bf4d5..3533549 100644 --- a/src/SFileFindFile.cpp +++ b/src/SFileFindFile.cpp @@ -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; - - // 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; + // 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); + + // 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); -- cgit v1.2.3