mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[9170] Impleament DBCs build check at server startup.
* Extractor now include in extarcted DBC dir data file with build info. * Mangosd use this data for check at startup for main DBC dir and DBC local subdirs intergrity. * Also updates DBC checks for raw data. NOTE: You need reextract DBC data by _new_ extractor for correct work mangosd.
This commit is contained in:
parent
10de01c6f7
commit
83bd854030
4 changed files with 158 additions and 14 deletions
|
|
@ -166,6 +166,43 @@ void HandleArgs(int argc, char * arg[])
|
|||
}
|
||||
}
|
||||
|
||||
uint32 ReadBuild(int locale)
|
||||
{
|
||||
// include build info file also
|
||||
std::string filename = std::string("component.wow-")+langs[locale]+".txt";
|
||||
//printf("Read %s file... ", filename.c_str());
|
||||
|
||||
MPQFile m(filename.c_str());
|
||||
if(m.isEof())
|
||||
{
|
||||
printf("Fatal error: Not found %s file!\n", filename.c_str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::string text = m.getPointer();
|
||||
m.close();
|
||||
|
||||
size_t pos = text.find("version=\"");
|
||||
size_t pos1 = pos + strlen("version=\"");
|
||||
size_t pos2 = text.find("\"",pos1);
|
||||
if (pos == text.npos || pos2 == text.npos || pos1 >= pos2)
|
||||
{
|
||||
printf("Fatal error: Invalid %s file format!\n", filename.c_str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
std::string build_str = text.substr(pos1,pos2-pos1);
|
||||
|
||||
int build = atoi(build_str.c_str());
|
||||
if (build <= 0)
|
||||
{
|
||||
printf("Fatal error: Invalid %s file format!\n", filename.c_str());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return build;
|
||||
}
|
||||
|
||||
uint32 ReadMapDBC()
|
||||
{
|
||||
printf("Read Map.dbc file... ");
|
||||
|
|
@ -920,6 +957,14 @@ void ExtractDBCFiles(int locale, bool basicLocale)
|
|||
CreateDir(path);
|
||||
}
|
||||
|
||||
// extract Build info file
|
||||
{
|
||||
string mpq_name = std::string("component.wow-") + langs[locale] + ".txt";
|
||||
string filename = path + mpq_name;
|
||||
|
||||
ExtractFile(mpq_name.c_str(), filename);
|
||||
}
|
||||
|
||||
// extract DBCs
|
||||
int count = 0;
|
||||
for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter)
|
||||
|
|
@ -978,6 +1023,7 @@ int main(int argc, char * arg[])
|
|||
HandleArgs(argc, arg);
|
||||
|
||||
int FirstLocale = -1;
|
||||
uint32 build = 0;
|
||||
|
||||
for (int i = 0; i < LANG_COUNT; i++)
|
||||
{
|
||||
|
|
@ -993,6 +1039,8 @@ int main(int argc, char * arg[])
|
|||
if((CONF_extract & EXTRACT_DBC) == 0)
|
||||
{
|
||||
FirstLocale = i;
|
||||
build = ReadBuild(FirstLocale);
|
||||
printf("Detected client build: %u\n", build);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -1000,6 +1048,8 @@ int main(int argc, char * arg[])
|
|||
if(FirstLocale < 0)
|
||||
{
|
||||
FirstLocale = i;
|
||||
build = ReadBuild(FirstLocale);
|
||||
printf("Detected client build: %u\n", build);
|
||||
ExtractDBCFiles(i, true);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue