mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-14 05:59:29 +01:00
Tools/vmap extractor: Skip antiportal WMO groups
This commit is contained in:
@@ -335,6 +335,7 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
WMODoodadData& doodads = WmoDoodads[plain_name];
|
||||
std::swap(doodads, froot.DoodadData);
|
||||
int Wmo_nVertices = 0;
|
||||
uint32 groupCount = 0;
|
||||
//printf("root has %d groups\n", froot->nGroups);
|
||||
if (froot.nGroups !=0)
|
||||
{
|
||||
@@ -356,6 +357,9 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
break;
|
||||
}
|
||||
|
||||
if (fgroup.ShouldSkip(&froot))
|
||||
continue;
|
||||
|
||||
Wmo_nVertices += fgroup.ConvertToVMAPGroupWmo(output, preciseVectorData);
|
||||
for (uint16 groupReference : fgroup.DoodadReferences)
|
||||
{
|
||||
@@ -372,7 +376,8 @@ bool ExtractSingleWmo(std::string& fname)
|
||||
}
|
||||
|
||||
fseek(output, 8, SEEK_SET); // store the correct no of vertices
|
||||
fwrite(&Wmo_nVertices,sizeof(int),1,output);
|
||||
fwrite(&Wmo_nVertices, sizeof(int), 1, output);
|
||||
fwrite(&groupCount, sizeof(uint32), 1, output);
|
||||
fclose(output);
|
||||
|
||||
// Delete the extracted file in the case of an error
|
||||
|
||||
@@ -74,6 +74,11 @@ bool WMORoot::open()
|
||||
f.read(bbcorn2, 12);
|
||||
f.read(&flags, 4);
|
||||
}
|
||||
else if (!strcmp(fourcc, "MOGN"))
|
||||
{
|
||||
GroupNames.resize(size);
|
||||
f.read(GroupNames.data(), size);
|
||||
}
|
||||
else if (!strcmp(fourcc, "MODS"))
|
||||
{
|
||||
DoodadData.Sets.resize(size / sizeof(WMO::MODS));
|
||||
@@ -112,9 +117,6 @@ bool WMORoot::open()
|
||||
else if (!strcmp(fourcc,"MOMT"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOGN"))
|
||||
{
|
||||
}
|
||||
else if (!strcmp(fourcc,"MOGI"))
|
||||
{
|
||||
}
|
||||
@@ -156,8 +158,8 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE* pOutfile)
|
||||
}
|
||||
|
||||
WMOGroup::WMOGroup(const std::string& filename) :
|
||||
filename(filename), MOPY(0), MOVI(0), MoviEx(0), MOVT(0), MOBA(0), MobaEx(0),
|
||||
hlq(0), LiquEx(0), LiquBytes(0), groupName(0), descGroupName(0), mogpFlags(0),
|
||||
filename(filename), MOPY(nullptr), MOVI(nullptr), MoviEx(nullptr), MOVT(nullptr), MOBA(nullptr), MobaEx(nullptr),
|
||||
hlq(nullptr), LiquEx(nullptr), LiquBytes(nullptr), groupName(0), descGroupName(0), mogpFlags(0),
|
||||
moprIdx(0), moprNItems(0), nBatchA(0), nBatchB(0), nBatchC(0), fogIdx(0),
|
||||
groupLiquid(0), groupWMOID(0), mopy_size(0), moba_size(0), LiquEx_size(0),
|
||||
nVertices(0), nTriangles(0), liquflags(0)
|
||||
@@ -175,17 +177,15 @@ bool WMOGroup::open(WMORoot* rootWMO)
|
||||
return false;
|
||||
}
|
||||
uint32 size;
|
||||
char fourcc[5];
|
||||
char fourcc[5] = { };
|
||||
while (!f.isEof())
|
||||
{
|
||||
f.read(fourcc, 4);
|
||||
f.read(&size, 4);
|
||||
flipcc(fourcc);
|
||||
if (!strcmp(fourcc, "MOGP"))//Fix sizeoff = Data size.
|
||||
{
|
||||
if (!strcmp(fourcc,"MOGP")) //size specified in MOGP chunk is all the other chunks combined, adjust to read MOGP-only
|
||||
size = 68;
|
||||
}
|
||||
fourcc[4] = 0;
|
||||
|
||||
size_t nextpos = f.getPos() + size;
|
||||
if (!strcmp(fourcc, "MOGP"))//header
|
||||
{
|
||||
@@ -494,6 +494,18 @@ uint32 WMOGroup::GetLiquidTypeId(uint32 liquidTypeId)
|
||||
return liquidTypeId;
|
||||
}
|
||||
|
||||
bool WMOGroup::ShouldSkip(WMORoot const* root) const
|
||||
{
|
||||
// skip antiportals
|
||||
if (mogpFlags & 0x4000000)
|
||||
return true;
|
||||
|
||||
if (groupName < int32(root->GroupNames.size()) && !strcmp(&root->GroupNames[groupName], "antiportal"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
WMOGroup::~WMOGroup()
|
||||
{
|
||||
delete[] MOPY;
|
||||
|
||||
@@ -85,6 +85,7 @@ public:
|
||||
float bbcorn1[3];
|
||||
float bbcorn2[3];
|
||||
|
||||
std::vector<char> GroupNames;
|
||||
WMODoodadData DoodadData;
|
||||
std::unordered_set<uint32> ValidDoodadNames;
|
||||
|
||||
@@ -154,6 +155,7 @@ public:
|
||||
bool open(WMORoot* rootWMO);
|
||||
int ConvertToVMAPGroupWmo(FILE* output, bool preciseVectorData);
|
||||
uint32 GetLiquidTypeId(uint32 liquidTypeId);
|
||||
bool ShouldSkip(WMORoot const* root) const;
|
||||
};
|
||||
|
||||
namespace MapObject
|
||||
|
||||
Reference in New Issue
Block a user