2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 19:44:55 +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

@@ -72,18 +72,21 @@ public:
}
std::unique_ptr<CActorLights> MakeActorLights() const {
if (!x1c_makeLights)
return {};
if (!x1c_makeLights) {
return nullptr;
}
u32 updateFrames = GetFramesBetweenRecalculation(x24_lightRecalcOpts);
CActorLights* lights = new CActorLights(updateFrames, x2c_actorPosBias, x38_maxDynamicLights, x3c_maxAreaLights,
x1d_ambientChannelOverflow, x28_layerIdx == 1,
x20_worldLightingOptions == EWorldLightingOptions::DisableWorld, 0.1f);
if (x20_worldLightingOptions == EWorldLightingOptions::NoShadowCast)
const u32 updateFrames = GetFramesBetweenRecalculation(x24_lightRecalcOpts);
auto lights = std::make_unique<CActorLights>(updateFrames, x2c_actorPosBias, x38_maxDynamicLights,
x3c_maxAreaLights, x1d_ambientChannelOverflow, x28_layerIdx == 1,
x20_worldLightingOptions == EWorldLightingOptions::DisableWorld, 0.1f);
if (x20_worldLightingOptions == EWorldLightingOptions::NoShadowCast) {
lights->SetCastShadows(false);
if (x3c_maxAreaLights == 0)
}
if (x3c_maxAreaLights == 0) {
lights->SetAmbientColor(x18_noLightsAmbient);
return std::unique_ptr<CActorLights>(lights);
}
return lights;
}
const zeus::CColor& GetNoLightsAmbient() const { return x18_noLightsAmbient; }
};