diff options
-rw-r--r-- | dep/StormLib/searchFix.patch | 49 | ||||
-rw-r--r-- | dep/StormLib/src/SFileFindFile.cpp | 10 | ||||
-rw-r--r-- | src/tools/map_extractor/System.cpp | 24 |
3 files changed, 72 insertions, 11 deletions
diff --git a/dep/StormLib/searchFix.patch b/dep/StormLib/searchFix.patch new file mode 100644 index 00000000000..d4ba11d8645 --- /dev/null +++ b/dep/StormLib/searchFix.patch @@ -0,0 +1,49 @@ +diff --git a/dep/StormLib/src/SFileFindFile.cpp b/dep/StormLib/src/SFileFindFile.cpp +index aa065d2..542637b 100644 +--- a/dep/StormLib/src/SFileFindFile.cpp ++++ b/dep/StormLib/src/SFileFindFile.cpp +@@ -31,7 +31,7 @@ struct TMPQSearch + DWORD dwSearchTableItems; // Number of items in the search table + DWORD dwNextIndex; // Next file index to be checked + DWORD dwFlagMask; // For checking flag mask +- char szSearchMask[1]; // Search mask (variable length) ++ char * szSearchMask; // Search mask (variable length) + }; + + //----------------------------------------------------------------------------- +@@ -69,7 +69,7 @@ bool CheckWildCard(const char * szString, const char * szWildCard) + szString++; + } + +- // If there is '*', means zero or more chars. We have to ++ // If there is '*', means zero or more chars. We have to + // find the sequence after '*' + if(*szWildCard == '*') + { +@@ -337,6 +337,8 @@ static void FreeMPQSearch(TMPQSearch *& hs) + { + if(hs->pSearchTable != NULL) + STORM_FREE(hs->pSearchTable); ++ if(hs->szSearchMask != NULL) ++ free(hs->szSearchMask); // allocated with strdup + STORM_FREE(hs); + hs = NULL; + } +@@ -376,7 +378,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA + if(nError == ERROR_SUCCESS) + { + memset(hs, 0, sizeof(TMPQSearch)); +- strcpy(hs->szSearchMask, szMask); ++ hs->szSearchMask = strdup(szMask); + hs->dwFlagMask = MPQ_FILE_EXISTS; + hs->ha = ha; + +@@ -406,7 +408,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA + FreeMPQSearch(hs); + SetLastError(nError); + } +- ++ + // Return the result value + return (HANDLE)hs; + } diff --git a/dep/StormLib/src/SFileFindFile.cpp b/dep/StormLib/src/SFileFindFile.cpp index aa065d23a84..542637b3668 100644 --- a/dep/StormLib/src/SFileFindFile.cpp +++ b/dep/StormLib/src/SFileFindFile.cpp @@ -31,7 +31,7 @@ struct TMPQSearch DWORD dwSearchTableItems; // Number of items in the search table DWORD dwNextIndex; // Next file index to be checked DWORD dwFlagMask; // For checking flag mask - char szSearchMask[1]; // Search mask (variable length) + char * szSearchMask; // Search mask (variable length) }; //----------------------------------------------------------------------------- @@ -69,7 +69,7 @@ bool CheckWildCard(const char * szString, const char * szWildCard) szString++; } - // If there is '*', means zero or more chars. We have to + // If there is '*', means zero or more chars. We have to // find the sequence after '*' if(*szWildCard == '*') { @@ -337,6 +337,8 @@ static void FreeMPQSearch(TMPQSearch *& hs) { if(hs->pSearchTable != NULL) STORM_FREE(hs->pSearchTable); + if(hs->szSearchMask != NULL) + free(hs->szSearchMask); // allocated with strdup STORM_FREE(hs); hs = NULL; } @@ -376,7 +378,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA if(nError == ERROR_SUCCESS) { memset(hs, 0, sizeof(TMPQSearch)); - strcpy(hs->szSearchMask, szMask); + hs->szSearchMask = strdup(szMask); hs->dwFlagMask = MPQ_FILE_EXISTS; hs->ha = ha; @@ -406,7 +408,7 @@ HANDLE WINAPI SFileFindFirstFile(HANDLE hMpq, const char * szMask, SFILE_FIND_DA FreeMPQSearch(hs); SetLastError(nError); } - + // Return the result value return (HANDLE)hs; } diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index 94639e5ba06..fb64adb3c61 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -998,7 +998,7 @@ void ExtractDBCFiles(int l, bool basicLocale) SFILE_FIND_DATA foundFile; memset(&foundFile, 0, sizeof(foundFile)); - HANDLE listFile = SListFileFindFirstFile(LocaleMpq, NULL, "DBFilesClient\\*dbc", &foundFile); + HANDLE listFile = SFileFindFirstFile(LocaleMpq, "DBFilesClient\\*dbc", &foundFile, NULL); HANDLE dbcFile = NULL; uint32 count = 0; if (listFile) @@ -1017,7 +1017,10 @@ void ExtractDBCFiles(int l, bool basicLocale) do { if (!SFileOpenFileEx(LocaleMpq, foundFile.cFileName, SFILE_OPEN_PATCHED_FILE, &dbcFile)) + { + printf("Unable to open file %s in the archive\n", foundFile.cFileName); continue; + } filename = foundFile.cFileName; filename = outputPath + filename.substr(filename.rfind('\\')); @@ -1025,7 +1028,9 @@ void ExtractDBCFiles(int l, bool basicLocale) ++count; SFileCloseFile(dbcFile); - } while (SListFileFindNextFile(listFile, &foundFile)); + } while (SFileFindNextFile(listFile, &foundFile)); + + SFileFindClose(listFile); } printf("Extracted %u DBC files\n\n", count); @@ -1037,7 +1042,7 @@ void ExtractDB2Files(int l, bool basicLocale) SFILE_FIND_DATA foundFile; memset(&foundFile, 0, sizeof(foundFile)); - HANDLE listFile = SListFileFindFirstFile(LocaleMpq, NULL, "DBFilesClient\\*db2", &foundFile); + HANDLE listFile = SFileFindFirstFile(LocaleMpq, "DBFilesClient\\*db2", &foundFile, NULL); HANDLE dbcFile = NULL; uint32 count = 0; if (listFile) @@ -1054,7 +1059,10 @@ void ExtractDB2Files(int l, bool basicLocale) do { if (!SFileOpenFileEx(LocaleMpq, foundFile.cFileName, SFILE_OPEN_PATCHED_FILE, &dbcFile)) + { + printf("Unable to open file %s in the archive\n", foundFile.cFileName); continue; + } filename = foundFile.cFileName; filename = outputPath + filename.substr(filename.rfind('\\')); @@ -1062,7 +1070,9 @@ void ExtractDB2Files(int l, bool basicLocale) ++count; SFileCloseFile(dbcFile); - } while (SListFileFindNextFile(listFile, &foundFile)); + } while (SFileFindNextFile(listFile, &foundFile)); + + SFileFindClose(listFile); } printf("Extracted %u DB2 files\n\n", count); @@ -1072,7 +1082,7 @@ bool LoadLocaleMPQFile(int locale) { TCHAR buff[512]; memset(buff, 0, sizeof(buff)); - _stprintf(buff, _T("./Data/%s/locale-%s.MPQ"), LocalesT[locale], LocalesT[locale]); + _stprintf(buff, _T("%s/Data/%s/locale-%s.MPQ"), input_path, LocalesT[locale], LocalesT[locale]); if (!SFileOpenArchive(buff, 0, MPQ_OPEN_READ_ONLY, &LocaleMpq)) { if (GetLastError() != ERROR_PATH_NOT_FOUND) @@ -1087,12 +1097,12 @@ bool LoadLocaleMPQFile(int locale) if (Builds[i] > LAST_DBC_IN_DATA_BUILD) { prefix = ""; - _stprintf(buff, _T("./Data/%s/wow-update-%s-%u.MPQ"), LocalesT[locale], LocalesT[locale], Builds[i]); + _stprintf(buff, _T("%s/Data/%s/wow-update-%s-%u.MPQ"), input_path, LocalesT[locale], LocalesT[locale], Builds[i]); } else { prefix = Locales[locale]; - _stprintf(buff, _T("./Data/wow-update-%u.MPQ"), Builds[i]); + _stprintf(buff, _T("%s/Data/wow-update-%u.MPQ"), input_path, Builds[i]); } if (!SFileOpenPatchArchive(LocaleMpq, buff, prefix, 0)) |