aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SFileOpenFileEx.cpp35
-rw-r--r--src/StormLib.h2
2 files changed, 19 insertions, 18 deletions
diff --git a/src/SFileOpenFileEx.cpp b/src/SFileOpenFileEx.cpp
index 6e4af14..a25cc72 100644
--- a/src/SFileOpenFileEx.cpp
+++ b/src/SFileOpenFileEx.cpp
@@ -259,27 +259,16 @@ bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearch
case SFILE_OPEN_BASE_FILE:
case SFILE_OPEN_CHECK_EXISTS:
- // Check the pseudo-file name
- if((bOpenByIndex = IsPseudoFileName(szFileName, &dwFileIndex)) == true)
+ // If this MPQ has no patches, open the file from this MPQ directly
+ if(ha->haPatch == NULL || dwSearchScope == SFILE_OPEN_BASE_FILE)
{
- // Get the file entry for the file
- if(dwFileIndex > ha->dwFileTableSize)
- break;
- pFileEntry = ha->pFileTable + dwFileIndex;
+ pFileEntry = GetFileEntryLocale2(ha, szFileName, lcFileLocale, &dwHashIndex);
}
+
+ // If this MPQ is a patched archive, open the file as patched
else
{
- // If this MPQ has no patches, open the file from this MPQ directly
- if(ha->haPatch == NULL || dwSearchScope == SFILE_OPEN_BASE_FILE)
- {
- pFileEntry = GetFileEntryLocale2(ha, szFileName, lcFileLocale, &dwHashIndex);
- }
-
- // If this MPQ is a patched archive, open the file as patched
- else
- {
- return OpenPatchedFile(hMpq, szFileName, PtrFile);
- }
+ return OpenPatchedFile(hMpq, szFileName, PtrFile);
}
break;
@@ -308,7 +297,19 @@ bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char * szFileName, DWORD dwSearch
if(nError == ERROR_SUCCESS)
{
if(pFileEntry == NULL || (pFileEntry->dwFlags & MPQ_FILE_EXISTS) == 0)
+ {
+ // Check the pseudo-file name
+ if((bOpenByIndex = IsPseudoFileName(szFileName, &dwFileIndex)) == true)
+ {
+ // Get the file entry for the file
+ if(dwFileIndex < ha->dwFileTableSize)
+ {
+ pFileEntry = ha->pFileTable + dwFileIndex;
+ }
+ }
+
nError = ERROR_FILE_NOT_FOUND;
+ }
// Ignore unknown loading flags (example: MPQ_2016_v1_WME4_4.w3x)
// if(pFileEntry != NULL && pFileEntry->dwFlags & ~MPQ_FILE_VALID_FLAGS)
diff --git a/src/StormLib.h b/src/StormLib.h
index a0738d1..b9f60a4 100644
--- a/src/StormLib.h
+++ b/src/StormLib.h
@@ -1077,7 +1077,7 @@ bool WINAPI SFileCreateFile(HANDLE hMpq, const char * szArchivedName, ULONGLON
bool WINAPI SFileWriteFile(HANDLE hFile, const void * pvData, DWORD dwSize, DWORD dwCompression);
bool WINAPI SFileFinishFile(HANDLE hFile);
-bool WINAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext);
+bool WINAPI SFileAddFileEx(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwCompression, DWORD dwCompressionNext = MPQ_COMPRESSION_NEXT_SAME);
bool WINAPI SFileAddFile(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags);
bool WINAPI SFileAddWave(HANDLE hMpq, const TCHAR * szFileName, const char * szArchivedName, DWORD dwFlags, DWORD dwQuality);
bool WINAPI SFileRemoveFile(HANDLE hMpq, const char * szFileName, DWORD dwSearchScope);