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,