From 115343f6e52bd45a6bb318269e4d88bda708aefa Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 28 Oct 2024 11:04:08 -0700 Subject: [PATCH] Implement/match PizzeriaState::NextAction (#1125) * Implement/match PizzeriaState::NextAction * Name globals * Refactor globals into class statics * Remove TODO --- LEGO1/lego/legoomni/include/pizza.h | 12 +++++++ LEGO1/lego/legoomni/include/pizzeria.h | 13 ++++--- LEGO1/lego/legoomni/src/actors/pizza.cpp | 20 +++++------ LEGO1/lego/legoomni/src/actors/pizzeria.cpp | 38 ++++++++++++--------- 4 files changed, 53 insertions(+), 30 deletions(-) diff --git a/LEGO1/lego/legoomni/include/pizza.h b/LEGO1/lego/legoomni/include/pizza.h index 961d5923..629020cf 100644 --- a/LEGO1/lego/legoomni/include/pizza.h +++ b/LEGO1/lego/legoomni/include/pizza.h @@ -146,6 +146,18 @@ class PizzaMissionState : public LegoState { undefined4 m_unk0x0c; // 0x0c Mission m_missions[5]; // 0x10 MxU32 m_unk0xb0; // 0xb0 + + static IsleScript::Script g_pepperActions[]; + static IsleScript::Script g_mamaActions[]; + static IsleScript::Script g_papaActions[]; + static IsleScript::Script g_nickActions[]; + static IsleScript::Script g_lauraActions[]; + + static MxLong g_pepperFinishTimes[]; + static MxLong g_mamaFinishTimes[]; + static MxLong g_papaFinishTimes[]; + static MxLong g_nickFinishTimes[]; + static MxLong g_lauraFinishTimes[]; }; // VTABLE: LEGO1 0x100d7380 diff --git a/LEGO1/lego/legoomni/include/pizzeria.h b/LEGO1/lego/legoomni/include/pizzeria.h index 69ea1b9d..52bb9827 100644 --- a/LEGO1/lego/legoomni/include/pizzeria.h +++ b/LEGO1/lego/legoomni/include/pizzeria.h @@ -1,6 +1,7 @@ #ifndef PIZZERIA_H #define PIZZERIA_H +#include "actionsfwd.h" #include "decomp.h" #include "isleactor.h" #include "legostate.h" @@ -32,12 +33,16 @@ class PizzeriaState : public LegoState { // PizzeriaState::`scalar deleting destructor' MxS16 FUN_10017d50(); - MxU32 FUN_10017d70(); + MxU32 NextAction(); - // TODO: Most likely getters/setters are not used according to BETA. + Playlist m_unk0x08[5]; // 0x08 + MxS32 m_unk0x44[5]; // 0x44 - Playlist m_unk0x08[5]; // 0x08 - undefined4 m_unk0x44[5]; // 0x44 + static IsleScript::Script g_pepperActions[]; + static IsleScript::Script g_mamaActions[]; + static IsleScript::Script g_papaActions[]; + static IsleScript::Script g_nickActions[]; + static IsleScript::Script g_lauraActions[]; }; // VTABLE: LEGO1 0x100d5520 diff --git a/LEGO1/lego/legoomni/src/actors/pizza.cpp b/LEGO1/lego/legoomni/src/actors/pizza.cpp index 490068d3..82589946 100644 --- a/LEGO1/lego/legoomni/src/actors/pizza.cpp +++ b/LEGO1/lego/legoomni/src/actors/pizza.cpp @@ -25,7 +25,7 @@ DECOMP_SIZE_ASSERT(PizzaMissionState::Mission, 0x20) extern MxU32 g_isleFlags; // GLOBAL: LEGO1 0x100f3a80 -IsleScript::Script g_pepperActions[] = { +IsleScript::Script PizzaMissionState::g_pepperActions[] = { IsleScript::c_pnsx48pr_RunAnim, IsleScript::c_pnsx69pr_RunAnim, IsleScript::c_pns125ni_RunAnim, @@ -42,10 +42,10 @@ IsleScript::Script g_pepperActions[] = { }; // GLOBAL: LEGO1 0x100f3ab8 -MxLong g_pepperFinishTimes[] = {100000, 200000, 300000, 350000}; +MxLong PizzaMissionState::g_pepperFinishTimes[] = {100000, 200000, 300000, 350000}; // GLOBAL: LEGO1 0x100f3ac8 -IsleScript::Script g_lauraActions[] = { +IsleScript::Script PizzaMissionState::g_lauraActions[] = { IsleScript::c_pns096pr_RunAnim, IsleScript::c_pns097pr_RunAnim, IsleScript::c_pns098pr_RunAnim, @@ -62,10 +62,10 @@ IsleScript::Script g_lauraActions[] = { }; // GLOBAL: LEGO1 0x100f3b00 -MxLong g_lauraFinishTimes[] = {100000, 200000, 300000, 350000}; +MxLong PizzaMissionState::g_lauraFinishTimes[] = {100000, 200000, 300000, 350000}; // GLOBAL: LEGO1 0x100f3b10 -IsleScript::Script g_nickActions[] = { +IsleScript::Script PizzaMissionState::g_nickActions[] = { IsleScript::c_pns042bm_RunAnim, IsleScript::c_pns043en_RunAnim, IsleScript::c_pns045p1_RunAnim, @@ -82,10 +82,10 @@ IsleScript::Script g_nickActions[] = { }; // GLOBAL: LEGO1 0x100f3b48 -MxLong g_nickFinishTimes[] = {100000, 200000, 300000, 350000}; +MxLong PizzaMissionState::g_nickFinishTimes[] = {100000, 200000, 300000, 350000}; // GLOBAL: LEGO1 0x100f3b58 -IsleScript::Script g_mamaActions[] = { +IsleScript::Script PizzaMissionState::g_mamaActions[] = { IsleScript::c_pns022pr_RunAnim, IsleScript::c_pns021dl_RunAnim, IsleScript::c_pns018rd_RunAnim, @@ -102,10 +102,10 @@ IsleScript::Script g_mamaActions[] = { }; // GLOBAL: LEGO1 0x100f3b90 -MxLong g_mamaFinishTimes[] = {100000, 200000, 300000, 350000}; +MxLong PizzaMissionState::g_mamaFinishTimes[] = {100000, 200000, 300000, 350000}; // GLOBAL: LEGO1 0x100f3ba0 -IsleScript::Script g_papaActions[] = { +IsleScript::Script PizzaMissionState::g_papaActions[] = { IsleScript::c_pns065rd_RunAnim, IsleScript::c_pns066db_RunAnim, IsleScript::c_pns067gd_RunAnim, @@ -122,7 +122,7 @@ IsleScript::Script g_papaActions[] = { }; // GLOBAL: LEGO1 0x100f3bd8 -MxLong g_papaFinishTimes[] = {100000, 200000, 300000, 350000}; +MxLong PizzaMissionState::g_papaFinishTimes[] = {100000, 200000, 300000, 350000}; // FUNCTION: LEGO1 0x10037ef0 Pizza::Pizza() diff --git a/LEGO1/lego/legoomni/src/actors/pizzeria.cpp b/LEGO1/lego/legoomni/src/actors/pizzeria.cpp index 2f8e2642..a7681f87 100644 --- a/LEGO1/lego/legoomni/src/actors/pizzeria.cpp +++ b/LEGO1/lego/legoomni/src/actors/pizzeria.cpp @@ -15,23 +15,23 @@ DECOMP_SIZE_ASSERT(Pizzeria, 0x84) DECOMP_SIZE_ASSERT(PizzeriaState, 0x58) // GLOBAL: LEGO1 0x100f0ce8 -IsleScript::Script g_unk0x100f0ce8[] = +IsleScript::Script PizzeriaState::g_pepperActions[] = {IsleScript::c_ppz107ma_RunAnim, IsleScript::c_ppz114pa_RunAnim, IsleScript::c_ppz114pa_RunAnim}; // GLOBAL: LEGO1 0x100f0cf8 -IsleScript::Script g_unk0x100f0cf8[] = +IsleScript::Script PizzeriaState::g_mamaActions[] = {IsleScript::c_ppz001pe_RunAnim, IsleScript::c_ppz006pa_RunAnim, IsleScript::c_ppz007pa_RunAnim}; // GLOBAL: LEGO1 0x100f0d08 -IsleScript::Script g_unk0x100f0d08[] = +IsleScript::Script PizzeriaState::g_papaActions[] = {IsleScript::c_ppz054ma_RunAnim, IsleScript::c_ppz055ma_RunAnim, IsleScript::c_ppz056ma_RunAnim}; // GLOBAL: LEGO1 0x100f0d18 -IsleScript::Script g_unk0x100f0d18[] = +IsleScript::Script PizzeriaState::g_nickActions[] = {IsleScript::c_ppz031ma_RunAnim, IsleScript::c_ppz035pa_RunAnim, IsleScript::c_ppz036pa_RunAnim}; // GLOBAL: LEGO1 0x100f0d28 -IsleScript::Script g_unk0x100f0d28[] = +IsleScript::Script PizzeriaState::g_lauraActions[] = {IsleScript::c_ppz075pa_RunAnim, IsleScript::c_ppz082pa_RunAnim, IsleScript::c_ppz084pa_RunAnim}; // FUNCTION: LEGO1 0x100179c0 @@ -79,7 +79,7 @@ MxLong Pizzeria::HandleClick() AnimationManager()->FUN_10061010(FALSE); Pizza* pizza = (Pizza*) CurrentWorld()->Find(*g_isleScript, IsleScript::c_Pizza_Actor); - pizza->FUN_10038220((IsleScript::Script) m_pizzeriaState->FUN_10017d70()); + pizza->FUN_10038220((IsleScript::Script) m_pizzeriaState->NextAction()); } return 1; @@ -89,25 +89,31 @@ MxLong Pizzeria::HandleClick() // FUNCTION: BETA10 0x100efd14 PizzeriaState::PizzeriaState() { - m_unk0x08[0] = Playlist((MxU32*) g_unk0x100f0ce8, sizeOfArray(g_unk0x100f0ce8), Playlist::e_once); - m_unk0x08[1] = Playlist((MxU32*) g_unk0x100f0cf8, sizeOfArray(g_unk0x100f0cf8), Playlist::e_once); - m_unk0x08[2] = Playlist((MxU32*) g_unk0x100f0d08, sizeOfArray(g_unk0x100f0d08), Playlist::e_once); - m_unk0x08[3] = Playlist((MxU32*) g_unk0x100f0d18, sizeOfArray(g_unk0x100f0d18), Playlist::e_once); - m_unk0x08[4] = Playlist((MxU32*) g_unk0x100f0d28, sizeOfArray(g_unk0x100f0d28), Playlist::e_once); + m_unk0x08[0] = Playlist((MxU32*) g_pepperActions, sizeOfArray(g_pepperActions), Playlist::e_once); + m_unk0x08[1] = Playlist((MxU32*) g_mamaActions, sizeOfArray(g_mamaActions), Playlist::e_once); + m_unk0x08[2] = Playlist((MxU32*) g_papaActions, sizeOfArray(g_papaActions), Playlist::e_once); + m_unk0x08[3] = Playlist((MxU32*) g_nickActions, sizeOfArray(g_nickActions), Playlist::e_once); + m_unk0x08[4] = Playlist((MxU32*) g_lauraActions, sizeOfArray(g_lauraActions), Playlist::e_once); memset(m_unk0x44, -1, sizeof(m_unk0x44)); } -// STUB: LEGO1 0x10017d50 +// FUNCTION: LEGO1 0x10017d50 MxS16 PizzeriaState::FUN_10017d50() { - return 0; + return m_unk0x44[GameState()->GetActorId() - 1]; } -// STUB: LEGO1 0x10017d70 +// FUNCTION: LEGO1 0x10017d70 // FUNCTION: BETA10 0x100effc0 -MxU32 PizzeriaState::FUN_10017d70() +MxU32 PizzeriaState::NextAction() { - return 0; + MxU8 actorId = GameState()->GetActorId(); + + if (m_unk0x44[actorId - 1] < 2) { + m_unk0x44[actorId - 1]++; + } + + return m_unk0x08[actorId - 1].Next(); } // FUNCTION: LEGO1 0x10017da0