From 35f90de9295c22580031a5bed5d280433e321217 Mon Sep 17 00:00:00 2001 From: robojumper Date: Mon, 7 Apr 2025 11:29:30 +0200 Subject: [PATCH] Link f_base in the least intrusive way --- config/SOUE01/splits.txt | 2 +- configure.py | 2 +- include/f/f_base.h | 7 ++----- src/f/f_base.cpp | 8 ++++++-- src/f/f_list.cpp | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 5685818f..61b51591 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -973,7 +973,7 @@ c/c_tree.cpp: .text start:0x802E0E70 end:0x802E1140 f/f_base.cpp: - .text start:0x802E12F0 end:0x802E2680 + .text start:0x802E12F0 end:0x802E2674 .ctors start:0x804DB8C0 end:0x804DB8C4 .data start:0x80542278 end:0x805423A8 .sdata start:0x80573FB8 end:0x80573FBC diff --git a/configure.py b/configure.py index 4e07a0f9..2c2b8429 100644 --- a/configure.py +++ b/configure.py @@ -588,7 +588,7 @@ config.libs = [ "progress_category": "core", "host": False, "objects": [ - Object(NonMatching, "f/f_base.cpp"), + Object(Matching, "f/f_base.cpp"), Object(Matching, "f/f_list.cpp"), Object(Matching, "f/f_manager.cpp"), ], diff --git a/include/f/f_base.h b/include/f/f_base.h index cc6d8005..c24095fe 100644 --- a/include/f/f_base.h +++ b/include/f/f_base.h @@ -5,6 +5,7 @@ // https://github.com/NSMBW-Community/NSMBW-Decomp/blob/master/include/dol/framework/f_base.hpp and the Skyward Sword // Ghidra database. Comments and docs can be seen above. stripped in this file for easier looking +#include "c/c_list.h" #include "common.h" #include "egg/core/eggExpHeap.h" #include "egg/core/eggFrmHeap.h" @@ -31,7 +32,7 @@ public: /* 0x0F */ u8 proc_control; /* 0x10 */ fManager_c manager; /* 0x50 */ fBaHelper_c *p_helper; - /* 0x54 */ fLiMgBa_c actor_list; + /* 0x54 */ cListMg_c actor_list; /* 0x5C */ EGG::FrmHeap *p_heap; /* 0x60 */ // vtable public: @@ -83,10 +84,6 @@ public: proc_control &= ~flag; } - fManager_c *getManager() { - return &manager; - } - void setParams() { unique_ID = m_rootUniqueID; params = m_tmpCtData.params; diff --git a/src/f/f_base.cpp b/src/f/f_base.cpp index 865f0395..3fddeae8 100644 --- a/src/f/f_base.cpp +++ b/src/f/f_base.cpp @@ -55,10 +55,14 @@ fBase_c::fBase_c() /* 802e1480 */ fBase_c::~fBase_c() { - fLiNdBa_c *node = actor_list.getFirst(); + // Is this static_cast fake? Maybe. But if actor_list is of type fLiMgBa_c, + // that causes a weak destructor to spawn that actually needs to be in f_manager. + // And it's not like any of fLiMgBa_c's methods are accessed via actor_list, + // so who can tell? Maybe there's yet another type? + fLiNdBa_c *node = static_cast(actor_list.getFirst()); while (node != nullptr) { node->unlink(); - node = actor_list.getFirst(); + node = static_cast(actor_list.getFirst()); } } diff --git a/src/f/f_list.cpp b/src/f/f_list.cpp index 53d2d042..39f6d2a1 100644 --- a/src/f/f_list.cpp +++ b/src/f/f_list.cpp @@ -81,7 +81,7 @@ void fLiNdBa_c::link(fBase_c *link) { /* 802e2830 */ void fLiNdBa_c::unlink() { if (p_owner != nullptr) { - reinterpret_cast(p_owner)->actor_list.remove(this); + p_owner->actor_list.remove(this); p_owner = nullptr; } }