mirror of https://github.com/AxioDL/metaforce.git
Merge pull request #213 from lioncash/unique
CProjectileWeaponDataFactory: Make GetGeneratorDesc() return a unique_ptr
This commit is contained in:
commit
97e33bdf11
|
@ -12,19 +12,21 @@ namespace urde {
|
||||||
static logvisor::Module Log("urde::CDecalDataFactory");
|
static logvisor::Module Log("urde::CDecalDataFactory");
|
||||||
|
|
||||||
using CPF = CParticleDataFactory;
|
using CPF = CParticleDataFactory;
|
||||||
CDecalDescription* CDecalDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) {
|
std::unique_ptr<CDecalDescription> CDecalDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) {
|
||||||
return CreateGeneratorDescription(in, resPool);
|
return CreateGeneratorDescription(in, resPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
CDecalDescription* CDecalDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool) {
|
std::unique_ptr<CDecalDescription> CDecalDataFactory::CreateGeneratorDescription(CInputStream& in,
|
||||||
FourCC clsId = CPF::GetClassID(in);
|
CSimplePool* resPool) {
|
||||||
|
const FourCC clsId = CPF::GetClassID(in);
|
||||||
|
|
||||||
if (clsId == FOURCC('DPSM')) {
|
if (clsId == FOURCC('DPSM')) {
|
||||||
CDecalDescription* desc = new CDecalDescription;
|
auto desc = std::make_unique<CDecalDescription>();
|
||||||
if (CreateDPSM(desc, in, resPool))
|
if (CreateDPSM(desc.get(), in, resPool)) {
|
||||||
return desc;
|
return desc;
|
||||||
else
|
}
|
||||||
delete desc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +131,6 @@ void CDecalDataFactory::GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool,
|
||||||
CFactoryFnReturn FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
CFactoryFnReturn FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||||
CObjectReference*) {
|
CObjectReference*) {
|
||||||
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
||||||
return TToken<CDecalDescription>::GetIObjObjectFor(
|
return TToken<CDecalDescription>::GetIObjObjectFor(CDecalDataFactory::GetGeneratorDesc(in, sp));
|
||||||
std::unique_ptr<CDecalDescription>(CDecalDataFactory::GetGeneratorDesc(in, sp)));
|
|
||||||
}
|
}
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "Runtime/CFactoryMgr.hpp"
|
#include "Runtime/CFactoryMgr.hpp"
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
#include "Runtime/IObj.hpp"
|
#include "Runtime/IObj.hpp"
|
||||||
|
@ -12,11 +14,11 @@ class CSimplePool;
|
||||||
|
|
||||||
class CDecalDataFactory {
|
class CDecalDataFactory {
|
||||||
static bool CreateDPSM(CDecalDescription* desc, CInputStream& in, CSimplePool* resPool);
|
static bool CreateDPSM(CDecalDescription* desc, CInputStream& in, CSimplePool* resPool);
|
||||||
static CDecalDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool);
|
static std::unique_ptr<CDecalDescription> CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool);
|
||||||
static void GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, SQuadDescr& quad);
|
static void GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, SQuadDescr& quad);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CDecalDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
static std::unique_ptr<CDecalDescription> GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
||||||
};
|
};
|
||||||
|
|
||||||
CFactoryFnReturn FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
CFactoryFnReturn FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||||
|
|
|
@ -13,20 +13,24 @@ static logvisor::Module Log("urde::CParticleElectricDataFactory");
|
||||||
|
|
||||||
using CPF = CParticleDataFactory;
|
using CPF = CParticleDataFactory;
|
||||||
|
|
||||||
CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) {
|
std::unique_ptr<CElectricDescription> CParticleElectricDataFactory::GetGeneratorDesc(CInputStream& in,
|
||||||
|
CSimplePool* resPool) {
|
||||||
return CreateElectricDescription(in, resPool);
|
return CreateElectricDescription(in, resPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
CElectricDescription* CParticleElectricDataFactory::CreateElectricDescription(CInputStream& in, CSimplePool* resPool) {
|
std::unique_ptr<CElectricDescription> CParticleElectricDataFactory::CreateElectricDescription(CInputStream& in,
|
||||||
FourCC cid = CPF::GetClassID(in);
|
CSimplePool* resPool) {
|
||||||
if (cid == FOURCC('ELSM')) {
|
const FourCC cid = CPF::GetClassID(in);
|
||||||
CElectricDescription* desc = new CElectricDescription;
|
|
||||||
CreateELSM(desc, in, resPool);
|
if (cid != FOURCC('ELSM')) {
|
||||||
LoadELSMTokens(desc);
|
return nullptr;
|
||||||
return desc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
auto desc = std::make_unique<CElectricDescription>();
|
||||||
|
CreateELSM(desc.get(), in, resPool);
|
||||||
|
LoadELSMTokens(desc.get());
|
||||||
|
return desc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CParticleElectricDataFactory::CreateELSM(CElectricDescription* desc, CInputStream& in, CSimplePool* resPool) {
|
bool CParticleElectricDataFactory::CreateELSM(CElectricDescription* desc, CInputStream& in, CSimplePool* resPool) {
|
||||||
|
@ -124,7 +128,6 @@ void CParticleElectricDataFactory::LoadELSMTokens(CElectricDescription* desc) {
|
||||||
CFactoryFnReturn FParticleElectricDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
CFactoryFnReturn FParticleElectricDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||||
CObjectReference*) {
|
CObjectReference*) {
|
||||||
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
||||||
return TToken<CElectricDescription>::GetIObjObjectFor(
|
return TToken<CElectricDescription>::GetIObjObjectFor(CParticleElectricDataFactory::GetGeneratorDesc(in, sp));
|
||||||
std::unique_ptr<CElectricDescription>(CParticleElectricDataFactory::GetGeneratorDesc(in, sp)));
|
|
||||||
}
|
}
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "Runtime/CFactoryMgr.hpp"
|
#include "Runtime/CFactoryMgr.hpp"
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
#include "Runtime/IOStreams.hpp"
|
#include "Runtime/IOStreams.hpp"
|
||||||
|
@ -10,12 +12,12 @@ namespace urde {
|
||||||
class CElectricDescription;
|
class CElectricDescription;
|
||||||
class CSimplePool;
|
class CSimplePool;
|
||||||
class CParticleElectricDataFactory {
|
class CParticleElectricDataFactory {
|
||||||
static CElectricDescription* CreateElectricDescription(CInputStream& in, CSimplePool* resPool);
|
static std::unique_ptr<CElectricDescription> CreateElectricDescription(CInputStream& in, CSimplePool* resPool);
|
||||||
static bool CreateELSM(CElectricDescription* desc, CInputStream& in, CSimplePool* resPool);
|
static bool CreateELSM(CElectricDescription* desc, CInputStream& in, CSimplePool* resPool);
|
||||||
static void LoadELSMTokens(CElectricDescription* desc);
|
static void LoadELSMTokens(CElectricDescription* desc);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CElectricDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
static std::unique_ptr<CElectricDescription> GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
||||||
};
|
};
|
||||||
|
|
||||||
CFactoryFnReturn FParticleElectricDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
CFactoryFnReturn FParticleElectricDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||||
|
|
|
@ -12,19 +12,22 @@ static logvisor::Module Log("urde::CParticleSwooshDataFactory");
|
||||||
|
|
||||||
using CPF = CParticleDataFactory;
|
using CPF = CParticleDataFactory;
|
||||||
|
|
||||||
CSwooshDescription* CParticleSwooshDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) {
|
std::unique_ptr<CSwooshDescription> CParticleSwooshDataFactory::GetGeneratorDesc(CInputStream& in,
|
||||||
|
CSimplePool* resPool) {
|
||||||
return CreateGeneratorDescription(in, resPool);
|
return CreateGeneratorDescription(in, resPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSwooshDescription* CParticleSwooshDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool) {
|
std::unique_ptr<CSwooshDescription> CParticleSwooshDataFactory::CreateGeneratorDescription(CInputStream& in,
|
||||||
FourCC clsId = CPF::GetClassID(in);
|
CSimplePool* resPool) {
|
||||||
|
const FourCC clsId = CPF::GetClassID(in);
|
||||||
|
|
||||||
if (clsId == FOURCC('SWSH')) {
|
if (clsId == FOURCC('SWSH')) {
|
||||||
CSwooshDescription* desc = new CSwooshDescription;
|
auto desc = std::make_unique<CSwooshDescription>();
|
||||||
if (CreateWPSM(desc, in, resPool))
|
if (CreateWPSM(desc.get(), in, resPool)) {
|
||||||
return desc;
|
return desc;
|
||||||
else
|
}
|
||||||
delete desc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +135,6 @@ bool CParticleSwooshDataFactory::CreateWPSM(CSwooshDescription* desc, CInputStre
|
||||||
CFactoryFnReturn FParticleSwooshDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
CFactoryFnReturn FParticleSwooshDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||||
CObjectReference*) {
|
CObjectReference*) {
|
||||||
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
||||||
return TToken<CSwooshDescription>::GetIObjObjectFor(
|
return TToken<CSwooshDescription>::GetIObjObjectFor(CParticleSwooshDataFactory::GetGeneratorDesc(in, sp));
|
||||||
std::unique_ptr<CSwooshDescription>(CParticleSwooshDataFactory::GetGeneratorDesc(in, sp)));
|
|
||||||
}
|
}
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "Runtime/CFactoryMgr.hpp"
|
#include "Runtime/CFactoryMgr.hpp"
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
#include "Runtime/IOStreams.hpp"
|
#include "Runtime/IOStreams.hpp"
|
||||||
|
@ -10,11 +12,11 @@ namespace urde {
|
||||||
class CSwooshDescription;
|
class CSwooshDescription;
|
||||||
class CSimplePool;
|
class CSimplePool;
|
||||||
class CParticleSwooshDataFactory {
|
class CParticleSwooshDataFactory {
|
||||||
static CSwooshDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool);
|
static std::unique_ptr<CSwooshDescription> CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool);
|
||||||
static bool CreateWPSM(CSwooshDescription* desc, CInputStream& in, CSimplePool* resPool);
|
static bool CreateWPSM(CSwooshDescription* desc, CInputStream& in, CSimplePool* resPool);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CSwooshDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
static std::unique_ptr<CSwooshDescription> GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
||||||
};
|
};
|
||||||
|
|
||||||
CFactoryFnReturn FParticleSwooshDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
CFactoryFnReturn FParticleSwooshDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||||
|
|
|
@ -14,19 +14,22 @@ static logvisor::Module Log("urde::CProjectileWeaponDataFactory");
|
||||||
|
|
||||||
using CPF = CParticleDataFactory;
|
using CPF = CParticleDataFactory;
|
||||||
|
|
||||||
CWeaponDescription* CProjectileWeaponDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) {
|
std::unique_ptr<CWeaponDescription> CProjectileWeaponDataFactory::GetGeneratorDesc(CInputStream& in,
|
||||||
|
CSimplePool* resPool) {
|
||||||
return CreateGeneratorDescription(in, resPool);
|
return CreateGeneratorDescription(in, resPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
CWeaponDescription* CProjectileWeaponDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool) {
|
std::unique_ptr<CWeaponDescription> CProjectileWeaponDataFactory::CreateGeneratorDescription(CInputStream& in,
|
||||||
FourCC clsId = CPF::GetClassID(in);
|
CSimplePool* resPool) {
|
||||||
if (clsId == FOURCC('WPSM')) {
|
const FourCC clsId = CPF::GetClassID(in);
|
||||||
CWeaponDescription* desc = new CWeaponDescription;
|
if (clsId != FOURCC('WPSM')) {
|
||||||
CreateWPSM(desc, in, resPool);
|
return nullptr;
|
||||||
return desc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
auto desc = std::make_unique<CWeaponDescription>();
|
||||||
|
CreateWPSM(desc.get(), in, resPool);
|
||||||
|
return desc;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputStream& in, CSimplePool* resPool) {
|
bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputStream& in, CSimplePool* resPool) {
|
||||||
|
@ -159,7 +162,6 @@ bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputSt
|
||||||
CFactoryFnReturn FProjectileWeaponDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
CFactoryFnReturn FProjectileWeaponDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||||
CObjectReference*) {
|
CObjectReference*) {
|
||||||
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
||||||
return TToken<CWeaponDescription>::GetIObjObjectFor(
|
return TToken<CWeaponDescription>::GetIObjObjectFor(CProjectileWeaponDataFactory::GetGeneratorDesc(in, sp));
|
||||||
std::unique_ptr<CWeaponDescription>(CProjectileWeaponDataFactory::GetGeneratorDesc(in, sp)));
|
|
||||||
}
|
}
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "Runtime/CFactoryMgr.hpp"
|
#include "Runtime/CFactoryMgr.hpp"
|
||||||
#include "Runtime/CToken.hpp"
|
#include "Runtime/CToken.hpp"
|
||||||
#include "Runtime/IOStreams.hpp"
|
#include "Runtime/IOStreams.hpp"
|
||||||
|
@ -7,14 +9,15 @@
|
||||||
#include "Runtime/RetroTypes.hpp"
|
#include "Runtime/RetroTypes.hpp"
|
||||||
|
|
||||||
namespace urde {
|
namespace urde {
|
||||||
class CWeaponDescription;
|
|
||||||
class CSimplePool;
|
class CSimplePool;
|
||||||
|
class CWeaponDescription;
|
||||||
|
|
||||||
class CProjectileWeaponDataFactory {
|
class CProjectileWeaponDataFactory {
|
||||||
static CWeaponDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool);
|
static std::unique_ptr<CWeaponDescription> CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool);
|
||||||
static bool CreateWPSM(CWeaponDescription* desc, CInputStream& in, CSimplePool* resPool);
|
static bool CreateWPSM(CWeaponDescription* desc, CInputStream& in, CSimplePool* resPool);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CWeaponDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
static std::unique_ptr<CWeaponDescription> GetGeneratorDesc(CInputStream& in, CSimplePool* resPool);
|
||||||
};
|
};
|
||||||
|
|
||||||
CFactoryFnReturn FProjectileWeaponDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
CFactoryFnReturn FProjectileWeaponDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
||||||
|
|
Loading…
Reference in New Issue