diff options
author | Zezula Ladislav <ladislav.zezula@avast.com> | 2017-08-29 15:08:02 +0200 |
---|---|---|
committer | Zezula Ladislav <ladislav.zezula@avast.com> | 2017-08-29 15:08:02 +0200 |
commit | 431570180b0d089143c10b40563810bb45e57300 (patch) | |
tree | 7a33afd328128a418c50d2ebc96b84047d0a607a /src | |
parent | adac4aa0f586c7aa2a3c19aa4e687d827dc86195 (diff) |
+ Fixed patching bug
Diffstat (limited to 'src')
-rw-r--r-- | src/SFileFindFile.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
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);
|