2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-15 07:26:10 +00:00

Runtime: Make use of std::make_unique where applicable

Makes use of the C++14 make_unique allocation function to allocate class
instances where applicable instead of a reset with a new operator within
it.

This doesn't touch cases where buffers are allocated, given make_unique
would zero-initialize them.
This commit is contained in:
Lioncash
2019-09-11 23:50:38 -04:00
parent d6166ad666
commit f9079f0215
42 changed files with 227 additions and 205 deletions

View File

@@ -51,11 +51,11 @@ CMetroidBeta::CMetroidBeta(TUniqueId uid, std::string_view name, const CEntityIn
, x7fc_(g_SimplePool->GetObj({FOURCC('PART'), metroidData.xfc_}))
, x808_(g_SimplePool->GetObj({FOURCC('PART'), metroidData.x100_}))
, x814_(g_SimplePool->GetObj({FOURCC('PART'), metroidData.x104_}))
, x820_(new CElementGen(x7e4_))
, x824_(new CParticleSwoosh(x7f0_, 0))
, x828_(new CElementGen(x7fc_))
, x82c_(new CElementGen(x808_))
, x830_(new CElementGen(x814_)) {
, x820_(std::make_unique<CElementGen>(x7e4_))
, x824_(std::make_unique<CParticleSwoosh>(x7f0_, 0))
, x828_(std::make_unique<CElementGen>(x7fc_))
, x82c_(std::make_unique<CElementGen>(x808_))
, x830_(std::make_unique<CElementGen>(x814_)) {
x820_->SetParticleEmission(false);
x828_->SetParticleEmission(false);
x82c_->SetParticleEmission(false);
@@ -237,7 +237,8 @@ void CMetroidBeta::CreateCollisionActorManager(CStateManager& mgr) {
std::vector<CJointCollisionDescription> joints;
AddSphereJoints(skPelvisInfo, 1, joints);
x764_collisionManager.reset(new CCollisionActorManager(mgr, GetUniqueId(), GetAreaIdAlways(), joints, false));
x764_collisionManager =
std::make_unique<CCollisionActorManager>(mgr, GetUniqueId(), GetAreaIdAlways(), joints, false);
x764_collisionManager->SetActive(mgr, GetActive());
for (u32 i = 0; i < x764_collisionManager->GetNumCollisionActors(); ++i) {