2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 15:07:41 +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

@@ -54,7 +54,7 @@ CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntity
if (partId.IsValid()) {
xf8_particleSystemToken = g_SimplePool->GetObj({FOURCC('PART'), partId});
x104_particleSystem.reset(new CElementGen(xf8_particleSystemToken));
x104_particleSystem = std::make_unique<CElementGen>(xf8_particleSystemToken);
zeus::CTransform newXf = xf;
newXf.origin = zeus::skZero3f;
x104_particleSystem->SetOrientation(newXf);
@@ -67,7 +67,7 @@ CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntity
if (elscId.IsValid()) {
xe8_electricToken = g_SimplePool->GetObj({FOURCC('ELSC'), elscId});
xf4_electric.reset(new CParticleElectric(xe8_electricToken));
xf4_electric = std::make_unique<CParticleElectric>(xe8_electricToken);
zeus::CTransform newXf = xf;
newXf.origin = zeus::skZero3f;
xf4_electric->SetOrientation(newXf);
@@ -87,9 +87,9 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
case EScriptObjectMessage::Activate:
if (x110_26_rebuildSystemsOnActivate) {
if (x104_particleSystem) {
zeus::CVector3f scale = x104_particleSystem->GetGlobalScale();
zeus::CColor color = x104_particleSystem->GetModulationColor();
x104_particleSystem.reset(new CElementGen(xf8_particleSystemToken));
const zeus::CVector3f scale = x104_particleSystem->GetGlobalScale();
const zeus::CColor color = x104_particleSystem->GetModulationColor();
x104_particleSystem = std::make_unique<CElementGen>(xf8_particleSystemToken);
zeus::CTransform newXf = GetTransform();
newXf.origin = zeus::skZero3f;
x104_particleSystem->SetOrientation(newXf);
@@ -101,9 +101,9 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
}
if (xf4_electric) {
zeus::CVector3f scale = xf4_electric->GetGlobalScale();
zeus::CColor color = xf4_electric->GetModulationColor();
xf4_electric.reset(new CParticleElectric(xe8_electricToken));
const zeus::CVector3f scale = xf4_electric->GetGlobalScale();
const zeus::CColor color = xf4_electric->GetModulationColor();
xf4_electric = std::make_unique<CParticleElectric>(xe8_electricToken);
zeus::CTransform newXf = GetTransform();
newXf.origin = zeus::skZero3f;
xf4_electric->SetOrientation(newXf);