mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-09 07:07:42 +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:
@@ -76,18 +76,18 @@ public:
|
||||
CGameGlobalObjects(IFactory* resFactory, CSimplePool* objStore)
|
||||
: x4_resFactory(resFactory), xcc_simplePool(objStore) {
|
||||
if (!x4_resFactory) {
|
||||
m_gameResFactory.reset(new CResFactory());
|
||||
m_gameResFactory = std::make_unique<CResFactory>();
|
||||
x4_resFactory = m_gameResFactory.get();
|
||||
}
|
||||
if (!xcc_simplePool) {
|
||||
m_gameSimplePool.reset(new CSimplePool(*x4_resFactory));
|
||||
m_gameSimplePool = std::make_unique<CSimplePool>(*x4_resFactory);
|
||||
xcc_simplePool = m_gameSimplePool.get();
|
||||
}
|
||||
g_ResFactory = x4_resFactory;
|
||||
g_SimplePool = xcc_simplePool;
|
||||
g_CharFactoryBuilder = &xec_charFactoryBuilder;
|
||||
g_AiFuncMap = &x110_aiFuncMap;
|
||||
x134_gameState.reset(new CGameState());
|
||||
x134_gameState = std::make_unique<CGameState>();
|
||||
g_GameState = x134_gameState.get();
|
||||
g_TweakManager = &x150_tweakManager;
|
||||
}
|
||||
@@ -104,12 +104,12 @@ public:
|
||||
}
|
||||
|
||||
void ResetGameState() {
|
||||
x134_gameState.reset(new CGameState());
|
||||
x134_gameState = std::make_unique<CGameState>();
|
||||
g_GameState = x134_gameState.get();
|
||||
}
|
||||
|
||||
void StreamInGameState(CBitStreamReader& stream, u32 saveIdx) {
|
||||
x134_gameState.reset(new CGameState(stream, saveIdx));
|
||||
x134_gameState = std::make_unique<CGameState>(stream, saveIdx);
|
||||
g_GameState = x134_gameState.get();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user