From 79d5df69e13c5e1323e16a9964c658f262041558 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Tue, 17 Oct 2023 12:25:54 -0700 Subject: [PATCH] Match and link CStateMachineFactory Former-commit-id: fdf57fb977840449171779a3d788b13af7c6c5fc --- config/GM8E01_00/symbols.txt | 8 ++++---- config/GM8E01_01/symbols.txt | 6 +++--- configure.py | 2 +- include/MetroidPrime/Enemies/CStateMachine.hpp | 6 ++++-- src/MetroidPrime/Enemies/CStateMachine.cpp | 13 +++++++++---- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/config/GM8E01_00/symbols.txt b/config/GM8E01_00/symbols.txt index fb1a941f..2a2bc371 100644 --- a/config/GM8E01_00/symbols.txt +++ b/config/GM8E01_00/symbols.txt @@ -5934,11 +5934,11 @@ fn_800DE758 = .text:0x800DE758; // type:function size:0x74 __sinit_CSamusDoll_cpp = .text:0x800DE7CC; // type:function size:0x30 scope:local FAiFiniteStateMachineFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x800DE7FC; // type:function size:0x64 scope:global __ct<13CStateMachine>__16CFactoryFnReturnFP13CStateMachine = .text:0x800DE860; // type:function size:0xA4 scope:global -fn_800DE904 = .text:0x800DE904; // type:function size:0x90 -fn_800DE994 = .text:0x800DE994; // type:function size:0xDC +__dt__41TObjOwnerDerivedFromIObj<13CStateMachine>Fv = .text:0x800DE904; // type:function size:0x90 +__dt__13CStateMachineFv = .text:0x800DE994; // type:function size:0xDC GetIObjObjectFor__23TToken<13CStateMachine>FRCQ24rstl25auto_ptr<13CStateMachine> = .text:0x800DEA70; // type:function size:0x2C scope:global GetNewDerivedObject__41TObjOwnerDerivedFromIObj<13CStateMachine>FRCQ24rstl25auto_ptr<13CStateMachine> = .text:0x800DEA9C; // type:function size:0x9C scope:global -__dt__Q24rstl53auto_ptr<41TObjOwnerDerivedFromIObj<13CStateMachine>>Fv = .text:0x800DEB38; // type:function size:0x64 scope:global +__dt__Q24rstl25auto_ptr<13CStateMachine>Fv = .text:0x800DEB38; // type:function size:0x64 scope:global SetWorldLighting__11CPlasmaBeamFR13CStateManager7TAreaIdff = .text:0x800DEB9C; // type:function size:0x130 scope:global EnableSecondaryFx__11CPlasmaBeamFQ210CGunWeapon16ESecondaryFxType = .text:0x800DECCC; // type:function size:0x134 scope:global IsLoaded__11CPlasmaBeamCFv = .text:0x800DEE00; // type:function size:0x54 scope:global @@ -18208,7 +18208,7 @@ lbl_803DF580 = .data:0x803DF580; // type:object size:0x84 jumptable_803DF604 = .data:0x803DF604; // type:object size:0x80 scope:local lbl_803DF688 = .data:0x803DF688; // type:object size:0x6C lbl_803DF6F4 = .data:0x803DF6F4; // type:object size:0xC -lbl_803DF700 = .data:0x803DF700; // type:object size:0x10 +__vt__41TObjOwnerDerivedFromIObj<13CStateMachine> = .data:0x803DF700; // type:object size:0x10 __vt__11CPlasmaBeam = .data:0x803DF710; // type:object size:0x44 scope:global __vt__10CPowerBeam = .data:0x803DF758; // type:object size:0x48 scope:global __vt__9CWaveBeam = .data:0x803DF7A0; // type:object size:0x48 scope:global diff --git a/config/GM8E01_01/symbols.txt b/config/GM8E01_01/symbols.txt index ebcdaa0e..ee06f438 100644 --- a/config/GM8E01_01/symbols.txt +++ b/config/GM8E01_01/symbols.txt @@ -5936,8 +5936,8 @@ fn_800DE758 = .text:0x800DE7D4; // type:function size:0x74 scope:global __sinit_CSamusDoll_cpp = .text:0x800DE848; // type:function size:0x30 scope:global FAiFiniteStateMachineFactory__FRC10SObjectTagR12CInputStreamRC15CVParamTransfer = .text:0x800DE878; // type:function size:0x64 scope:global __ct<13CStateMachine>__16CFactoryFnReturnFP13CStateMachine = .text:0x800DE8DC; // type:function size:0xA4 scope:global -fn_800DE904 = .text:0x800DE980; // type:function size:0x90 scope:global -fn_800DE994 = .text:0x800DEA10; // type:function size:0xDC scope:global +__dt__41TObjOwnerDerivedFromIObj<13CStateMachine>Fv = .text:0x800DE980; // type:function size:0x90 scope:global +__dt__13CStateMachineFv = .text:0x800DEA10; // type:function size:0xDC scope:global GetIObjObjectFor__23TToken<13CStateMachine>FRCQ24rstl25auto_ptr<13CStateMachine> = .text:0x800DEAEC; // type:function size:0x2C scope:global GetNewDerivedObject__41TObjOwnerDerivedFromIObj<13CStateMachine>FRCQ24rstl25auto_ptr<13CStateMachine> = .text:0x800DEB18; // type:function size:0x9C scope:global __dt__Q24rstl53auto_ptr<41TObjOwnerDerivedFromIObj<13CStateMachine>>Fv = .text:0x800DEBB4; // type:function size:0x64 scope:global @@ -18261,7 +18261,7 @@ lbl_803DF580 = .data:0x803DF760; // type:object size:0x84 scope:global lbl_803DF604 = .data:0x803DF7E4; // type:object size:0x80 scope:global lbl_803DF688 = .data:0x803DF868; // type:object size:0x6C scope:global lbl_803DF6F4 = .data:0x803DF8D4; // type:object size:0xC scope:global -lbl_803DF700 = .data:0x803DF8E0; // type:object size:0x10 scope:global +__vt__41TObjOwnerDerivedFromIObj<13CStateMachine> = .data:0x803DF8E0; // type:object size:0x10 scope:global __vt__11CPlasmaBeam = .data:0x803DF8F0; // type:object size:0x48 scope:global __vt__10CPowerBeam = .data:0x803DF938; // type:object size:0x48 scope:global __vt__9CWaveBeam = .data:0x803DF980; // type:object size:0x48 scope:global diff --git a/configure.py b/configure.py index b3d422f1..ad3a967e 100755 --- a/configure.py +++ b/configure.py @@ -371,7 +371,7 @@ config.libs = [ Object(NonMatching, "MetroidPrime/ScriptObjects/CScriptCameraHint.cpp"), Object(NonMatching, "MetroidPrime/ScriptLoader.cpp"), Object(NonMatching, "MetroidPrime/CSamusDoll.cpp"), - Object(NonMatching, "MetroidPrime/Factories/CStateMachineFactory.cpp"), + Object(Matching, "MetroidPrime/Factories/CStateMachineFactory.cpp"), Object(Matching, "MetroidPrime/Weapons/CPlasmaBeam.cpp"), Object(Matching, "MetroidPrime/Weapons/CPowerBeam.cpp"), Object(NonMatching, "MetroidPrime/Weapons/CWaveBeam.cpp"), diff --git a/include/MetroidPrime/Enemies/CStateMachine.hpp b/include/MetroidPrime/Enemies/CStateMachine.hpp index 5748bd6a..d7d036f6 100644 --- a/include/MetroidPrime/Enemies/CStateMachine.hpp +++ b/include/MetroidPrime/Enemies/CStateMachine.hpp @@ -55,8 +55,10 @@ private: class CAiState { public: - CAiState(CAiStateFunc func, const char* name) { - x0_func = func; + CAiState(CAiStateFunc func, const char* name) + : x0_func(func) + , x2c_numTriggers(0) + , x30_firstTrigger(nullptr) { strncpy(xc_name, name, 31); } diff --git a/src/MetroidPrime/Enemies/CStateMachine.cpp b/src/MetroidPrime/Enemies/CStateMachine.cpp index 60f6abd5..9bf70123 100644 --- a/src/MetroidPrime/Enemies/CStateMachine.cpp +++ b/src/MetroidPrime/Enemies/CStateMachine.cpp @@ -115,6 +115,10 @@ CStateMachine::CStateMachine(CInputStream& in) { continue; } + for (uint i = 0; i < x0_states[i].GetNumTriggers(); ++i) { + x10_triggers.push_back(CAiTrigger()); + } + CAiTrigger* firstTrig = x10_triggers.data() + x10_triggers.size(); x0_states[i].SetTriggers(firstTrig); @@ -133,17 +137,18 @@ CStateMachine::CStateMachine(CInputStream& in) { } } - const bool isNot = name[0] == '!'; - const CAiTriggerFunc func = CAi::GetTriggerFunc(isNot ? name + 1 : name); + name[nameLen] = '\0'; + + const CAiTriggerFunc func = CAi::GetTriggerFunc(name[0] == '!' ? name + 1 : name); const float arg = in.Get< float >(); + const bool isNot = name[0] == '!'; CAiTrigger* newTrig; if (k < lastTriggerIdx) { x10_triggers.push_back(CAiTrigger()); newTrig = &x10_triggers.back(); } else { - newTrig = &firstTrig[j]; + newTrig = x0_states[i].GetTrig(j); } - if (k == 0) { newTrig->Setup(func, isNot, arg, &x0_states[in.Get< int >()]); } else {