diff --git a/data/uking_functions.csv b/data/uking_functions.csv index eab11454..1c42ba29 100644 --- a/data/uking_functions.csv +++ b/data/uking_functions.csv @@ -1313,14 +1313,14 @@ 0x000000710004c188,AI_AIOrActionBase::isFlag1Set,12,_ZNK4ksys3act2ai10ActionBase8isFailedEv 0x000000710004c194,AI_AIOrActionBase::isFinished,12,_ZNK4ksys3act2ai10ActionBase10isFinishedEv 0x000000710004c1a0,AI_AIOrActionBase::isFlag2Set,12,_ZNK4ksys3act2ai10ActionBase10isFlag4SetEv -0x000000710004c1ac,AI_AIOrActionBase::ret0,8,_ZN4ksys3act2ai10ActionBase2m7Ev -0x000000710004c1b4,AI_AIOrActionBase::ret0_2,8,_ZN4ksys3act2ai10ActionBase2m8Ev +0x000000710004c1ac,AI_AIOrActionBase::ret0,8,_ZN4ksys3act2ai10ActionBase14hasPreDeleteCbEv +0x000000710004c1b4,AI_AIOrActionBase::ret0_2,8,_ZN4ksys3act2ai10ActionBase23hasUpdateForPreDeleteCbEv 0x000000710004c1bc,AI_AIOrActionBase::m9_null,4,_ZN4ksys3act2ai10ActionBase2m9Ev 0x000000710004c1c0,AI_AIOrActionBase::ret1,8,_ZN4ksys3act2ai10ActionBase8oneShot_Ev 0x000000710004c1c8,AI_AIOrActionBase::ret0_3,8,_ZN4ksys3act2ai10ActionBase3m16Ev 0x000000710004c1d0,AI_AIOrActionBase::ret0_4,8,_ZN4ksys3act2ai10ActionBase3m17Ev -0x000000710004c1d8,AI_AIOrActionBase::ret1_0,8,_ZN4ksys3act2ai10ActionBase3m18Ev -0x000000710004c1e0,AI_AIOrActionBase::m19_null,4,_ZN4ksys3act2ai10ActionBase3m19Ev +0x000000710004c1d8,AI_AIOrActionBase::ret1_0,8,_ZN4ksys3act2ai10ActionBase18updateForPreDeleteEv +0x000000710004c1e0,AI_AIOrActionBase::m19_null,4,_ZN4ksys3act2ai10ActionBase11onPreDeleteEv 0x000000710004c1e4,AI_AIOrActionBase::ret0_0,8,_ZN4ksys3act2ai10ActionBase3m22Ev 0x000000710004c1ec,AI_AIOrActionBase::ret0_1,8,_ZNK4ksys3act2ai10ActionBase14getNumChildrenEv 0x000000710004c1f4,AI_AIOrActionBase::ret1_1,8,_ZN4ksys3act2ai10ActionBase12initChildrenERKNS_8AIDefSetEPN4sead4HeapE @@ -1329,8 +1329,8 @@ 0x000000710004c20c,AI_AIOrActionBase::m28,16,_ZN4ksys3act2ai10ActionBase7reenterEPS2_RKN4sead14SafeStringBaseIcEE 0x000000710004c21c,AI_AIOrActionBase::m29_null,4,_ZN4ksys3act2ai10ActionBase9postLeaveEv 0x000000710004c220,AI_AIOrActionBase::ret0_6,8,_ZNK4ksys3act2ai10ActionBase8getChildEi -0x000000710004c228,sub_710004C228,140, -0x000000710004c2b4,sub_710004C2B4,140, +0x000000710004c228,sub_710004C228,140,_ZNK4sead15RuntimeTypeInfo6DeriveIN4ksys3act2ai6ActionEE9isDerivedEPKNS0_9InterfaceE +0x000000710004c2b4,sub_710004C2B4,140,_ZNK4sead15RuntimeTypeInfo6DeriveIN4ksys3act2ai10ActionBaseEE9isDerivedEPKNS0_9InterfaceE 0x000000710004c340,AI_Action_AnimeDrivenTurn::ctor,104, 0x000000710004c3a8,AI_Action_AnimeDrivenTurn::dtor,20, 0x000000710004c3bc,AI_Action_AnimeDrivenTurn::dtorDelete,52, @@ -1555,7 +1555,7 @@ 0x00000071000570d0,sub_71000570D0,92, 0x000000710005712c,nullsub_102,4, 0x0000007100057130,sub_7100057130,140, -0x00000071000571bc,sub_71000571BC,140, +0x00000071000571bc,sub_71000571BC,140,_ZNK4sead15RuntimeTypeInfo6DeriveIN4ksys3act2ai2AiEE9isDerivedEPKNS0_9InterfaceE 0x0000007100057248,AI_Action_DgnObjDLCSpurGearB01::ctor,72, 0x0000007100057290,j_AI_Action_GearRotate::dtor,4, 0x0000007100057294,_ZN4gsys12LayerTextureD0Ev,36, @@ -91926,8 +91926,8 @@ 0x00000071011c2740,ai::Actions::init,1248,_ZN4ksys3act2ai7Actions4initEPNS0_5ActorEPN4sead4HeapE 0x00000071011c2c20,sub_71011C2C20,32,_ZN4ksys3act2ai7Actions12setFactoriesEiPNS1_13ActionFactoryE 0x00000071011c2c40,sub_71011C2C40,300,_ZN4ksys3act2ai7Actions5cloneERKNS1_6ActionEPN4sead4HeapE -0x00000071011c2d6c,sub_71011C2D6C,96,_ZNK4ksys3act2ai7Actions17onActorPreDelete2Ev -0x00000071011c2dcc,sub_71011C2DCC,68,_ZNK4ksys3act2ai7Actions17onActorPreDelete1Ev +0x00000071011c2d6c,sub_71011C2D6C,96,_ZNK4ksys3act2ai7Actions18updateForPreDeleteEv +0x00000071011c2dcc,sub_71011C2DCC,68,_ZNK4ksys3act2ai7Actions11onPreDeleteEv 0x00000071011c2e10,Dummy::construct,68, 0x00000071011c2e54,getDummyBaseProcLink,12, 0x00000071011c2e60,Actor::ctor,1208, @@ -92284,8 +92284,8 @@ 0x00000071011df0e4,sub_71011DF0E4,200,_ZN4ksys3act2ai3Ais8finalizeEv 0x00000071011df1ac,ai::AIs::init,1276,_ZN4ksys3act2ai3Ais4initEPNS0_5ActorEPN4sead4HeapE 0x00000071011df6a8,sub_71011DF6A8,32,_ZN4ksys3act2ai3Ais12setFactoriesEiPNS1_9AiFactoryE -0x00000071011df6c8,sub_71011DF6C8,96,_ZNK4ksys3act2ai3Ais17onActorPreDelete2Ev -0x00000071011df728,sub_71011DF728,68,_ZNK4ksys3act2ai3Ais17onActorPreDelete1Ev +0x00000071011df6c8,sub_71011DF6C8,96,_ZNK4ksys3act2ai3Ais18updateForPreDeleteEv +0x00000071011df728,sub_71011DF728,68,_ZNK4ksys3act2ai3Ais11onPreDeleteEv 0x00000071011df76c,sub_71011DF76C,92,_ZN4ksys10AIClassDef18SingletonDisposer_D2Ev 0x00000071011df7c8,sub_71011DF7C8,100,_ZN4ksys10AIClassDef18SingletonDisposer_D0Ev 0x00000071011df82c,AIClassDef::createInstance,132,_ZN4ksys10AIClassDef14createInstanceEPN4sead4HeapE diff --git a/src/KingSystem/ActorSystem/actAiAction.cpp b/src/KingSystem/ActorSystem/actAiAction.cpp index 0f973f9f..0f87ac9f 100644 --- a/src/KingSystem/ActorSystem/actAiAction.cpp +++ b/src/KingSystem/ActorSystem/actAiAction.cpp @@ -21,16 +21,16 @@ Actions::~Actions() { } void Actions::finalize() { - for (s32 i = 0; i < classes.size(); ++i) { - if (classes[i]) { - delete classes[i]; - classes[i] = nullptr; + for (s32 i = 0; i < mClasses.size(); ++i) { + if (mClasses[i]) { + delete mClasses[i]; + mClasses[i] = nullptr; } } - predelete1_callbacks.freeBuffer(); - predelete2_callbacks.freeBuffer(); - classes.freeBuffer(); + mOnPreDeleteCbs.freeBuffer(); + mUpdateForPreDeleteCbs.freeBuffer(); + mClasses.freeBuffer(); } bool Actions::init(Actor* actor, sead::Heap* heap) { @@ -40,19 +40,19 @@ bool Actions::init(Actor* actor, sead::Heap* heap) { if (num_actions == 0) return true; - if (!classes.tryAllocBuffer(num_actions, heap)) + if (!mClasses.tryAllocBuffer(num_actions, heap)) return false; for (s32 i = 0; i < num_actions; ++i) - classes(i) = nullptr; - auto it_class = classes.begin(); - const auto it_class_end = classes.end(); + mClasses(i) = nullptr; + auto it_class = mClasses.begin(); + const auto it_class_end = mClasses.end(); Action::InitArg arg{}; arg.actor = actor; arg.def_idx = -1; arg.root_idx = -1; - s32 predelete1_callback_num = 0; - s32 predelete2_callback_num = 0; + s32 pre_delete_cb_num = 0; + s32 update_cb_num = 0; for (; it_class != it_class_end; ++it_class) { const char* name; if (it_class.getIndex() >= num_actions) { @@ -73,38 +73,38 @@ bool Actions::init(Actor* actor, sead::Heap* heap) { if (!*it_class) return false; - predelete2_callback_num += (*it_class)->m8(); - predelete1_callback_num += (*it_class)->m7(); + update_cb_num += (*it_class)->hasUpdateForPreDeleteCb(); + pre_delete_cb_num += (*it_class)->hasPreDeleteCb(); } // Allocate the callback lists. - if (predelete1_callback_num != 0) { - if (!predelete1_callbacks.tryAllocBuffer(predelete1_callback_num, heap)) + if (pre_delete_cb_num != 0) { + if (!mOnPreDeleteCbs.tryAllocBuffer(pre_delete_cb_num, heap)) return false; - for (s32 i = 0; i < predelete1_callback_num; ++i) - predelete1_callbacks(i) = nullptr; + for (s32 i = 0; i < pre_delete_cb_num; ++i) + mOnPreDeleteCbs(i) = nullptr; } - if (predelete2_callback_num != 0) { - if (!predelete2_callbacks.tryAllocBuffer(predelete2_callback_num, heap)) + if (update_cb_num != 0) { + if (!mUpdateForPreDeleteCbs.tryAllocBuffer(update_cb_num, heap)) return false; - for (s32 i = 0; i < predelete2_callback_num; ++i) - predelete2_callbacks(i) = nullptr; + for (s32 i = 0; i < update_cb_num; ++i) + mUpdateForPreDeleteCbs(i) = nullptr; } // Initialize each class. s32 idx_cb1 = 0, idx_cb2 = 0; - for (auto it = classes.begin(), end = classes.end(); it != end; ++it) { + for (auto it = mClasses.begin(), end = mClasses.end(); it != end; ++it) { if (!(*it)->init(heap, false)) return false; - if ((*it)->m8()) { - predelete2_callbacks[idx_cb2] = *it; + if ((*it)->hasUpdateForPreDeleteCb()) { + mUpdateForPreDeleteCbs[idx_cb2] = *it; ++idx_cb2; } - if ((*it)->m7()) { - predelete1_callbacks[idx_cb1] = *it; + if ((*it)->hasPreDeleteCb()) { + mOnPreDeleteCbs[idx_cb1] = *it; ++idx_cb1; } } @@ -130,19 +130,19 @@ Action* Actions::clone(const Action& action, sead::Heap* heap) { return clone; } -bool Actions::onActorPreDelete2() const { +bool Actions::updateForPreDelete() const { bool ok = true; - for (auto* action : predelete2_callbacks) { + for (auto* action : mUpdateForPreDeleteCbs) { if (action) - ok &= action->m18(); + ok &= action->updateForPreDelete(); } return ok; } -void Actions::onActorPreDelete1() const { - for (auto* action : predelete1_callbacks) { +void Actions::onPreDelete() const { + for (auto* action : mOnPreDeleteCbs) { if (action) - action->m19(); + action->onPreDelete(); } } diff --git a/src/KingSystem/ActorSystem/actAiAction.h b/src/KingSystem/ActorSystem/actAiAction.h index 9ffa28a5..634cb134 100644 --- a/src/KingSystem/ActorSystem/actAiAction.h +++ b/src/KingSystem/ActorSystem/actAiAction.h @@ -34,21 +34,22 @@ public: void finalize(); bool init(Actor* actor, sead::Heap* heap); - bool onActorPreDelete2() const; - void onActorPreDelete1() const; + bool updateForPreDelete() const; + void onPreDelete() const; + + const sead::Buffer& getClasses() const { return mClasses; } static Action* clone(const Action& action, sead::Heap* heap); static ActionFactory* getFactory(const sead::SafeString& name); static void setFactories(int count, ActionFactory* factories); - sead::Buffer classes; - // Non-owning buffer. - sead::Buffer predelete1_callbacks; - // Non-owning buffer. - sead::Buffer predelete2_callbacks; - private: static inline sead::Buffer sFactories; + sead::Buffer mClasses; + // Non-owning buffer. + sead::Buffer mOnPreDeleteCbs; + // Non-owning buffer. + sead::Buffer mUpdateForPreDeleteCbs; }; } // namespace ksys::act::ai diff --git a/src/KingSystem/ActorSystem/actAiActionBase.h b/src/KingSystem/ActorSystem/actAiActionBase.h index 404771ba..a75280e4 100644 --- a/src/KingSystem/ActorSystem/actAiActionBase.h +++ b/src/KingSystem/ActorSystem/actAiActionBase.h @@ -71,8 +71,8 @@ public: virtual bool isFinished() const { return mFlags.isOn(Flag::Finished); } virtual bool isFlag4Set() const { return mFlags.isOn(Flag::_4); } - virtual bool m7() { return false; } - virtual bool m8() { return false; } + virtual bool hasPreDeleteCb() { return false; } + virtual bool hasUpdateForPreDeleteCb() { return false; } virtual void m9() {} virtual bool oneShot_() { return true; } virtual bool init_(sead::Heap* heap) { return true; } @@ -82,8 +82,8 @@ public: virtual void loadParams_() {} virtual bool m16() { return false; } virtual bool m17() { return false; } - virtual bool m18() { return true; } - virtual void m19() {} + virtual bool updateForPreDelete() { return true; } + virtual void onPreDelete() {} virtual void calc() {} virtual void getCurrentName(sead::BufferedSafeString* name, ActionBase* last) const; virtual void* m22() { return nullptr; } diff --git a/src/KingSystem/ActorSystem/actAiAi.cpp b/src/KingSystem/ActorSystem/actAiAi.cpp index 46e5bc90..f12391af 100644 --- a/src/KingSystem/ActorSystem/actAiAi.cpp +++ b/src/KingSystem/ActorSystem/actAiAi.cpp @@ -60,9 +60,9 @@ bool Ai::initChildren_(s32 num_children, const char** names, sead::Buffer& for (; it_ptr != it_ptr_end && it_idx != it_idx_end; ++it_ptr, ++it_idx) { if (*it_idx < effective_ai_count) - *it_ptr = root_ai->getAis().classes[*it_idx]; + *it_ptr = root_ai->getAis().getClasses()[*it_idx]; else - *it_ptr = root_ai->getActions().classes[*it_idx - effective_ai_count]; + *it_ptr = root_ai->getActions().getClasses()[*it_idx - effective_ai_count]; if (*it_ptr == nullptr) return false; @@ -113,16 +113,16 @@ Ais::~Ais() { } void Ais::finalize() { - for (s32 i = 0; i < classes.size(); ++i) { - if (classes[i]) { - delete classes[i]; - classes[i] = nullptr; + for (s32 i = 0; i < mClasses.size(); ++i) { + if (mClasses[i]) { + delete mClasses[i]; + mClasses[i] = nullptr; } } - predelete1_callbacks.freeBuffer(); - predelete2_callbacks.freeBuffer(); - classes.freeBuffer(); + mOnPreDeleteCbs.freeBuffer(); + mUpdateForPreDeleteCbs.freeBuffer(); + mClasses.freeBuffer(); } bool Ais::init(Actor* actor, sead::Heap* heap) { @@ -132,19 +132,19 @@ bool Ais::init(Actor* actor, sead::Heap* heap) { if (num_ais < 0) return false; - if (!classes.tryAllocBuffer(num_ais + 1, heap)) + if (!mClasses.tryAllocBuffer(num_ais + 1, heap)) return false; - for (s32 i = 0, n = classes.size(); i != n; ++i) - classes(i) = nullptr; - auto it_class = classes.begin(); - const auto it_class_end = classes.end(); + for (s32 i = 0, n = mClasses.size(); i != n; ++i) + mClasses(i) = nullptr; + auto it_class = mClasses.begin(); + const auto it_class_end = mClasses.end(); Ai::InitArg arg{}; arg.actor = actor; arg.def_idx = -1; arg.root_idx = -1; - s32 predelete1_callback_num = 0; - s32 predelete2_callback_num = 0; + s32 predelete_cb_num = 0; + s32 update_cb_num = 0; for (; it_class != it_class_end; ++it_class) { const char* name; if (it_class.getIndex() >= num_ais) { @@ -165,43 +165,43 @@ bool Ais::init(Actor* actor, sead::Heap* heap) { if (!*it_class) return false; - predelete2_callback_num += (*it_class)->m8(); - predelete1_callback_num += (*it_class)->m7(); + update_cb_num += (*it_class)->hasUpdateForPreDeleteCb(); + predelete_cb_num += (*it_class)->hasPreDeleteCb(); } // Allocate the callback lists. - if (predelete1_callback_num != 0) { - if (!predelete1_callbacks.tryAllocBuffer(predelete1_callback_num, heap)) + if (predelete_cb_num != 0) { + if (!mOnPreDeleteCbs.tryAllocBuffer(predelete_cb_num, heap)) return false; - for (s32 i = 0; i < predelete1_callback_num; ++i) - predelete1_callbacks(i) = nullptr; + for (s32 i = 0; i < predelete_cb_num; ++i) + mOnPreDeleteCbs(i) = nullptr; } - if (predelete2_callback_num != 0) { - if (!predelete2_callbacks.tryAllocBuffer(predelete2_callback_num, heap)) + if (update_cb_num != 0) { + if (!mUpdateForPreDeleteCbs.tryAllocBuffer(update_cb_num, heap)) return false; - for (s32 i = 0; i < predelete2_callback_num; ++i) - predelete2_callbacks(i) = nullptr; + for (s32 i = 0; i < update_cb_num; ++i) + mUpdateForPreDeleteCbs(i) = nullptr; } // Initialize each class. s32 idx_cb1 = 0, idx_cb2 = 0; - for (auto it = classes.begin(), end = classes.end(); it != end; ++it) { + for (auto it = mClasses.begin(), end = mClasses.end(); it != end; ++it) { if (!(*it)->init(heap, false)) return false; - if ((*it)->m8()) { - predelete2_callbacks[idx_cb2] = *it; + if ((*it)->hasUpdateForPreDeleteCb()) { + mUpdateForPreDeleteCbs[idx_cb2] = *it; ++idx_cb2; } - if ((*it)->m7()) { - predelete1_callbacks[idx_cb1] = *it; + if ((*it)->hasPreDeleteCb()) { + mOnPreDeleteCbs[idx_cb1] = *it; ++idx_cb1; } } - for (auto* ai : classes) { + for (auto* ai : mClasses) { if (!ai->gatherParamsFromChildren(heap)) return false; } @@ -209,38 +209,19 @@ bool Ais::init(Actor* actor, sead::Heap* heap) { return true; } -Ai* Ais::clone(const Ai& action, sead::Heap* heap) { - auto* factory = getFactory(action.getClassName()); - if (!factory) - return nullptr; - - Ai::InitArg arg; - arg.actor = action.getActor(); - arg.def_idx = action.getDefinitionIdx(); - auto* clone = factory->create_fn(arg, heap); - if (!clone) { - return nullptr; - } - if (!clone->init(heap, true)) { - delete clone; - return nullptr; - } - return clone; -} - -bool Ais::onActorPreDelete2() const { +bool Ais::updateForPreDelete() const { bool ok = true; - for (auto* action : predelete2_callbacks) { + for (auto* action : mUpdateForPreDeleteCbs) { if (action) - ok &= action->m18(); + ok &= action->updateForPreDelete(); } return ok; } -void Ais::onActorPreDelete1() const { - for (auto* action : predelete1_callbacks) { +void Ais::onPreDelete() const { + for (auto* action : mOnPreDeleteCbs) { if (action) - action->m19(); + action->onPreDelete(); } } diff --git a/src/KingSystem/ActorSystem/actAiAi.h b/src/KingSystem/ActorSystem/actAiAi.h index 06213208..75b1bc0c 100644 --- a/src/KingSystem/ActorSystem/actAiAi.h +++ b/src/KingSystem/ActorSystem/actAiAi.h @@ -62,21 +62,21 @@ public: void finalize(); bool init(Actor* actor, sead::Heap* heap); - bool onActorPreDelete2() const; - void onActorPreDelete1() const; + bool updateForPreDelete() const; + void onPreDelete() const; + + const sead::Buffer& getClasses() const { return mClasses; } - static Ai* clone(const Ai& ai, sead::Heap* heap); static AiFactory* getFactory(const sead::SafeString& name); static void setFactories(int count, AiFactory* factories); - sead::Buffer classes; - // Non-owning buffer. - sead::Buffer predelete1_callbacks; - // Non-owning buffer. - sead::Buffer predelete2_callbacks; - private: static inline sead::Buffer sFactories; + sead::Buffer mClasses; + // Non-owning buffer. + sead::Buffer mOnPreDeleteCbs; + // Non-owning buffer. + sead::Buffer mUpdateForPreDeleteCbs; }; } // namespace ksys::act::ai