From f585ef383fb730c7348a90e0cc7281717f879d22 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Thu, 17 Nov 2022 07:13:56 +0200 Subject: [PATCH] Use raw pointers in CWeaponDescription, link it Former-commit-id: 0e45d770364322de1c3f1ed0fe36db5536d5534b --- configure.py | 2 +- include/Weapons/CWeaponDescription.hpp | 24 +++++++-------- obj_files.mk | 2 +- src/MetroidPrime/Weapons/CProjectileInfo.cpp | 2 +- src/Weapons/CWeaponDescription.cpp | 31 ++++++++++++++++++-- 5 files changed, 43 insertions(+), 18 deletions(-) diff --git a/configure.py b/configure.py index 343cdf7b..084f3010 100755 --- a/configure.py +++ b/configure.py @@ -425,7 +425,7 @@ LIBS = [ ["Weapons/IWeaponRenderer", True], "Weapons/CDecalDataFactory", ["Weapons/CDecal", False], - "Weapons/CWeaponDescription", + ["Weapons/CWeaponDescription", True], ["Weapons/CDecalDescription", True], ], }, diff --git a/include/Weapons/CWeaponDescription.hpp b/include/Weapons/CWeaponDescription.hpp index ea524a70..a3b6b79b 100644 --- a/include/Weapons/CWeaponDescription.hpp +++ b/include/Weapons/CWeaponDescription.hpp @@ -22,16 +22,16 @@ public: CWeaponDescription(); ~CWeaponDescription(); - rstl::single_ptr< CVectorElement > x0_IORN; - rstl::single_ptr< CVectorElement > x4_IVEC; - rstl::single_ptr< CVectorElement > x8_PSOV; - rstl::single_ptr< CModVectorElement > xc_PSVM; + CVectorElement* x0_IORN; + CVectorElement* x4_IVEC; + CVectorElement* x8_PSOV; + CModVectorElement* xc_PSVM; bool x10_VMD2; - rstl::single_ptr< CIntElement > x14_PSLT; - rstl::single_ptr< CVectorElement > x18_PSCL; - rstl::single_ptr< CColorElement > x1c_PCOL; - rstl::single_ptr< CVectorElement > x20_POFS; - rstl::single_ptr< CVectorElement > x24_OFST; + CIntElement* x14_PSLT; + CVectorElement* x18_PSCL; + CColorElement* x1c_PCOL; + CVectorElement* x20_POFS; + CVectorElement* x24_OFST; bool x28_APSO; bool x29_HOMG; bool x2a_AP11; @@ -39,7 +39,7 @@ public: bool x2c_AS11; bool x2d_AS12; bool x2e_AS13; - rstl::single_ptr< CRealElement > x30_TRAT; + CRealElement* x30_TRAT; TChildGeneratorDesc x34_APSM; TChildGeneratorDesc x44_APS2; TSwooshGeneratorDesc x54_ASW1; @@ -51,8 +51,8 @@ public: bool xa5_LWTR; bool xa6_SWTR; int xa8_PJFX; - rstl::single_ptr< CRealElement > xac_RNGE; - rstl::single_ptr< CRealElement > xb0_FOFF; + CRealElement* xac_RNGE; + CRealElement* xb0_FOFF; }; #endif // _CWEAPONDESCRIPTION diff --git a/obj_files.mk b/obj_files.mk index 41e2afbf..3bc6e7d4 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -378,7 +378,7 @@ WEAPONS :=\ $(BUILD_DIR)/src/Weapons/IWeaponRenderer.o\ $(BUILD_DIR)/asm/Weapons/CDecalDataFactory.o\ $(BUILD_DIR)/asm/Weapons/CDecal.o\ - $(BUILD_DIR)/asm/Weapons/CWeaponDescription.o\ + $(BUILD_DIR)/src/Weapons/CWeaponDescription.o\ $(BUILD_DIR)/src/Weapons/CDecalDescription.o\ METARENDER :=\ diff --git a/src/MetroidPrime/Weapons/CProjectileInfo.cpp b/src/MetroidPrime/Weapons/CProjectileInfo.cpp index 406b0491..503b68b1 100644 --- a/src/MetroidPrime/Weapons/CProjectileInfo.cpp +++ b/src/MetroidPrime/Weapons/CProjectileInfo.cpp @@ -18,7 +18,7 @@ float CProjectileInfo::GetProjectileSpeed() const { float result = 45000.0f; TToken< CWeaponDescription > token(x0_weaponDescription); - if (!token->x4_IVEC.null()) { + if (token->x4_IVEC) { CVector3f vec = CVector3f::Zero(); token->x4_IVEC->GetValue(0, vec); result = vec.Magnitude() / CProjectileWeapon::GetTickPeriod(); diff --git a/src/Weapons/CWeaponDescription.cpp b/src/Weapons/CWeaponDescription.cpp index 8f9806e5..edbc1d01 100644 --- a/src/Weapons/CWeaponDescription.cpp +++ b/src/Weapons/CWeaponDescription.cpp @@ -2,16 +2,41 @@ #include "Kyoto/Alloc/CMemory.hpp" CWeaponDescription::CWeaponDescription() -: x10_VMD2(false) +: x0_IORN(nullptr) +, x4_IVEC(nullptr) +, x8_PSOV(nullptr) +, xc_PSVM(nullptr) +, x10_VMD2(false) +, x14_PSLT(nullptr) +, x18_PSCL(nullptr) +, x1c_PCOL(nullptr) +, x20_POFS(nullptr) +, x24_OFST(nullptr) , x28_APSO(false) , x2a_AP11(false) , x2b_AP21(false) , x2c_AS11(false) , x2d_AS12(false) , x2e_AS13(false) +, x30_TRAT(nullptr) , xa4_EWTR(true) , xa5_LWTR(true) , xa6_SWTR(true) -, xa8_PJFX(-1) {} +, xa8_PJFX(-1) +, xac_RNGE(nullptr) +, xb0_FOFF(nullptr) {} -CWeaponDescription::~CWeaponDescription() {} +CWeaponDescription::~CWeaponDescription() { + delete x4_IVEC; + delete x0_IORN; + delete xc_PSVM; + delete x8_PSOV; + delete x14_PSLT; + delete x18_PSCL; + delete x1c_PCOL; + delete x20_POFS; + delete x24_OFST; + delete x30_TRAT; + delete xac_RNGE; + delete xb0_FOFF; +}