CCollisionLoader: Make LoadAreaCollision() return a unique_ptr
Same behavior, less boilerplate
This commit is contained in:
parent
55eee5da65
commit
d0bd7eb292
|
@ -621,8 +621,7 @@ void CAreaLoader::LoadSectionDataBuffers()
|
|||
void CAreaLoader::ReadCollision()
|
||||
{
|
||||
mpSectionMgr->ToSection(mCollisionBlockNum);
|
||||
CCollisionMeshGroup* pAreaCollision = CCollisionLoader::LoadAreaCollision(*mpMREA);
|
||||
mpArea->mpCollision = std::unique_ptr<CCollisionMeshGroup>(pAreaCollision);
|
||||
mpArea->mpCollision = CCollisionLoader::LoadAreaCollision(*mpMREA);
|
||||
}
|
||||
|
||||
void CAreaLoader::ReadPATH()
|
||||
|
|
|
@ -189,9 +189,11 @@ void CCollisionLoader::LoadCollisionIndices(IInputStream& File, SCollisionIndexD
|
|||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
CCollisionMeshGroup* CCollisionLoader::LoadAreaCollision(IInputStream& rMREA)
|
||||
std::unique_ptr<CCollisionMeshGroup> 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<CCollisionMeshGroup>();
|
||||
pOut->AddMesh(Loader.mpMesh);
|
||||
return pOut;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ class CCollisionLoader
|
|||
void LoadCollisionIndices(IInputStream& File, SCollisionIndexData& OutData);
|
||||
|
||||
public:
|
||||
static CCollisionMeshGroup* LoadAreaCollision(IInputStream& rMREA);
|
||||
static std::unique_ptr<CCollisionMeshGroup> LoadAreaCollision(IInputStream& rMREA);
|
||||
static std::unique_ptr<CCollisionMeshGroup> LoadDCLN(IInputStream& rDCLN, CResourceEntry *pEntry);
|
||||
static EGame GetFormatVersion(uint32 Version);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue