mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01:00
Tools/Extractors: Changed search method, it will no longer miss some dbc files
This commit is contained in:
49
dep/StormLib/searchFix.patch
Normal file
49
dep/StormLib/searchFix.patch
Normal file
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user