mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 09:47: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:
@@ -71,7 +71,7 @@ CStateManager::CStateManager(const std::weak_ptr<CRelayTracker>& relayTracker,
|
||||
, x8c0_mapWorldInfo(mwInfo)
|
||||
, x8c4_worldTransManager(wtMgr)
|
||||
, x8c8_worldLayerState(layerState) {
|
||||
x86c_stateManagerContainer.reset(new CStateManagerContainer);
|
||||
x86c_stateManagerContainer = std::make_unique<CStateManagerContainer>();
|
||||
x870_cameraManager = &x86c_stateManagerContainer->x0_cameraManager;
|
||||
x874_sortedListManager = &x86c_stateManagerContainer->x3c0_sortedListManager;
|
||||
x878_weaponManager = &x86c_stateManagerContainer->xe3d8_weaponManager;
|
||||
@@ -2146,7 +2146,7 @@ void CStateManager::InitializeState(CAssetId mlvlId, TAreaId aid, CAssetId mreaI
|
||||
|
||||
if (xb3c_initPhase == EInitPhase::LoadWorld) {
|
||||
CreateStandardGameObjects();
|
||||
x850_world.reset(new CWorld(*g_SimplePool, *g_ResFactory, mlvlId));
|
||||
x850_world = std::make_unique<CWorld>(*g_SimplePool, *g_ResFactory, mlvlId);
|
||||
xb3c_initPhase = EInitPhase::LoadFirstArea;
|
||||
}
|
||||
|
||||
@@ -2216,17 +2216,18 @@ void CStateManager::InitializeState(CAssetId mlvlId, TAreaId aid, CAssetId mreaI
|
||||
}
|
||||
|
||||
void CStateManager::CreateStandardGameObjects() {
|
||||
float height = g_tweakPlayer->GetPlayerHeight();
|
||||
float xyHe = g_tweakPlayer->GetPlayerXYHalfExtent();
|
||||
float stepUp = g_tweakPlayer->GetStepUpHeight();
|
||||
float stepDown = g_tweakPlayer->GetStepDownHeight();
|
||||
float ballRadius = g_tweakPlayer->GetPlayerBallHalfExtent();
|
||||
zeus::CAABox pBounds = {{-xyHe, -xyHe, 0.f}, {xyHe, xyHe, height}};
|
||||
auto q = zeus::CQuaternion::fromAxisAngle(zeus::CVector3f{0.f, 0.f, 1.f}, zeus::degToRad(129.6f));
|
||||
x84c_player.reset(
|
||||
new CPlayer(AllocateUniqueId(), zeus::CTransform(q), pBounds, g_tweakPlayerRes->xc4_ballTransitionsANCS,
|
||||
zeus::CVector3f{1.65f, 1.65f, 1.65f}, 200.f, stepUp, stepDown, ballRadius,
|
||||
CMaterialList(EMaterialTypes::Player, EMaterialTypes::Solid, EMaterialTypes::GroundCollider)));
|
||||
const float height = g_tweakPlayer->GetPlayerHeight();
|
||||
const float xyHe = g_tweakPlayer->GetPlayerXYHalfExtent();
|
||||
const float stepUp = g_tweakPlayer->GetStepUpHeight();
|
||||
const float stepDown = g_tweakPlayer->GetStepDownHeight();
|
||||
const float ballRadius = g_tweakPlayer->GetPlayerBallHalfExtent();
|
||||
const zeus::CAABox pBounds = {{-xyHe, -xyHe, 0.f}, {xyHe, xyHe, height}};
|
||||
const auto q = zeus::CQuaternion::fromAxisAngle(zeus::CVector3f{0.f, 0.f, 1.f}, zeus::degToRad(129.6f));
|
||||
|
||||
x84c_player = std::make_unique<CPlayer>(
|
||||
AllocateUniqueId(), zeus::CTransform(q), pBounds, g_tweakPlayerRes->xc4_ballTransitionsANCS,
|
||||
zeus::CVector3f{1.65f, 1.65f, 1.65f}, 200.f, stepUp, stepDown, ballRadius,
|
||||
CMaterialList(EMaterialTypes::Player, EMaterialTypes::Solid, EMaterialTypes::GroundCollider));
|
||||
AddObject(*x84c_player);
|
||||
x870_cameraManager->CreateStandardCameras(*this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user