From f22be111ae0a1b2dd51418b0790fab1c8f2f9df7 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 3 Dec 2022 23:30:53 +0100 Subject: Tools/vmap_extractor: Implemented new MPY2 wmo chunk --- src/tools/vmap4_extractor/wmo.cpp | 24 +++++++++++++++--------- src/tools/vmap4_extractor/wmo.h | 4 ++-- 2 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/tools/vmap4_extractor/wmo.cpp b/src/tools/vmap4_extractor/wmo.cpp index fc4265cda59..85f82038da2 100644 --- a/src/tools/vmap4_extractor/wmo.cpp +++ b/src/tools/vmap4_extractor/wmo.cpp @@ -204,10 +204,10 @@ bool WMORoot::ConvertToVMAPRootWmo(FILE* pOutfile) } WMOGroup::WMOGroup(const std::string &filename) : - filename(filename), MOPY(nullptr), MOVX(nullptr), MOVT(nullptr), MOBA(nullptr), MobaEx(nullptr), + filename(filename), MPY2(nullptr), MOVX(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), + groupLiquid(0), groupWMOID(0), moba_size(0), LiquEx_size(0), nVertices(0), nTriangles(0), liquflags(0) { memset(bbcorn1, 0, sizeof(bbcorn1)); @@ -262,10 +262,17 @@ bool WMOGroup::open(WMORoot* rootWMO) } else if (!strcmp(fourcc,"MOPY")) { - MOPY = new char[size]; - mopy_size = size; + MPY2 = std::make_unique(size); + std::unique_ptr MOPY = std::make_unique(size); nTriangles = (int)size / 2; - f.read(MOPY, size); + f.read(MOPY.get(), size); + std::copy_n(MOPY.get(), size, MPY2.get()); + } + else if (!strcmp(fourcc,"MPY2")) + { + MPY2 = std::make_unique(size / 2); + nTriangles = (int)size / 4; + f.read(MPY2.get(), size); } else if (!strcmp(fourcc,"MOVI")) { @@ -440,15 +447,15 @@ int WMOGroup::ConvertToVMAPGroupWmo(FILE* output, bool preciseVectorData) delete [] MobaEx; //-------INDX------------------------------------ - //-------MOPY-------- + //-------MOPY/MPY2-------- std::unique_ptr MovxEx = std::make_unique(nTriangles*3); // "worst case" size... std::unique_ptr IndexRenum = std::make_unique(nVertices); std::fill_n(IndexRenum.get(), nVertices, -1); for (int i=0; i MPY2; std::unique_ptr MOVX; float* MOVT; uint16* MOBA; @@ -142,7 +142,7 @@ public: uint16 nBatchB; uint32 nBatchC, fogIdx, groupLiquid, groupWMOID; - int mopy_size, moba_size; + int moba_size; int LiquEx_size; unsigned int nVertices; // number when loaded int nTriangles; // number when loaded -- cgit v1.2.3