2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-11 02:27:43 +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

@@ -32,7 +32,7 @@ CActor::CActor(TUniqueId uid, bool active, std::string_view name, const CEntityI
, x68_material(MakeActorMaterialList(list, params))
, x70_materialFilter(CMaterialFilter::MakeIncludeExclude({EMaterialTypes::Solid}, {0ull}))
, xc6_nextDrawNode(otherUid) {
x90_actorLights = mData.IsNull() ? std::unique_ptr<CActorLights>() : params.x0_lightParms.MakeActorLights();
x90_actorLights = mData.IsNull() ? nullptr : params.x0_lightParms.MakeActorLights();
if (mData.x10_animData || mData.x1c_normalModel)
x64_modelData = std::make_unique<CModelData>(std::move(mData));
xd0_damageMag = params.x64_thermalMag;
@@ -431,8 +431,9 @@ void CActor::CreateShadow(bool b) {
}
void CActor::_CreateShadow() {
if (!x94_simpleShadow && x64_modelData && (x64_modelData->HasAnimData() || x64_modelData->HasNormalModel()))
x94_simpleShadow.reset(new CSimpleShadow(1.f, 1.f, 20.f, 0.05f));
if (!x94_simpleShadow && x64_modelData && (x64_modelData->HasAnimData() || x64_modelData->HasNormalModel())) {
x94_simpleShadow = std::make_unique<CSimpleShadow>(1.f, 1.f, 20.f, 0.05f);
}
}
void CActor::_CreateReflectionCube() {