aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLadislav Zezula <zezula-at-volny-dot-cz>2018-06-13 15:49:23 +0200
committerLadislav Zezula <zezula-at-volny-dot-cz>2018-06-13 15:49:23 +0200
commit4ad0bff21da0163917e1552960e6a43679586b89 (patch)
tree7bb0a72169c2a4736fc45ba563d1afc6a04f26c0
parent7292399efefe279c2f090d70ec7abf462a3f7f96 (diff)
+ When opening a file by special name, the file is first checked whether that file is there.
-rw-r--r--StormLib_vs08_test.vcproj2
-rw-r--r--src/SFileOpenFileEx.cpp35
-rw-r--r--src/StormLib.h2
-rw-r--r--test/StormTest.cpp9
4 files changed, 26 insertions, 22 deletions
diff --git a/StormLib_vs08_test.vcproj b/StormLib_vs08_test.vcproj
index 1cd9596..7e9e485 100644
--- a/StormLib_vs08_test.vcproj
+++ b/StormLib_vs08_test.vcproj
@@ -27,7 +27,7 @@
OutputDirectory="./bin/$(ProjectName)/$(PlatformName)/$(ConfigurationName)"
IntermediateDirectory="./bin/$(ProjectName)/$(PlatformName)/$(ConfigurationName)"
ConfigurationType="1"
- CharacterSet="2"
+ CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
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);
diff --git a/test/StormTest.cpp b/test/StormTest.cpp
index e6ca2cb..f1f6970 100644
--- a/test/StormTest.cpp
+++ b/test/StormTest.cpp
@@ -4406,7 +4406,7 @@ int _tmain(int argc, TCHAR * argv[])
// Not a test, but rather a tool for creating links to duplicated files
// if(nError == ERROR_SUCCESS)
// nError = FindFilePairs(ForEachFile_CreateArchiveLink, "2004 - WoW\\06080", "2004 - WoW\\06299");
-
+/*
// Search all testing archives and verify their SHA1 hash
if(nError == ERROR_SUCCESS)
nError = FindFiles(ForEachFile_VerifyFileChecksum, szMpqSubDir);
@@ -4482,7 +4482,10 @@ int _tmain(int argc, TCHAR * argv[])
// Open the update MPQ from Diablo II (patch 2016)
if(nError == ERROR_SUCCESS)
nError = TestOpenFile_OpenByName(_T("MPQ_2016_v1_D2XP_IX86_1xx_114a.mpq"), "waitingroombkgd.dc6");
-
+*/
+ if(nError == ERROR_SUCCESS)
+ nError = TestOpenFile_OpenByName(_T("MPQ_2018_v1_icon_error.w3m"), "file00000002.blp");
+/*
// Open a file whose archive's (signature) file has flags = 0x90000000
if(nError == ERROR_SUCCESS)
nError = TestOpenArchive(_T("MPQ_1997_v1_Diablo1_STANDARD.SNP"), _T("ListFile_Blizzard.txt"));
@@ -4832,7 +4835,7 @@ int _tmain(int argc, TCHAR * argv[])
// Test replacing a file with zero size file
if(nError == ERROR_SUCCESS)
nError = TestModifyArchive_ReplaceFile(_T("MPQ_2014_v4_Base.StormReplay"), _T("AddFile-replay.message.events"));
-
+*/
#ifdef _MSC_VER
_CrtDumpMemoryLeaks();
#endif // _MSC_VER