mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Tools/Misc: Partial cherry-pick of 7b235ce6e4
This commit is contained in:
@@ -116,12 +116,12 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
|
||||
{
|
||||
char *buf = new char[size];
|
||||
ADT.read(buf, size);
|
||||
char *p=buf;
|
||||
while (p<buf+size)
|
||||
char *p = buf;
|
||||
while (p < buf + size)
|
||||
{
|
||||
fixnamen(p,strlen(p));
|
||||
fixnamen(p, strlen(p));
|
||||
char* s = GetPlainName(p);
|
||||
fixname2(s,strlen(s));
|
||||
fixname2(s, strlen(s));
|
||||
|
||||
ModelInstansName.push_back(s);
|
||||
|
||||
@@ -139,14 +139,19 @@ bool ADTFile::init(uint32 map_num, uint32 tileX, uint32 tileY)
|
||||
{
|
||||
char* buf = new char[size];
|
||||
ADT.read(buf, size);
|
||||
char* p=buf;
|
||||
while (p<buf+size)
|
||||
char* p = buf;
|
||||
while (p < buf + size)
|
||||
{
|
||||
std::string path(p);
|
||||
|
||||
char* s = GetPlainName(p);
|
||||
fixnamen(s, strlen(s));
|
||||
fixname2(s, strlen(s));
|
||||
p += strlen(p) + 1;
|
||||
WmoInstansName.push_back(s);
|
||||
|
||||
ExtractSingleWmo(path);
|
||||
|
||||
p += strlen(p) + 1;
|
||||
}
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,6 @@ typedef struct
|
||||
}map_id;
|
||||
|
||||
std::vector<map_id> map_ids;
|
||||
std::vector<uint16> LiqType;
|
||||
uint32 map_count;
|
||||
char output_path[128]=".";
|
||||
char input_path[1024]=".";
|
||||
@@ -88,51 +87,6 @@ void strToLower(char* str)
|
||||
}
|
||||
}
|
||||
|
||||
// copied from contrib/extractor/System.cpp
|
||||
void ReadLiquidTypeTableDBC()
|
||||
{
|
||||
printf("Read LiquidType.dbc file...");
|
||||
DBCFile dbc("DBFilesClient\\LiquidType.dbc");
|
||||
if(!dbc.open())
|
||||
{
|
||||
printf("Fatal error: Invalid LiquidType.dbc file format!\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
size_t LiqType_count = dbc.getRecordCount();
|
||||
size_t LiqType_maxid = dbc.getRecord(LiqType_count - 1).getUInt(0);
|
||||
LiqType.resize(LiqType_maxid + 1, 0xFFFF);
|
||||
|
||||
for(uint32 x = 0; x < LiqType_count; ++x)
|
||||
LiqType[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3);
|
||||
|
||||
printf("Done! (%u LiqTypes loaded)\n", (unsigned int)LiqType_count);
|
||||
}
|
||||
|
||||
bool ExtractWmo()
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
//char const* ParsArchiveNames[] = {"patch-2.MPQ", "patch.MPQ", "common.MPQ", "expansion.MPQ"};
|
||||
|
||||
for (ArchiveSet::const_iterator ar_itr = gOpenArchives.begin(); ar_itr != gOpenArchives.end() && success; ++ar_itr)
|
||||
{
|
||||
std::vector<std::string> filelist;
|
||||
|
||||
(*ar_itr)->GetFileListTo(filelist);
|
||||
for (std::vector<std::string>::iterator fname = filelist.begin(); fname != filelist.end() && success; ++fname)
|
||||
{
|
||||
if (fname->find(".wmo") != std::string::npos)
|
||||
success = ExtractSingleWmo(*fname);
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
printf("\nExtract wmo complete (No (fatal) errors)\n");
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ExtractSingleWmo(std::string& fname)
|
||||
{
|
||||
// Copy files from archive
|
||||
@@ -164,7 +118,7 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
return true;
|
||||
|
||||
bool file_ok = true;
|
||||
std::cout << "Extracting " << fname << std::endl;
|
||||
printf("Extracting %s\n", fname.c_str());
|
||||
WMORoot froot(fname);
|
||||
if(!froot.open())
|
||||
{
|
||||
@@ -482,11 +436,6 @@ int main(int argc, char ** argv)
|
||||
printf("FATAL ERROR: None MPQ archive found by path '%s'. Use -d option with proper path.\n", input_path);
|
||||
return 1;
|
||||
}
|
||||
ReadLiquidTypeTableDBC();
|
||||
|
||||
// extract data
|
||||
if (success)
|
||||
success = ExtractWmo();
|
||||
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
//map.dbc
|
||||
|
||||
@@ -79,10 +79,15 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
|
||||
char *p = buf;
|
||||
while (p < buf + size)
|
||||
{
|
||||
std::string path(p);
|
||||
|
||||
char* s = wdtGetPlainName(p);
|
||||
fixnamen(s, strlen(s));
|
||||
fixname2(s, strlen(s));
|
||||
p = p + strlen(p) + 1;
|
||||
gWmoInstansName.push_back(s);
|
||||
|
||||
ExtractSingleWmo(path);
|
||||
}
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
extern std::vector<uint16> LiqType;
|
||||
|
||||
WMORoot::WMORoot(std::string &filename)
|
||||
: filename(filename), color(0), nTextures(0), nGroups(0), nPortals(0), nLights(0),
|
||||
nDoodadNames(0), nDoodadDefs(0), nDoodadSets(0), RootWMOID(0), flags(0)
|
||||
|
||||
@@ -136,8 +136,6 @@ public:
|
||||
uint32 indx, id;
|
||||
|
||||
WMOInstance(MPQFile&f , char const* WmoInstName, uint32 mapID, uint32 tileX, uint32 tileY, FILE* pDirfile);
|
||||
|
||||
static void reset();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user