From 705703e10b034022378053fc5be97f0031ae3c8f Mon Sep 17 00:00:00 2001 From: robojumper Date: Sat, 15 Jun 2024 07:50:35 +0200 Subject: [PATCH 1/5] Fix mAng3_c copy assignment, clean up list node templates --- .../SOUE01/rels/d_a_t_wood_areaNP/symbols.txt | 4 +-- .../SOUE01/rels/d_t_sound_areaNP/symbols.txt | 6 ++--- config/SOUE01/symbols.txt | 4 +-- include/d/a/d_a_base.h | 8 +++--- include/d/d_base.h | 2 +- include/d/tg/d_t_tumble_weed.h | 10 +++----- include/f/f_list_nd.h | 25 +++++++++++++++++-- include/m/m_angle.h | 16 +++++++++++- src/REL/d/a/d_a_t_wood_area.cpp | 14 +++-------- src/REL/d/t/d_t_tumble_weed.cpp | 16 ++++++------ src/d/a/d_a_base.cpp | 6 ++--- 11 files changed, 67 insertions(+), 44 deletions(-) diff --git a/config/SOUE01/rels/d_a_t_wood_areaNP/symbols.txt b/config/SOUE01/rels/d_a_t_wood_areaNP/symbols.txt index 8b869b01..03f21551 100644 --- a/config/SOUE01/rels/d_a_t_wood_areaNP/symbols.txt +++ b/config/SOUE01/rels/d_a_t_wood_areaNP/symbols.txt @@ -8,8 +8,8 @@ __dt__27sFState_c<14dAcTWoodArea_c>Fv = .text:0x000001C0; // type:function size: __dt__30sFStateFct_c<14dAcTWoodArea_c>Fv = .text:0x00000220; // type:function size:0x6C __dt__83sStateMgr_c<14dAcTWoodArea_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>Fv = .text:0x00000290; // type:function size:0xA0 __dt__53sFStateMgr_c<14dAcTWoodArea_c,20sStateMethodUsr_FI_c>Fv = .text:0x00000330; // type:function size:0xA4 -__ct__14fLiNdBa_Wood_cFv = .text:0x000003E0; // type:function size:0x14 -__dt__14fLiNdBa_Wood_cFv = .text:0x00000400; // type:function size:0x58 +__ct__24dAcRef_c<12dAcObjBase_c>Fv = .text:0x000003E0; // type:function size:0x14 +__dt__24dAcRef_c<12dAcObjBase_c>Fv = .text:0x00000400; // type:function size:0x58 actorCreate__14dAcTWoodArea_cFv = .text:0x00000460; // type:function size:0x9C changeState__83sStateMgr_c<14dAcTWoodArea_c,20sStateMethodUsr_FI_c,12sFStateFct_c,13sStateIDChk_c>FRC12sStateIDIf_c = .text:0x00000500; // type:function size:0x10 actorPostCreate__14dAcTWoodArea_cFv = .text:0x00000510; // type:function size:0x64 diff --git a/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt b/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt index cdc4ffe7..7625aa33 100644 --- a/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt +++ b/config/SOUE01/rels/d_t_sound_areaNP/symbols.txt @@ -14,8 +14,8 @@ checkAlg3__10dTgSndAr_cFRC7mVec3_c = .text:0x00000540; // type:function size:0x1 __dt__10dTgSndAr_cFv = .text:0x00000690; // type:function size:0x70 _ctors = .ctors:0x00000000; // type:label scope:global _dtors = .dtors:0x00000000; // type:label scope:global -lbl_497_rodata_0 = .rodata:0x00000000; // type:object size:0x18 data:float -lbl_497_rodata_18 = .rodata:0x00000018; // type:object size:0x10 data:float -lbl_497_rodata_28 = .rodata:0x00000028; // type:object size:0x4 data:float +lbl_497_rodata_0 = .rodata:0x00000000; // type:object size:0x18 scope:local data:float +lbl_497_rodata_18 = .rodata:0x00000018; // type:object size:0x10 scope:local data:float +lbl_497_rodata_28 = .rodata:0x00000028; // type:object size:0x4 scope:local data:float g_profile_TAG_SOUND_AREA = .data:0x00000000; // type:object size:0x10 __vt__10dTgSndAr_c = .data:0x00000010; // type:object size:0x74 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 268e77c7..0030142f 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1063,7 +1063,7 @@ forEveryActor__9dAcBase_cFPFP9dAcBase_cP9dAcBase_c_PvP9dAcBase_c = .text:0x8002D getXZAngleToPlayer__9dAcBase_cFPs = .text:0x8002D190; // type:function size:0x3C getDistanceToActor__9dAcBase_cFP9dAcBase_cfPf = .text:0x8002D1D0; // type:function size:0xB8 getDistanceAndAngleToActor__9dAcBase_cFP9dAcBase_cfssPfPsPs = .text:0x8002D290; // type:function size:0x148 -isWithinPlayerRadius__9dAcBase_cFf = .text:0x8002D3E0; // type:function size:0x5C +isWithinPlayerRadius__9dAcBase_cCFf = .text:0x8002D3E0; // type:function size:0x5C getDistanceAndAngleToPlayer__9dAcBase_cFfssPfPsPs = .text:0x8002D440; // type:function size:0x2C getDistToPlayer__9dAcBase_cFv = .text:0x8002D470; // type:function size:0x30 getSquareDistToPlayer__9dAcBase_cFv = .text:0x8002D4A0; // type:function size:0x10 @@ -1086,7 +1086,7 @@ FUN_8002d830__9dAcBase_cFv = .text:0x8002D830; // type:function size:0x28 FUN_8002d860__9dAcBase_cFv = .text:0x8002D860; // type:function size:0x20 getSoundSource__9dAcBase_cFv = .text:0x8002D880; // type:function size:0x8 FUN_8002d890__9dAcBase_cFv = .text:0x8002D890; // type:function size:0x88 -setActorRef__9dAcBase_cFP7dBase_c = .text:0x8002D920; // type:function size:0x8 +setActorRef__9dAcBase_cFP9dAcBase_c = .text:0x8002D920; // type:function size:0x8 setEnemyDefeatFlag__9dAcBase_cFv = .text:0x8002D930; // type:function size:0x10 changeLoadedEntitiesWithSet__9dAcBase_cFv = .text:0x8002D940; // type:function size:0x14 changeLoadedEntitiesNoSet__9dAcBase_cFv = .text:0x8002D960; // type:function size:0x14 diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index 2a6ca355..ebce49a6 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -61,7 +61,7 @@ class dAcBase_c : public dBase_c { /* 0xC0 */ mVec3_c position; /* 0xCC */ mVec3_c scale; /* 0xD8 */ u32 actor_properties; - /* 0xDC */ fLiNdBa_c actor_node; + /* 0xDC */ dAcRef_c actor_node; /* 0xE8 */ u32 field_0xe8; /* 0xEC */ s8 roomid; /* 0xED */ u8 actor_subtype; @@ -117,7 +117,7 @@ class dAcBase_c : public dBase_c { return position - other.position; } - f32 getSquareDistanceTo(const mVec3_c &point) { + f32 getSquareDistanceTo(const mVec3_c &point) const { mVec3_c diff = position - point; return diff.x * diff.x + diff.z * diff.z; } @@ -155,7 +155,7 @@ class dAcBase_c : public dBase_c { // same concept as above /* 8002d290 */ bool getDistanceAndAngleToActor(dAcBase_c *actor, f32 distThresh, s16 yAngle, s16 xAngle, f32 *outDist, s16 *outDiffAngleY, s16 *outDiffAngleX); - /* 8002d3e0 */ bool isWithinPlayerRadius(f32 radius); + /* 8002d3e0 */ bool isWithinPlayerRadius(f32 radius) const; /* 8002d440 */ bool getDistanceAndAngleToPlayer(f32 distThresh, s16 yAngle, s16 xAngle, f32 *outDist, s16 *outDiffAngleY, s16 *outDiffAngleX); /* 8002d470 */ f32 getDistToPlayer(); @@ -183,7 +183,7 @@ class dAcBase_c : public dBase_c { // End of SoundSource stuff /* 8002d890 */ void FUN_8002d890(); - /* 8002d920 */ void setActorRef(dBase_c *); + /* 8002d920 */ void setActorRef(dAcBase_c *); // next three funcs are related /* 8002d930 */ void setEnemyDefeatFlag(); /* 8002d940 */ void changeLoadedEntitiesWithSet(); diff --git a/include/d/d_base.h b/include/d/d_base.h index 6cfefb64..6f753108 100644 --- a/include/d/d_base.h +++ b/include/d/d_base.h @@ -16,7 +16,7 @@ class dBase_c : public fBase_c { /* 800508f0 */ virtual void postExecute(MAIN_STATE_e state); /* 80050920 */ virtual int preDraw(); /* 80050860 */ virtual void postDraw(MAIN_STATE_e state); - /* 8002c530 */ virtual ~dBase_c(); + /* 8002c530 */ virtual ~dBase_c() {} public: /* 80050980 */ static void resetFlags(); diff --git a/include/d/tg/d_t_tumble_weed.h b/include/d/tg/d_t_tumble_weed.h index 5f8f9ecd..c366e290 100644 --- a/include/d/tg/d_t_tumble_weed.h +++ b/include/d/tg/d_t_tumble_weed.h @@ -6,12 +6,6 @@ #include #include -class fLiNdTumbleweed_c : public fLiNdBaAutoUnlink_c { -public: - fLiNdTumbleweed_c(fBase_c *owner) : fLiNdBaAutoUnlink_c(owner) {} - u16 someField; -}; - class dTgTumbleWeed_c : public dTg_c { public: dTgTumbleWeed_c() : mStateMgr(*this, sStateID::null), childTumbleweed(nullptr) {} @@ -35,7 +29,9 @@ class dTgTumbleWeed_c : public dTg_c { u16 tumbleweedTimer; u16 padding; u16 windTimer; - fLiNdTumbleweed_c childTumbleweed; + // TODO dAcObjTumbleWeed + dAcRef_c childTumbleweed; + u16 someField; }; #endif diff --git a/include/f/f_list_nd.h b/include/f/f_list_nd.h index cc237048..c685f982 100644 --- a/include/f/f_list_nd.h +++ b/include/f/f_list_nd.h @@ -28,10 +28,31 @@ class fLiNdBa_c : public cListNd_c { fBase_c *p_owner; }; -class fLiNdBaAutoUnlink_c : public fLiNdBa_c { +// TODO unofficial, move these to a more appropriate place +class fLiNdBaAutoUnlink_c : public fLiNdBa_c { public: fLiNdBaAutoUnlink_c(fBase_c *owner) : fLiNdBa_c(owner) {} - ~fLiNdBaAutoUnlink_c() { unlink(); } + ~fLiNdBaAutoUnlink_c() { + unlink(); + } +}; + +template +class dAcRef_c : fLiNdBaAutoUnlink_c { +public: + dAcRef_c(T *owner) : fLiNdBaAutoUnlink_c(owner) {} + dAcRef_c() : fLiNdBaAutoUnlink_c(nullptr) {} + ~dAcRef_c() {} + + void link(T *ref) { + p_owner = ref; + } + void unlink() { + fLiNdBa_c::unlink(); + } + T *get() { + return static_cast(p_owner); + } }; #endif diff --git a/include/m/m_angle.h b/include/m/m_angle.h index 52c2408c..514fa6d0 100644 --- a/include/m/m_angle.h +++ b/include/m/m_angle.h @@ -6,7 +6,10 @@ struct mAng { mAng() {} mAng(s16 s) : mVal(s) {} - + mAng(const mAng &other) : mVal(other.mVal) {} + operator s16() const { + return mVal; + } s32 step(s16 target, s32 steps, s16 max, s16 min); s16 mVal; @@ -18,6 +21,17 @@ class mAng3_c { mAng3_c(s16 fx, s16 fy, s16 fz) : x(fx), y(fy), z(fz) {} + mAng3_c(const mAng3_c &r) { + *this = r; + } + + mAng3_c &operator=(const mAng3_c &r) { + x = r.x; + y = r.y; + z = r.z; + return *this; + } + void set(s16 fx, s16 fy, s16 fz) { x = fx; y = fy; diff --git a/src/REL/d/a/d_a_t_wood_area.cpp b/src/REL/d/a/d_a_t_wood_area.cpp index e9732211..40009734 100644 --- a/src/REL/d/a/d_a_t_wood_area.cpp +++ b/src/REL/d/a/d_a_t_wood_area.cpp @@ -4,12 +4,6 @@ #include #include -// Look I don't know why these levels of subclasses work -class fLiNdBa_Wood_c : public fLiNdBaAutoUnlink_c { -public: - fLiNdBa_Wood_c() : fLiNdBaAutoUnlink_c(nullptr) {} -}; - class dAcTWoodArea_c : public dAcObjBase_c { public: dAcTWoodArea_c() : mStateMgr(*this, sStateID::null) {} @@ -44,7 +38,7 @@ class dAcTWoodArea_c : public dAcObjBase_c { private: STATE_MGR_DECLARE(dAcTWoodArea_c); - fLiNdBa_Wood_c mRefs[8]; + dAcRef_c mRefs[8]; }; const f32 dAcTWoodArea_c::scaleX = 100.0f; @@ -141,8 +135,8 @@ void dAcTWoodArea_c::attachCloseObjects(ProfileName profID) { void dAcTWoodArea_c::dropItems() { for (int i = 0; i < 8; i++) { - if (mRefs[i].p_owner != nullptr) { - if (static_cast(mRefs[i].p_owner)->drop()) { + if (mRefs[i].get() != nullptr) { + if (mRefs[i].get()->drop()) { mRefs[i].unlink(); } } @@ -151,7 +145,7 @@ void dAcTWoodArea_c::dropItems() { bool dAcTWoodArea_c::attachObject(dAcObjBase_c *obj) { for (int i = 0; i < 8; i++) { - if (mRefs[i].p_owner == nullptr) { + if (mRefs[i].get() == nullptr) { mRefs[i].link(obj); return true; } diff --git a/src/REL/d/t/d_t_tumble_weed.cpp b/src/REL/d/t/d_t_tumble_weed.cpp index c98f6121..5534cb98 100644 --- a/src/REL/d/t/d_t_tumble_weed.cpp +++ b/src/REL/d/t/d_t_tumble_weed.cpp @@ -74,12 +74,12 @@ void dTgTumbleWeed_c::executeState_AreaIn() { } void dTgTumbleWeed_c::finalizeState_AreaIn() {} -extern "C" void fn_475_1B00(fBase_c *, mVec3_c&); +extern "C" void fn_475_1B00(fBase_c *, mVec3_c &); void dTgTumbleWeed_c::initializeState_Wind() { mVec3_c vec; getWind(&vec); - if (childTumbleweed.p_owner != nullptr) { - fn_475_1B00(childTumbleweed.p_owner, vec); + if (childTumbleweed.get() != nullptr) { + fn_475_1B00(childTumbleweed.get(), vec); } } @@ -94,7 +94,7 @@ void dTgTumbleWeed_c::finalizeState_Wind() {} bool dTgTumbleWeed_c::shouldSpawnTumbleweed() { bool spawnAllowed = false; - if (childTumbleweed.p_owner == nullptr && cM::rnd() <= 0.8f) { + if (childTumbleweed.get() == nullptr && cM::rnd() <= 0.8f) { spawnAllowed = true; } @@ -105,10 +105,8 @@ bool dTgTumbleWeed_c::shouldSpawnTumbleweed() { return false; } - bool dTgTumbleWeed_c::shouldDoWind() { - return childTumbleweed.p_owner != nullptr && cM::rnd() <= 0.5f; -} -void dTgTumbleWeed_c::doSpawnTumbleweed() { + return childTumbleweed.get() != nullptr && cM::rnd() <= 0.5f; } -void dTgTumbleWeed_c::getWind(mVec3_c*) {} +void dTgTumbleWeed_c::doSpawnTumbleweed() {} +void dTgTumbleWeed_c::getWind(mVec3_c *) {} diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index efd8f612..ce0c7e61 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -72,7 +72,7 @@ dAcBase_c::dAcBase_c() } // 8002c530 -dBase_c::~dBase_c() {} +// dBase_c::~dBase_c() {} dAcBase_c::~dAcBase_c() {} @@ -392,7 +392,7 @@ bool dAcBase_c::getDistanceAndAngleToActor(dAcBase_c *actor, f32 distThresh, s16 } // 8002d3e0 -bool dAcBase_c::isWithinPlayerRadius(f32 radius) { +bool dAcBase_c::isWithinPlayerRadius(f32 radius) const { f32 dist_diff = getSquareDistanceTo(dPlayer::LINK->position); return dist_diff < radius * radius; } @@ -462,7 +462,7 @@ SoundSource *dAcBase_c::getSoundSource() { void dAcBase_c::FUN_8002d890() {} // current name is Global__setActorRef -void dAcBase_c::setActorRef(dBase_c *ref) { +void dAcBase_c::setActorRef(dAcBase_c *ref) { actor_node.link(ref); } From c33d392f93d59a5d03b76c27a56c204ce91fa186 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Sat, 15 Jun 2024 19:05:54 -0400 Subject: [PATCH 2/5] create d_a_t_wood_area header --- include/d/a/d_a_t_wood_area.h | 48 +++++++++++++++++++++++++++++++++ src/REL/d/a/d_a_t_wood_area.cpp | 44 ++---------------------------- 2 files changed, 50 insertions(+), 42 deletions(-) create mode 100644 include/d/a/d_a_t_wood_area.h diff --git a/include/d/a/d_a_t_wood_area.h b/include/d/a/d_a_t_wood_area.h new file mode 100644 index 00000000..03576037 --- /dev/null +++ b/include/d/a/d_a_t_wood_area.h @@ -0,0 +1,48 @@ +#ifndef D_A_T_WOOD_AREA_H +#define D_A_T_WOOD_AREA_H + +#include +#include +#include +#include +#include + +class dAcTWoodArea_c : public dAcObjBase_c { +public: + dAcTWoodArea_c() : mStateMgr(*this, sStateID::null) {} + virtual ~dAcTWoodArea_c() {} + virtual int actorCreate() override; + virtual int actorPostCreate() override; + virtual int actorExecute() override; + virtual int draw() override; + virtual int doDelete() override; + + STATE_FUNC_DECLARE(dAcTWoodArea_c, Init); + STATE_FUNC_DECLARE(dAcTWoodArea_c, Wait); + + void attachCloseObjects(ProfileName profID); + void dropItems(); + bool attachObject(dAcObjBase_c *obj); + + f32 getAttachRadius() { + return scale.x * scaleX; + } + f32 getAttachRadiusSquare() { + return getAttachRadius() * getAttachRadius(); + } + f32 getAttachHeight() { + return scale.y * scaleY; + } + + static const f32 scaleX; + static const f32 scaleY; + +private: + STATE_MGR_DECLARE(dAcTWoodArea_c); + + dAcRef_c mRefs[8]; +}; + +// {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + +#endif diff --git a/src/REL/d/a/d_a_t_wood_area.cpp b/src/REL/d/a/d_a_t_wood_area.cpp index 40009734..43921e3a 100644 --- a/src/REL/d/a/d_a_t_wood_area.cpp +++ b/src/REL/d/a/d_a_t_wood_area.cpp @@ -1,45 +1,4 @@ -#include -#include -#include -#include -#include - -class dAcTWoodArea_c : public dAcObjBase_c { -public: - dAcTWoodArea_c() : mStateMgr(*this, sStateID::null) {} - virtual ~dAcTWoodArea_c() {} - virtual int actorCreate() override; - virtual int actorPostCreate() override; - virtual int actorExecute() override; - virtual int draw() override; - virtual int doDelete() override; - - void attachCloseObjects(ProfileName profID); - void dropItems(); - bool attachObject(dAcObjBase_c *obj); - - f32 getAttachRadius() { - return scale.x * scaleX; - } - f32 getAttachRadiusSquare() { - return getAttachRadius() * getAttachRadius(); - } - - f32 getAttachHeight() { - return scale.y * scaleY; - } - - STATE_FUNC_DECLARE(dAcTWoodArea_c, Init); - STATE_FUNC_DECLARE(dAcTWoodArea_c, Wait); - - static const f32 scaleX; - static const f32 scaleY; - -private: - STATE_MGR_DECLARE(dAcTWoodArea_c); - - dAcRef_c mRefs[8]; -}; +#include const f32 dAcTWoodArea_c::scaleX = 100.0f; const f32 dAcTWoodArea_c::scaleY = 100.0f; @@ -95,6 +54,7 @@ extern "C" void fn_800298B0(u16, mVec3_c *, mAng3_c *, u32, u32, u32, u32, u32); extern u16 PARTICLE_RESOURCE_ID_MAPPING[]; void dAcTWoodArea_c::initializeState_Wait() {} + void dAcTWoodArea_c::executeState_Wait() { if (dPlayer::LINK != nullptr && (dPlayer::LINK->someFlags & 0x2000)) { // This is a bit messed up From a856aa5db5a7c58e94055b8e1de14489be20d2cd Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 21 Jun 2024 00:41:59 +0200 Subject: [PATCH 3/5] Fix one angle problem --- config/SOUE01/symbols.txt | 2 +- include/d/a/d_a_base.h | 3 +-- src/d/a/d_a_base.cpp | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 0030142f..0c6f28f2 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -1060,7 +1060,7 @@ getParams2Lower__9dAcBase_cFv = .text:0x8002D010; // type:function size:0xC findActor__9dAcBase_cFPcP9dAcBase_c = .text:0x8002D020; // type:function size:0x74 searchActor__9dAcBase_cFP9dAcBase_c = .text:0x8002D0A0; // type:function size:0x88 forEveryActor__9dAcBase_cFPFP9dAcBase_cP9dAcBase_c_PvP9dAcBase_c = .text:0x8002D130; // type:function size:0x5C -getXZAngleToPlayer__9dAcBase_cFPs = .text:0x8002D190; // type:function size:0x3C +getXZAngleToPlayer__9dAcBase_cFv = .text:0x8002D190; // type:function size:0x3C getDistanceToActor__9dAcBase_cFP9dAcBase_cfPf = .text:0x8002D1D0; // type:function size:0xB8 getDistanceAndAngleToActor__9dAcBase_cFP9dAcBase_cfssPfPsPs = .text:0x8002D290; // type:function size:0x148 isWithinPlayerRadius__9dAcBase_cCFf = .text:0x8002D3E0; // type:function size:0x5C diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index ebce49a6..346c68a4 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -148,8 +148,7 @@ class dAcBase_c : public dBase_c { /* 8002d0a0 */ static dAcBase_c *searchActor(dAcBase_c *parent); // Kinda performs the code of the first param on every actor (second param is optional parent) /* 8002d130 */ static void forEveryActor(void *func(dAcBase_c *, dAcBase_c *), dAcBase_c *parent); - // Not really static, but we currently dont have a type for the return (not just simply a s16) - /* 8002d190 */ mAng getXZAngleToPlayer(s16 *angle); + /* 8002d190 */ mAng getXZAngleToPlayer(); // returns true if under the distThresh, False if not. the actual distance is returned in outDist /* 8002d1d0 */ bool getDistanceToActor(dAcBase_c *actor, f32 distThresh, f32 *outDist); // same concept as above diff --git a/src/d/a/d_a_base.cpp b/src/d/a/d_a_base.cpp index ce0c7e61..0ebbe74c 100644 --- a/src/d/a/d_a_base.cpp +++ b/src/d/a/d_a_base.cpp @@ -327,7 +327,7 @@ void dAcBase_c::forEveryActor(void *func(dAcBase_c *, dAcBase_c *), dAcBase_c *p } // 8002d190 -mAng dAcBase_c::getXZAngleToPlayer(s16 *angle) { +mAng dAcBase_c::getXZAngleToPlayer() { return targetAngleY(&this->position, &dPlayer::LINK->position); } From 3be14367f816c100f56bba9f7c3545442ada8890 Mon Sep 17 00:00:00 2001 From: robojumper Date: Fri, 21 Jun 2024 00:42:37 +0200 Subject: [PATCH 4/5] Drop unused comment --- include/d/a/d_a_t_wood_area.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/d/a/d_a_t_wood_area.h b/include/d/a/d_a_t_wood_area.h index 03576037..0729b9f8 100644 --- a/include/d/a/d_a_t_wood_area.h +++ b/include/d/a/d_a_t_wood_area.h @@ -43,6 +43,4 @@ class dAcTWoodArea_c : public dAcObjBase_c { dAcRef_c mRefs[8]; }; -// {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; - #endif From 58483211c90f4841801b64ef8aa34b6ba839f3cd Mon Sep 17 00:00:00 2001 From: robojumper Date: Tue, 25 Jun 2024 20:11:44 +0200 Subject: [PATCH 5/5] Move actor ref header somewhere more appropriate --- include/d/a/d_a_base.h | 35 +++++++++++++++++++++++++++++++++++ include/f/f_list_nd.h | 27 --------------------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/include/d/a/d_a_base.h b/include/d/a/d_a_base.h index 346c68a4..46072cb0 100644 --- a/include/d/a/d_a_base.h +++ b/include/d/a/d_a_base.h @@ -25,6 +25,41 @@ struct SoundInfo { SoundInfo *prev; }; +/** + * A list node that will automatically unlink upon destruction. + */ +class dAcRefBase_c : public fLiNdBa_c { +public: + dAcRefBase_c(fBase_c *owner) : fLiNdBa_c(owner) {} + ~dAcRefBase_c() { + unlink(); + } +}; + +/** + * A type-safe list node that can hold a specific actor reference. + * Unlinks upon destruction. This setup is inferred from + * double null checks in inline dtors and instantiated ctors/dtors + * for arrays of these nodes in classes. + */ +template +class dAcRef_c : dAcRefBase_c { +public: + dAcRef_c(T *owner) : dAcRefBase_c(owner) {} + dAcRef_c() : dAcRefBase_c(nullptr) {} + ~dAcRef_c() {} + + void link(T *ref) { + fLiNdBa_c::link(ref); + } + void unlink() { + fLiNdBa_c::unlink(); + } + T *get() { + return static_cast(p_owner); + } +}; + template struct TList { T *GetOffset() { diff --git a/include/f/f_list_nd.h b/include/f/f_list_nd.h index c685f982..4ef42769 100644 --- a/include/f/f_list_nd.h +++ b/include/f/f_list_nd.h @@ -28,31 +28,4 @@ class fLiNdBa_c : public cListNd_c { fBase_c *p_owner; }; -// TODO unofficial, move these to a more appropriate place -class fLiNdBaAutoUnlink_c : public fLiNdBa_c { -public: - fLiNdBaAutoUnlink_c(fBase_c *owner) : fLiNdBa_c(owner) {} - ~fLiNdBaAutoUnlink_c() { - unlink(); - } -}; - -template -class dAcRef_c : fLiNdBaAutoUnlink_c { -public: - dAcRef_c(T *owner) : fLiNdBaAutoUnlink_c(owner) {} - dAcRef_c() : fLiNdBaAutoUnlink_c(nullptr) {} - ~dAcRef_c() {} - - void link(T *ref) { - p_owner = ref; - } - void unlink() { - fLiNdBa_c::unlink(); - } - T *get() { - return static_cast(p_owner); - } -}; - #endif