diff options
author | Ladislav Zezula <zezula@volny.cz> | 2020-05-10 06:43:37 +0200 |
---|---|---|
committer | Ladislav Zezula <zezula@volny.cz> | 2020-05-10 06:43:37 +0200 |
commit | 6065d16ba99f40011c494a31a8f65b7edd15025e (patch) | |
tree | 4fdfc84ff5c9882d775b1e3da2ce70020ab5a39c /src/SFileOpenFileEx.cpp | |
parent | 147b4aa7e5278287e235cad1849e0d9dd0d5a0f0 (diff) |
* ZLIB updated
* Minor fixes
Diffstat (limited to 'src/SFileOpenFileEx.cpp')
-rw-r--r-- | src/SFileOpenFileEx.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/SFileOpenFileEx.cpp b/src/SFileOpenFileEx.cpp index fc37f6a..d66c369 100644 --- a/src/SFileOpenFileEx.cpp +++ b/src/SFileOpenFileEx.cpp @@ -124,37 +124,38 @@ bool OpenPatchedFile(HANDLE hMpq, const char * szFileName, HANDLE * PtrFile) } // If we couldn't find the base file in any of the patches, it doesn't exist - if((ha = haBase) == NULL) + if((ha = haBase) != NULL) { - SetLastError(ERROR_FILE_NOT_FOUND); - return false; - } - - // Now open the base file - if(SFileOpenFileEx((HANDLE)ha, GetPatchFileName(ha, szFileName, szNameBuffer), SFILE_OPEN_BASE_FILE, (HANDLE *)&hfBase)) - { - // The file must be a base file, i.e. without MPQ_FILE_PATCH_FILE - assert((hfBase->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0); - hf = hfBase; - - // Now open all patches and attach them on top of the base file - for(ha = ha->haPatch; ha != NULL; ha = ha->haPatch) + // Now open the base file + if(SFileOpenFileEx((HANDLE)ha, GetPatchFileName(ha, szFileName, szNameBuffer), SFILE_OPEN_BASE_FILE, (HANDLE *)&hfBase)) { - // Prepare the file name with a correct prefix - if(SFileOpenFileEx((HANDLE)ha, GetPatchFileName(ha, szFileName, szNameBuffer), SFILE_OPEN_BASE_FILE, &hPatchFile)) + // The file must be a base file, i.e. without MPQ_FILE_PATCH_FILE + assert((hfBase->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) == 0); + hf = hfBase; + + // Now open all patches and attach them on top of the base file + for(ha = ha->haPatch; ha != NULL; ha = ha->haPatch) { - // Remember the new version - hfPatch = (TMPQFile *)hPatchFile; + // Prepare the file name with a correct prefix + if(SFileOpenFileEx((HANDLE)ha, GetPatchFileName(ha, szFileName, szNameBuffer), SFILE_OPEN_BASE_FILE, &hPatchFile)) + { + // Remember the new version + hfPatch = (TMPQFile *)hPatchFile; - // We should not find patch file - assert((hfPatch->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) != 0); + // We should not find patch file + assert((hfPatch->pFileEntry->dwFlags & MPQ_FILE_PATCH_FILE) != 0); - // Attach the patch to the base file - hf->hfPatch = hfPatch; - hf = hfPatch; + // Attach the patch to the base file + hf->hfPatch = hfPatch; + hf = hfPatch; + } } } } + else + { + SetLastError(ERROR_FILE_NOT_FOUND); + } // Give the updated base MPQ if(PtrFile != NULL) |