diff --git a/src/Core/Resource/Factory/CAreaLoader.cpp b/src/Core/Resource/Factory/CAreaLoader.cpp index a35b218b..d8b90f49 100644 --- a/src/Core/Resource/Factory/CAreaLoader.cpp +++ b/src/Core/Resource/Factory/CAreaLoader.cpp @@ -621,8 +621,7 @@ void CAreaLoader::LoadSectionDataBuffers() void CAreaLoader::ReadCollision() { mpSectionMgr->ToSection(mCollisionBlockNum); - CCollisionMeshGroup* pAreaCollision = CCollisionLoader::LoadAreaCollision(*mpMREA); - mpArea->mpCollision = std::unique_ptr(pAreaCollision); + mpArea->mpCollision = CCollisionLoader::LoadAreaCollision(*mpMREA); } void CAreaLoader::ReadPATH() diff --git a/src/Core/Resource/Factory/CCollisionLoader.cpp b/src/Core/Resource/Factory/CCollisionLoader.cpp index ff09ae75..80039eb9 100644 --- a/src/Core/Resource/Factory/CCollisionLoader.cpp +++ b/src/Core/Resource/Factory/CCollisionLoader.cpp @@ -189,9 +189,11 @@ void CCollisionLoader::LoadCollisionIndices(IInputStream& File, SCollisionIndexD } // ************ STATIC ************ -CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(IInputStream& rMREA) +std::unique_ptr CCollisionLoader::LoadAreaCollision(IInputStream& rMREA) { - if (!rMREA.IsValid()) return nullptr; + if (!rMREA.IsValid()) + return nullptr; + rMREA.Skip(0x8); // Skipping unknown value + collion section size // Validate magic @@ -215,7 +217,7 @@ CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(IInputStream& rMREA) // Read collision indices and return Loader.LoadCollisionIndices(rMREA, Loader.mpMesh->mIndexData); - CCollisionMeshGroup* pOut = new CCollisionMeshGroup(); + auto pOut = std::make_unique(); pOut->AddMesh(Loader.mpMesh); return pOut; } diff --git a/src/Core/Resource/Factory/CCollisionLoader.h b/src/Core/Resource/Factory/CCollisionLoader.h index 7283a8fa..b39e85ed 100644 --- a/src/Core/Resource/Factory/CCollisionLoader.h +++ b/src/Core/Resource/Factory/CCollisionLoader.h @@ -25,7 +25,7 @@ class CCollisionLoader void LoadCollisionIndices(IInputStream& File, SCollisionIndexData& OutData); public: - static CCollisionMeshGroup* LoadAreaCollision(IInputStream& rMREA); + static std::unique_ptr LoadAreaCollision(IInputStream& rMREA); static std::unique_ptr LoadDCLN(IInputStream& rDCLN, CResourceEntry *pEntry); static EGame GetFormatVersion(uint32 Version); };