From 63719ef68981edbb37ee71e20e382a735f7e01ce Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 24 May 2024 14:07:36 -0400 Subject: [PATCH] Implement/match Isle::CreateState and related (#948) --- LEGO1/lego/legoomni/include/ambulance.h | 1 + LEGO1/lego/legoomni/include/helicopter.h | 5 ++- LEGO1/lego/legoomni/include/isle.h | 2 +- LEGO1/lego/legoomni/include/pizza.h | 19 +++++----- LEGO1/lego/legoomni/include/pizzeria.h | 4 +-- LEGO1/lego/legoomni/include/radio.h | 3 +- LEGO1/lego/legoomni/include/towtrack.h | 24 +++++++------ LEGO1/lego/legoomni/src/actors/ambulance.cpp | 36 ++++++++++++------- LEGO1/lego/legoomni/src/actors/helicopter.cpp | 4 +-- LEGO1/lego/legoomni/src/actors/pizza.cpp | 22 ++++++++++-- LEGO1/lego/legoomni/src/actors/pizzeria.cpp | 4 +-- LEGO1/lego/legoomni/src/actors/radio.cpp | 6 ++-- LEGO1/lego/legoomni/src/actors/towtrack.cpp | 31 +++++++++++----- LEGO1/lego/legoomni/src/worlds/isle.cpp | 23 +++++++++--- 14 files changed, 123 insertions(+), 61 deletions(-) diff --git a/LEGO1/lego/legoomni/include/ambulance.h b/LEGO1/lego/legoomni/include/ambulance.h index 1aff83a0..f5d8d04c 100644 --- a/LEGO1/lego/legoomni/include/ambulance.h +++ b/LEGO1/lego/legoomni/include/ambulance.h @@ -36,6 +36,7 @@ class Ambulance : public IslePathActor { MxU32 VTable0xdc(MxType19NotificationParam&) override; // vtable+0xdc void VTable0xe4() override; // vtable+0xe4 + void CreateState(); void FUN_10036e60(); void FUN_10037060(); diff --git a/LEGO1/lego/legoomni/include/helicopter.h b/LEGO1/lego/legoomni/include/helicopter.h index b568390a..867763be 100644 --- a/LEGO1/lego/legoomni/include/helicopter.h +++ b/LEGO1/lego/legoomni/include/helicopter.h @@ -37,6 +37,8 @@ class Helicopter : public IslePathActor { // SYNTHETIC: LEGO1 0x10003210 // Helicopter::`scalar deleting destructor' + void CreateState(); + protected: MxMatrix m_unk0x160; // 0x160 MxMatrix m_unk0x1a8; // 0x1a8 @@ -44,9 +46,6 @@ class Helicopter : public IslePathActor { UnknownMx4DPointFloat m_unk0x1f4; // 0x1f4 HelicopterState* m_state; // 0x228 MxAtomId m_script; // 0x22c - -private: - void GetState(); }; #endif // HELICOPTER_H diff --git a/LEGO1/lego/legoomni/include/isle.h b/LEGO1/lego/legoomni/include/isle.h index 8d98d423..6242a828 100644 --- a/LEGO1/lego/legoomni/include/isle.h +++ b/LEGO1/lego/legoomni/include/isle.h @@ -76,7 +76,7 @@ class Isle : public LegoWorld { void HandleElevatorEndAction(); void UpdateGlobe(); void FUN_10032620(); - void FUN_100330e0(); + void CreateState(); void FUN_10032d30( IsleScript::Script p_script, JukeboxScript::Script p_music, diff --git a/LEGO1/lego/legoomni/include/pizza.h b/LEGO1/lego/legoomni/include/pizza.h index bb8c18f7..f845868f 100644 --- a/LEGO1/lego/legoomni/include/pizza.h +++ b/LEGO1/lego/legoomni/include/pizza.h @@ -4,6 +4,8 @@ #include "decomp.h" #include "isleactor.h" +class Act1State; +class PizzaMissionState; class SkateBoard; // VTABLE: LEGO1 0x100d7380 @@ -33,6 +35,7 @@ class Pizza : public IsleActor { undefined4 HandleEndAction(MxEndActionNotificationParam&) override; // vtable+0x74 undefined4 VTable0x80(MxParam&) override; // vtable+0x80 + void CreateState(); void FUN_100382b0(); void FUN_10038380(); @@ -42,14 +45,14 @@ class Pizza : public IsleActor { // Pizza::`scalar deleting destructor' private: - undefined4 m_unk0x7c; // 0x7c - undefined4 m_unk0x80; // 0x80 - SkateBoard* m_skateboard; // 0x84 - undefined4 m_unk0x88; // 0x88 - undefined4 m_unk0x8c; // 0x8c - undefined4 m_unk0x90; // 0x90 - undefined4 m_unk0x94; // 0x94 - undefined m_unk0x98; // 0x98 + PizzaMissionState* m_state; // 0x7c + undefined4 m_unk0x80; // 0x80 + SkateBoard* m_skateboard; // 0x84 + Act1State* m_act1state; // 0x88 + undefined4 m_unk0x8c; // 0x8c + undefined4 m_unk0x90; // 0x90 + undefined4 m_unk0x94; // 0x94 + undefined m_unk0x98; // 0x98 }; #endif // PIZZA_H diff --git a/LEGO1/lego/legoomni/include/pizzeria.h b/LEGO1/lego/legoomni/include/pizzeria.h index 0f36dbdf..0991d00a 100644 --- a/LEGO1/lego/legoomni/include/pizzeria.h +++ b/LEGO1/lego/legoomni/include/pizzeria.h @@ -29,12 +29,12 @@ class Pizzeria : public IsleActor { MxResult Create(MxDSAction& p_dsAction) override; // vtable+0x18 undefined4 VTable0x68() override; // vtable+0x68 + void CreateState(); + // SYNTHETIC: LEGO1 0x1000e8d0 // Pizzeria::`scalar deleting destructor' private: - void Init(); - PizzeriaState* m_pizzeriaState; // 0x7c PizzaMissionState* m_pizzaMissionState; // 0x80 }; diff --git a/LEGO1/lego/legoomni/include/radio.h b/LEGO1/lego/legoomni/include/radio.h index 3c35a300..50b4de6f 100644 --- a/LEGO1/lego/legoomni/include/radio.h +++ b/LEGO1/lego/legoomni/include/radio.h @@ -30,6 +30,7 @@ class Radio : public MxCore { } void Initialize(MxBool p_und); + void CreateState(); void Play(); void Stop(); @@ -39,8 +40,6 @@ class Radio : public MxCore { // Radio::`scalar deleting destructor' private: - void CreateRadioState(); - RadioState* m_state; // 0x08 MxBool m_unk0x0c; // 0x0c MxBool m_audioEnabled; // 0x0d diff --git a/LEGO1/lego/legoomni/include/towtrack.h b/LEGO1/lego/legoomni/include/towtrack.h index 056f0793..0c91e8a7 100644 --- a/LEGO1/lego/legoomni/include/towtrack.h +++ b/LEGO1/lego/legoomni/include/towtrack.h @@ -4,6 +4,8 @@ #include "decomp.h" #include "islepathactor.h" +class TowTrackMissionState; + // VTABLE: LEGO1 0x100d7ee0 // SIZE 0x180 class TowTrack : public IslePathActor { @@ -32,6 +34,7 @@ class TowTrack : public IslePathActor { MxU32 VTable0xdc(MxType19NotificationParam& p_param) override; // vtable+0xdc void VTable0xe4() override; // vtable+0xe4 + void CreateState(); void FUN_1004dab0(); void FUN_1004dad0(); @@ -39,17 +42,16 @@ class TowTrack : public IslePathActor { // TowTrack::`scalar deleting destructor' private: - // TODO: TowTrack field types - undefined m_unk0x154[4]; - MxS32 m_unk0x164; - MxS16 m_unk0x168; - MxS16 m_unk0x16a; - MxS16 m_unk0x16c; - MxS16 m_unk0x16e; - MxS32 m_unk0x170; - MxS32 m_unk0x174; - MxFloat m_unk0x178; - undefined4 m_unk0x17c; + undefined4 m_unk0x160; // 0x160 + TowTrackMissionState* m_state; // 0x164 + MxS16 m_unk0x168; // 0x168 + MxS16 m_unk0x16a; // 0x16a + MxS16 m_unk0x16c; // 0x16c + MxS16 m_unk0x16e; // 0x16e + MxS32 m_unk0x170; // 0x170 + MxS32 m_unk0x174; // 0x174 + MxFloat m_unk0x178; // 0x178 + undefined4 m_unk0x17c; // 0x17c }; #endif // TOWTRACK_H diff --git a/LEGO1/lego/legoomni/src/actors/ambulance.cpp b/LEGO1/lego/legoomni/src/actors/ambulance.cpp index d793503b..d7f7ebb4 100644 --- a/LEGO1/lego/legoomni/src/actors/ambulance.cpp +++ b/LEGO1/lego/legoomni/src/actors/ambulance.cpp @@ -18,17 +18,17 @@ DECOMP_SIZE_ASSERT(Ambulance, 0x184) // FUNCTION: LEGO1 0x10035ee0 Ambulance::Ambulance() { - this->m_unk0x168 = 0; - this->m_unk0x16a = -1; - this->m_state = NULL; - this->m_unk0x16c = 0; - this->m_unk0x174 = -1; - this->m_unk0x16e = 0; - this->m_unk0x178 = -1; - this->m_unk0x170 = 0; - this->m_unk0x172 = 0; - this->m_unk0x13c = 40.0; - this->m_unk0x17c = 1.0; + m_unk0x168 = 0; + m_unk0x16a = -1; + m_state = NULL; + m_unk0x16c = 0; + m_unk0x174 = -1; + m_unk0x16e = 0; + m_unk0x178 = -1; + m_unk0x170 = 0; + m_unk0x172 = 0; + m_unk0x13c = 40.0; + m_unk0x17c = 1.0; } // FUNCTION: LEGO1 0x10035f90 @@ -66,7 +66,6 @@ MxResult Ambulance::Create(MxDSAction& p_dsAction) VariableTable()->SetVariable(g_varAMBULFUEL, "1.0"); m_unk0x17c = 1.0; m_time = Timer()->GetTime(); - return result; } @@ -76,6 +75,19 @@ void Ambulance::VTable0x70(float p_float) // TODO } +// FUNCTION: LEGO1 0x100363f0 +void Ambulance::CreateState() +{ + LegoGameState* gameState = GameState(); + AmbulanceMissionState* state = (AmbulanceMissionState*) gameState->GetState("AmbulanceMissionState"); + + if (state == NULL) { + state = (AmbulanceMissionState*) gameState->CreateState("AmbulanceMissionState"); + } + + m_state = state; +} + // STUB: LEGO1 0x10036420 MxLong Ambulance::Notify(MxParam& p_param) { diff --git a/LEGO1/lego/legoomni/src/actors/helicopter.cpp b/LEGO1/lego/legoomni/src/actors/helicopter.cpp index 078cb6c1..8307e07a 100644 --- a/LEGO1/lego/legoomni/src/actors/helicopter.cpp +++ b/LEGO1/lego/legoomni/src/actors/helicopter.cpp @@ -49,12 +49,12 @@ MxResult Helicopter::Create(MxDSAction& p_dsAction) if (world) { world->Add(this); } - GetState(); + CreateState(); return result; } // FUNCTION: LEGO1 0x10003320 -void Helicopter::GetState() +void Helicopter::CreateState() { m_state = (HelicopterState*) GameState()->GetState("HelicopterState"); if (!m_state) { diff --git a/LEGO1/lego/legoomni/src/actors/pizza.cpp b/LEGO1/lego/legoomni/src/actors/pizza.cpp index 57ab17df..236536b0 100644 --- a/LEGO1/lego/legoomni/src/actors/pizza.cpp +++ b/LEGO1/lego/legoomni/src/actors/pizza.cpp @@ -1,17 +1,21 @@ #include "pizza.h" +#include "act1state.h" +#include "legogamestate.h" +#include "misc.h" #include "mxmisc.h" #include "mxticklemanager.h" +#include "pizzamissionstate.h" DECOMP_SIZE_ASSERT(Pizza, 0x9c) // FUNCTION: LEGO1 0x10037ef0 Pizza::Pizza() { - m_unk0x7c = 0; + m_state = NULL; m_unk0x80 = 0; m_skateboard = NULL; - m_unk0x88 = 0; + m_act1state = NULL; m_unk0x8c = -1; m_unk0x98 = 0; m_unk0x90 = 0x80000000; @@ -30,6 +34,20 @@ MxResult Pizza::Create(MxDSAction& p_dsAction) return SUCCESS; } +// FUNCTION: LEGO1 0x100381b0 +void Pizza::CreateState() +{ + m_state = (PizzaMissionState*) GameState()->GetState("PizzaMissionState"); + if (m_state == NULL) { + m_state = (PizzaMissionState*) GameState()->CreateState("PizzaMissionState"); + } + + m_act1state = (Act1State*) GameState()->GetState("Act1State"); + if (m_act1state == NULL) { + m_act1state = (Act1State*) GameState()->CreateState("Act1State"); + } +} + // STUB: LEGO1 0x100382b0 void Pizza::FUN_100382b0() { diff --git a/LEGO1/lego/legoomni/src/actors/pizzeria.cpp b/LEGO1/lego/legoomni/src/actors/pizzeria.cpp index 2346914b..2d72fd56 100644 --- a/LEGO1/lego/legoomni/src/actors/pizzeria.cpp +++ b/LEGO1/lego/legoomni/src/actors/pizzeria.cpp @@ -11,14 +11,14 @@ MxResult Pizzeria::Create(MxDSAction& p_dsAction) MxResult result = IsleActor::Create(p_dsAction); if (result == SUCCESS) { - Init(); + CreateState(); } return result; } // FUNCTION: LEGO1 0x100179f0 -void Pizzeria::Init() +void Pizzeria::CreateState() { LegoGameState* gameState = GameState(); PizzeriaState* pizzeriaState = (PizzeriaState*) gameState->GetState("PizzeriaState"); diff --git a/LEGO1/lego/legoomni/src/actors/radio.cpp b/LEGO1/lego/legoomni/src/actors/radio.cpp index a04523b1..537bf080 100644 --- a/LEGO1/lego/legoomni/src/actors/radio.cpp +++ b/LEGO1/lego/legoomni/src/actors/radio.cpp @@ -22,7 +22,7 @@ Radio::Radio() ControlManager()->Register(this); m_unk0x0c = TRUE; - CreateRadioState(); + CreateState(); } // FUNCTION: LEGO1 0x1002c990 @@ -147,12 +147,12 @@ void Radio::Initialize(MxBool p_und) { if (m_unk0x0c != p_und) { m_unk0x0c = p_und; - CreateRadioState(); + CreateState(); } } // FUNCTION: LEGO1 0x1002cde0 -void Radio::CreateRadioState() +void Radio::CreateState() { LegoGameState* gameState = GameState(); RadioState* state = (RadioState*) gameState->GetState("RadioState"); diff --git a/LEGO1/lego/legoomni/src/actors/towtrack.cpp b/LEGO1/lego/legoomni/src/actors/towtrack.cpp index 2b087966..25b939e0 100644 --- a/LEGO1/lego/legoomni/src/actors/towtrack.cpp +++ b/LEGO1/lego/legoomni/src/actors/towtrack.cpp @@ -1,19 +1,23 @@ #include "towtrack.h" +#include "legogamestate.h" +#include "misc.h" +#include "towtrackmissionstate.h" + DECOMP_SIZE_ASSERT(TowTrack, 0x180) // FUNCTION: LEGO1 0x1004c720 TowTrack::TowTrack() { - this->m_unk0x168 = 0; - this->m_unk0x16a = -1; - this->m_unk0x164 = 0; - this->m_unk0x16c = 0; - this->m_unk0x170 = -1; - this->m_unk0x16e = 0; - this->m_unk0x174 = -1; - this->m_unk0x13c = 40.0; - this->m_unk0x178 = 1.0; + m_unk0x168 = 0; + m_unk0x16a = -1; + m_state = NULL; + m_unk0x16c = 0; + m_unk0x170 = -1; + m_unk0x16e = 0; + m_unk0x174 = -1; + m_unk0x13c = 40.0; + m_unk0x178 = 1.0; } // STUB: LEGO1 0x1004c9e0 @@ -29,6 +33,15 @@ void TowTrack::VTable0x70(float p_float) // TODO } +// FUNCTION: LEGO1 0x1004cc40 +void TowTrack::CreateState() +{ + m_state = (TowTrackMissionState*) GameState()->GetState("TowTrackMissionState"); + if (m_state == NULL) { + m_state = (TowTrackMissionState*) GameState()->CreateState("TowTrackMissionState"); + } +} + // STUB: LEGO1 0x1004cc80 MxLong TowTrack::Notify(MxParam& p_param) { diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index 21aeb3dd..38e0fa5a 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -31,6 +31,7 @@ #include "mxtransitionmanager.h" #include "mxvariabletable.h" #include "pizza.h" +#include "pizzeria.h" #include "scripts.h" #include "skateboard.h" #include "towtrack.h" @@ -474,7 +475,7 @@ void Isle::Enable(MxBool p_enable) m_radio.Initialize(p_enable); if (p_enable) { - FUN_100330e0(); + CreateState(); VideoManager()->ResetPalette(FALSE); m_act1state->FUN_10034d00(); @@ -1095,10 +1096,24 @@ void Isle::VTable0x6c(LegoPathActor* p_actor) } } -// STUB: LEGO1 0x100330e0 -void Isle::FUN_100330e0() +// FUNCTION: LEGO1 0x100330e0 +void Isle::CreateState() { - // TODO + m_act1state = (Act1State*) GameState()->GetState("Act1State"); + if (!m_act1state) { + m_act1state = (Act1State*) GameState()->CreateState("Act1State"); + m_act1state->m_unk0x018 = 0; + } + + m_radio.CreateState(); + m_pizzeria->CreateState(); + m_pizza->CreateState(); + m_towtrack->CreateState(); + m_ambulance->CreateState(); + + if (m_helicopter != NULL) { + m_helicopter->CreateState(); + } } // STUB: LEGO1 0x10033180