diff --git a/Runtime/Particle/CDecalDataFactory.cpp b/Runtime/Particle/CDecalDataFactory.cpp index dae0dd11c..48ea6300a 100644 --- a/Runtime/Particle/CDecalDataFactory.cpp +++ b/Runtime/Particle/CDecalDataFactory.cpp @@ -12,19 +12,21 @@ namespace urde { static logvisor::Module Log("urde::CDecalDataFactory"); using CPF = CParticleDataFactory; -CDecalDescription* CDecalDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) { +std::unique_ptr CDecalDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) { return CreateGeneratorDescription(in, resPool); } -CDecalDescription* CDecalDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool) { - FourCC clsId = CPF::GetClassID(in); +std::unique_ptr CDecalDataFactory::CreateGeneratorDescription(CInputStream& in, + CSimplePool* resPool) { + const FourCC clsId = CPF::GetClassID(in); + if (clsId == FOURCC('DPSM')) { - CDecalDescription* desc = new CDecalDescription; - if (CreateDPSM(desc, in, resPool)) + auto desc = std::make_unique(); + if (CreateDPSM(desc.get(), in, resPool)) { return desc; - else - delete desc; + } } + return nullptr; } @@ -129,7 +131,6 @@ void CDecalDataFactory::GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, CFactoryFnReturn FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, CObjectReference*) { CSimplePool* sp = vparms.GetOwnedObj(); - return TToken::GetIObjObjectFor( - std::unique_ptr(CDecalDataFactory::GetGeneratorDesc(in, sp))); + return TToken::GetIObjObjectFor(CDecalDataFactory::GetGeneratorDesc(in, sp)); } } // namespace urde diff --git a/Runtime/Particle/CDecalDataFactory.hpp b/Runtime/Particle/CDecalDataFactory.hpp index c16547dab..54628447a 100644 --- a/Runtime/Particle/CDecalDataFactory.hpp +++ b/Runtime/Particle/CDecalDataFactory.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "Runtime/CFactoryMgr.hpp" #include "Runtime/CToken.hpp" #include "Runtime/IObj.hpp" @@ -12,11 +14,11 @@ class CSimplePool; class CDecalDataFactory { static bool CreateDPSM(CDecalDescription* desc, CInputStream& in, CSimplePool* resPool); - static CDecalDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); + static std::unique_ptr CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); static void GetQuadDecalInfo(CInputStream& in, CSimplePool* resPool, FourCC clsId, SQuadDescr& quad); public: - static CDecalDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); + static std::unique_ptr GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); }; CFactoryFnReturn FDecalDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, diff --git a/Runtime/Particle/CParticleElectricDataFactory.cpp b/Runtime/Particle/CParticleElectricDataFactory.cpp index c94bc768a..fe366b70a 100644 --- a/Runtime/Particle/CParticleElectricDataFactory.cpp +++ b/Runtime/Particle/CParticleElectricDataFactory.cpp @@ -13,20 +13,24 @@ static logvisor::Module Log("urde::CParticleElectricDataFactory"); using CPF = CParticleDataFactory; -CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) { +std::unique_ptr CParticleElectricDataFactory::GetGeneratorDesc(CInputStream& in, + CSimplePool* resPool) { return CreateElectricDescription(in, resPool); } -CElectricDescription* CParticleElectricDataFactory::CreateElectricDescription(CInputStream& in, CSimplePool* resPool) { - FourCC cid = CPF::GetClassID(in); - if (cid == FOURCC('ELSM')) { - CElectricDescription* desc = new CElectricDescription; - CreateELSM(desc, in, resPool); - LoadELSMTokens(desc); - return desc; +std::unique_ptr CParticleElectricDataFactory::CreateElectricDescription(CInputStream& in, + CSimplePool* resPool) { + const FourCC cid = CPF::GetClassID(in); + + if (cid != FOURCC('ELSM')) { + return nullptr; } - return nullptr; + auto desc = std::make_unique(); + CreateELSM(desc.get(), in, resPool); + LoadELSMTokens(desc.get()); + return desc; + } 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, CObjectReference*) { CSimplePool* sp = vparms.GetOwnedObj(); - return TToken::GetIObjObjectFor( - std::unique_ptr(CParticleElectricDataFactory::GetGeneratorDesc(in, sp))); + return TToken::GetIObjObjectFor(CParticleElectricDataFactory::GetGeneratorDesc(in, sp)); } } // namespace urde diff --git a/Runtime/Particle/CParticleElectricDataFactory.hpp b/Runtime/Particle/CParticleElectricDataFactory.hpp index e71fc4609..7ec5e749e 100644 --- a/Runtime/Particle/CParticleElectricDataFactory.hpp +++ b/Runtime/Particle/CParticleElectricDataFactory.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "Runtime/CFactoryMgr.hpp" #include "Runtime/CToken.hpp" #include "Runtime/IOStreams.hpp" @@ -10,12 +12,12 @@ namespace urde { class CElectricDescription; class CSimplePool; class CParticleElectricDataFactory { - static CElectricDescription* CreateElectricDescription(CInputStream& in, CSimplePool* resPool); + static std::unique_ptr CreateElectricDescription(CInputStream& in, CSimplePool* resPool); static bool CreateELSM(CElectricDescription* desc, CInputStream& in, CSimplePool* resPool); static void LoadELSMTokens(CElectricDescription* desc); public: - static CElectricDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); + static std::unique_ptr GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); }; CFactoryFnReturn FParticleElectricDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, diff --git a/Runtime/Particle/CParticleSwooshDataFactory.cpp b/Runtime/Particle/CParticleSwooshDataFactory.cpp index f8da8e18e..122d93b02 100644 --- a/Runtime/Particle/CParticleSwooshDataFactory.cpp +++ b/Runtime/Particle/CParticleSwooshDataFactory.cpp @@ -12,19 +12,22 @@ static logvisor::Module Log("urde::CParticleSwooshDataFactory"); using CPF = CParticleDataFactory; -CSwooshDescription* CParticleSwooshDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) { +std::unique_ptr CParticleSwooshDataFactory::GetGeneratorDesc(CInputStream& in, + CSimplePool* resPool) { return CreateGeneratorDescription(in, resPool); } -CSwooshDescription* CParticleSwooshDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool) { - FourCC clsId = CPF::GetClassID(in); +std::unique_ptr CParticleSwooshDataFactory::CreateGeneratorDescription(CInputStream& in, + CSimplePool* resPool) { + const FourCC clsId = CPF::GetClassID(in); + if (clsId == FOURCC('SWSH')) { - CSwooshDescription* desc = new CSwooshDescription; - if (CreateWPSM(desc, in, resPool)) + auto desc = std::make_unique(); + if (CreateWPSM(desc.get(), in, resPool)) { return desc; - else - delete desc; + } } + return nullptr; } @@ -132,7 +135,6 @@ bool CParticleSwooshDataFactory::CreateWPSM(CSwooshDescription* desc, CInputStre CFactoryFnReturn FParticleSwooshDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, CObjectReference*) { CSimplePool* sp = vparms.GetOwnedObj(); - return TToken::GetIObjObjectFor( - std::unique_ptr(CParticleSwooshDataFactory::GetGeneratorDesc(in, sp))); + return TToken::GetIObjObjectFor(CParticleSwooshDataFactory::GetGeneratorDesc(in, sp)); } } // namespace urde diff --git a/Runtime/Particle/CParticleSwooshDataFactory.hpp b/Runtime/Particle/CParticleSwooshDataFactory.hpp index d55d5ab05..e27fab23f 100644 --- a/Runtime/Particle/CParticleSwooshDataFactory.hpp +++ b/Runtime/Particle/CParticleSwooshDataFactory.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "Runtime/CFactoryMgr.hpp" #include "Runtime/CToken.hpp" #include "Runtime/IOStreams.hpp" @@ -10,11 +12,11 @@ namespace urde { class CSwooshDescription; class CSimplePool; class CParticleSwooshDataFactory { - static CSwooshDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); + static std::unique_ptr CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); static bool CreateWPSM(CSwooshDescription* desc, CInputStream& in, CSimplePool* resPool); public: - static CSwooshDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); + static std::unique_ptr GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); }; CFactoryFnReturn FParticleSwooshDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms, diff --git a/Runtime/Particle/CProjectileWeaponDataFactory.cpp b/Runtime/Particle/CProjectileWeaponDataFactory.cpp index 135d903d4..6727f4295 100644 --- a/Runtime/Particle/CProjectileWeaponDataFactory.cpp +++ b/Runtime/Particle/CProjectileWeaponDataFactory.cpp @@ -14,19 +14,22 @@ static logvisor::Module Log("urde::CProjectileWeaponDataFactory"); using CPF = CParticleDataFactory; -CWeaponDescription* CProjectileWeaponDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) { +std::unique_ptr CProjectileWeaponDataFactory::GetGeneratorDesc(CInputStream& in, + CSimplePool* resPool) { return CreateGeneratorDescription(in, resPool); } -CWeaponDescription* CProjectileWeaponDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool) { - FourCC clsId = CPF::GetClassID(in); - if (clsId == FOURCC('WPSM')) { - CWeaponDescription* desc = new CWeaponDescription; - CreateWPSM(desc, in, resPool); - return desc; +std::unique_ptr CProjectileWeaponDataFactory::CreateGeneratorDescription(CInputStream& in, + CSimplePool* resPool) { + const FourCC clsId = CPF::GetClassID(in); + if (clsId != FOURCC('WPSM')) { + return nullptr; } - return nullptr; + auto desc = std::make_unique(); + CreateWPSM(desc.get(), in, resPool); + return desc; + } 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, CObjectReference*) { CSimplePool* sp = vparms.GetOwnedObj(); - return TToken::GetIObjObjectFor( - std::unique_ptr(CProjectileWeaponDataFactory::GetGeneratorDesc(in, sp))); + return TToken::GetIObjObjectFor(CProjectileWeaponDataFactory::GetGeneratorDesc(in, sp)); } } // namespace urde diff --git a/Runtime/Particle/CProjectileWeaponDataFactory.hpp b/Runtime/Particle/CProjectileWeaponDataFactory.hpp index 88d920209..4cd9bd9d2 100644 --- a/Runtime/Particle/CProjectileWeaponDataFactory.hpp +++ b/Runtime/Particle/CProjectileWeaponDataFactory.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "Runtime/CFactoryMgr.hpp" #include "Runtime/CToken.hpp" #include "Runtime/IOStreams.hpp" @@ -7,14 +9,15 @@ #include "Runtime/RetroTypes.hpp" namespace urde { -class CWeaponDescription; class CSimplePool; +class CWeaponDescription; + class CProjectileWeaponDataFactory { - static CWeaponDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); + static std::unique_ptr CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); static bool CreateWPSM(CWeaponDescription* desc, CInputStream& in, CSimplePool* resPool); public: - static CWeaponDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); + static std::unique_ptr GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); }; CFactoryFnReturn FProjectileWeaponDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,