feat(Tools/Vmapextractor): Improved vmap detail level by extracting w… (#4922)

This commit is contained in:
UltraNix
2021-04-05 11:51:51 +02:00
committed by GitHub
parent 1b4c36ec52
commit 0528e0b485
20 changed files with 514 additions and 369 deletions

View File

@@ -7,6 +7,7 @@
#include "vmapexport.h"
#include "wdtfile.h"
#include "adtfile.h"
#include <cstdio>
char* wdtGetPlainName(char* FileName)
@@ -18,14 +19,14 @@ char* wdtGetPlainName(char* FileName)
return FileName;
}
WDTFile::WDTFile(char* file_name, char* file_name1) : WDT(file_name), gWmoInstansName(nullptr), gnWMO(0)
WDTFile::WDTFile(char* file_name, char* file_name1) : _file(file_name)
{
filename.append(file_name1, strlen(file_name1));
}
bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
bool WDTFile::init(uint32 mapId)
{
if (WDT.isEof())
if (_file.isEof())
{
//printf("Can't find WDT file.\n");
return false;
@@ -43,15 +44,15 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
return false;
}
while (!WDT.isEof())
while (!_file.isEof())
{
WDT.read(fourcc, 4);
WDT.read(&size, 4);
_file.read(fourcc, 4);
_file.read(&size, 4);
flipcc(fourcc);
fourcc[4] = 0;
size_t nextpos = WDT.getPos() + size;
size_t nextpos = _file.getPos() + size;
if (!strcmp(fourcc, "MAIN"))
{
@@ -62,16 +63,19 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
if (size)
{
char* buf = new char[size];
WDT.read(buf, size);
_file.read(buf, size);
char* p = buf;
int q = 0;
gWmoInstansName = new string[size];
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[q++] = s;
_wmoNames.push_back(s);
ExtractSingleWmo(path);
}
delete[] buf;
}
@@ -81,29 +85,27 @@ bool WDTFile::init(char* /*map_id*/, unsigned int mapID)
// global wmo instance data
if (size)
{
gnWMO = (int)size / 64;
for (int i = 0; i < gnWMO; ++i)
uint32 mapObjectCount = size / sizeof(ADT::MODF);
for (uint32 i = 0; i < mapObjectCount; ++i)
{
int id;
WDT.read(&id, 4);
WMOInstance inst(WDT, gWmoInstansName[id].c_str(), mapID, 65, 65, dirfile);
ADT::MODF mapObjDef;
_file.read(&mapObjDef, sizeof(ADT::MODF));
MapObject::Extract(mapObjDef, _wmoNames[mapObjDef.Id].c_str(), mapId, 65, 65, dirfile);
Doodad::ExtractSet(WmoDoodads[_wmoNames[mapObjDef.Id]], mapObjDef, mapId, 65, 65, dirfile);
}
delete[] gWmoInstansName;
}
}
WDT.seek((int)nextpos);
_file.seek((int)nextpos);
}
WDT.close();
_file.close();
fclose(dirfile);
return true;
}
WDTFile::~WDTFile()
{
WDT.close();
_file.close();
}
ADTFile* WDTFile::GetMap(int x, int z)