From 564fb7f7c0766e4734461d273d97a9693a14468d Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Sun, 8 Dec 2024 11:39:03 -0700 Subject: [PATCH] Implement/match `Act3::Enable` (#1198) * Implement Act3::Enable * Match * Change back to private * Remove unused function --- LEGO1/lego/legoomni/include/act3.h | 2 +- LEGO1/lego/legoomni/include/act3actors.h | 4 + LEGO1/lego/legoomni/include/act3ammo.h | 13 ++- LEGO1/lego/legoomni/include/act3brickster.h | 15 +++- LEGO1/lego/legoomni/include/act3cop.h | 7 +- LEGO1/lego/legoomni/include/act3shark.h | 6 +- LEGO1/lego/legoomni/include/helicopter.h | 4 +- LEGO1/lego/legoomni/include/legopathactor.h | 4 + LEGO1/lego/legoomni/src/actors/act3ammo.cpp | 2 +- LEGO1/lego/legoomni/src/worlds/act3.cpp | 87 ++++++++++++++++++++- 10 files changed, 132 insertions(+), 12 deletions(-) diff --git a/LEGO1/lego/legoomni/include/act3.h b/LEGO1/lego/legoomni/include/act3.h index d158950a..b44c1d59 100644 --- a/LEGO1/lego/legoomni/include/act3.h +++ b/LEGO1/lego/legoomni/include/act3.h @@ -117,7 +117,7 @@ class Act3 : public LegoWorld { Act3Brickster* m_brickster; // 0x4208 Helicopter* m_copter; // 0x420c Act3Shark* m_shark; // 0x4210 - MxFloat m_unk0x4214; // 0x4214 + MxFloat m_time; // 0x4214 undefined4 m_unk0x4218; // 0x4218 undefined m_unk0x421c; // 0x421c undefined m_unk0x421d; // 0x421d diff --git a/LEGO1/lego/legoomni/include/act3actors.h b/LEGO1/lego/legoomni/include/act3actors.h index 9b1d941d..c43cffda 100644 --- a/LEGO1/lego/legoomni/include/act3actors.h +++ b/LEGO1/lego/legoomni/include/act3actors.h @@ -23,6 +23,10 @@ class Act3Actor : public LegoAnimActor { MxU32 VTable0x90(float p_time, Matrix4& p_transform) override; // vtable+0x90 MxResult VTable0x94(LegoPathActor* p_actor, MxBool p_bool) override; // vtable+0x94 + MxFloat GetUnknown0x1c() { return m_unk0x1c; } + + void SetUnknown0x1c(MxFloat p_unk0x1c) { m_unk0x1c = p_unk0x1c; } + // SYNTHETIC: LEGO1 0x10043330 // Act3Actor::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/act3ammo.h b/LEGO1/lego/legoomni/include/act3ammo.h index 3a3db5f4..d7a65068 100644 --- a/LEGO1/lego/legoomni/include/act3ammo.h +++ b/LEGO1/lego/legoomni/include/act3ammo.h @@ -8,18 +8,27 @@ // SIZE 0x1a0 class Act3Ammo : public LegoPathActor { public: + enum { + c_bit4 = 0x04 + }; + Act3Ammo(); ~Act3Ammo() override; void Destroy(MxBool p_fromDestructor) override; // vtable+0x1c void VTable0x70(float p_time) override; // vtable+0x70 + MxU16 GetFlags() { return m_flags; } + MxFloat GetUnknown0x158() { return m_unk0x158; } + + void SetUnknown0x158(MxFloat p_unk0x158) { m_unk0x158 = p_unk0x158; } + // SYNTHETIC: LEGO1 0x10053880 // Act3Ammo::`scalar deleting destructor' private: - undefined2 m_unk0x154; // 0x154 - undefined4 m_unk0x158; // 0x158 + MxU16 m_flags; // 0x154 + MxFloat m_unk0x158; // 0x158 undefined4 m_unk0x15c; // 0x15c Mx3DPointFloat m_unk0x160[3]; // 0x160 undefined4 m_unk0x19c; // 0x19c diff --git a/LEGO1/lego/legoomni/include/act3brickster.h b/LEGO1/lego/legoomni/include/act3brickster.h index 815ba51d..1e418abf 100644 --- a/LEGO1/lego/legoomni/include/act3brickster.h +++ b/LEGO1/lego/legoomni/include/act3brickster.h @@ -21,11 +21,24 @@ class Act3Brickster : public Act3Actor { ) override; // vtable+0x98 MxResult VTable0x9c() override; // vtable+0x9c + MxFloat GetUnknown0x20() { return m_unk0x20; } + MxFloat GetUnknown0x24() { return m_unk0x24; } + MxFloat GetUnknown0x50() { return m_unk0x50; } + + void SetUnknown0x20(MxFloat p_unk0x20) { m_unk0x20 = p_unk0x20; } + void SetUnknown0x24(MxFloat p_unk0x24) { m_unk0x24 = p_unk0x24; } + void SetUnknown0x50(MxFloat p_unk0x50) { m_unk0x50 = p_unk0x50; } + // SYNTHETIC: LEGO1 0x10043250 // Act3Brickster::`scalar deleting destructor' private: - undefined4 m_unk0x20[15]; // 0x20 + MxFloat m_unk0x20; // 0x20 + MxFloat m_unk0x24; // 0x24 + undefined4 m_unk0x28[10]; // 0x28 + MxFloat m_unk0x50; // 0x50 + undefined4 m_unk0x54; // 0x54 + undefined4 m_unk0x58; // 0x58 }; #endif // ACT3BRICKSTER_H diff --git a/LEGO1/lego/legoomni/include/act3cop.h b/LEGO1/lego/legoomni/include/act3cop.h index 91d3a461..57c1459a 100644 --- a/LEGO1/lego/legoomni/include/act3cop.h +++ b/LEGO1/lego/legoomni/include/act3cop.h @@ -15,11 +15,16 @@ class Act3Cop : public Act3Actor { MxResult VTable0x94(LegoPathActor*, MxBool) override; // vtable+0x94 MxResult VTable0x9c() override; // vtable+0x9c + MxFloat GetUnknown0x20() { return m_unk0x20; } + + void SetUnknown0x20(MxFloat p_unk0x20) { m_unk0x20 = p_unk0x20; } + // SYNTHETIC: LEGO1 0x10043120 // Act3Cop::`scalar deleting destructor' private: - undefined4 m_unk0x20[4]; // 0x20 + MxFloat m_unk0x20; // 0x20 + undefined4 m_unk0x24[3]; // 0x24 }; #endif // ACT3COP_H diff --git a/LEGO1/lego/legoomni/include/act3shark.h b/LEGO1/lego/legoomni/include/act3shark.h index 06ac9da5..f43f76bd 100644 --- a/LEGO1/lego/legoomni/include/act3shark.h +++ b/LEGO1/lego/legoomni/include/act3shark.h @@ -23,13 +23,17 @@ class Act3Shark : public LegoAnimActor { // LegoAnimActor vtable virtual MxResult FUN_10042ce0(void*); // vtable+0x10 + MxFloat GetUnknown0x2c() { return m_unk0x2c; } + + void SetUnknown0x2c(MxFloat p_unk0x2c) { m_unk0x2c = p_unk0x2c; } + // SYNTHETIC: LEGO1 0x10043030 // Act3Shark::`scalar deleting destructor' private: list m_unk0x1c; // 0x1c undefined4 m_unk0x28; // 0x28 - undefined4 m_unk0x2c; // 0x2c + MxFloat m_unk0x2c; // 0x2c undefined m_unk0x30[0x0c]; // 0x30 Mx3DPointFloat m_unk0x3c; // 0x3c }; diff --git a/LEGO1/lego/legoomni/include/helicopter.h b/LEGO1/lego/legoomni/include/helicopter.h index 9faaff8b..a7be42bc 100644 --- a/LEGO1/lego/legoomni/include/helicopter.h +++ b/LEGO1/lego/legoomni/include/helicopter.h @@ -73,11 +73,11 @@ class Helicopter : public IslePathActor { MxLong HandleEndAnim(LegoEndAnimNotificationParam& p_param) override; // vtable+0xd8 void Exit() override; // vtable+0xe4 + void CreateState(); + // SYNTHETIC: LEGO1 0x10003210 // Helicopter::`scalar deleting destructor' - void CreateState(); - protected: MxMatrix m_unk0x160; // 0x160 MxMatrix m_unk0x1a8; // 0x1a8 diff --git a/LEGO1/lego/legoomni/include/legopathactor.h b/LEGO1/lego/legoomni/include/legopathactor.h index 0fe7a3df..3de87194 100644 --- a/LEGO1/lego/legoomni/include/legopathactor.h +++ b/LEGO1/lego/legoomni/include/legopathactor.h @@ -137,6 +137,8 @@ class LegoPathActor : public LegoActor { LegoPathController* GetController() { return m_controller; } MxBool GetCollideBox() { return m_collideBox; } + MxFloat GetLastTime() { return m_lastTime; } + MxFloat GetActorTime() { return m_actorTime; } void SetBoundary(LegoPathBoundary* p_boundary) { m_boundary = p_boundary; } @@ -144,6 +146,8 @@ class LegoPathActor : public LegoActor { void SetState(MxU32 p_state) { m_state = p_state; } void SetController(LegoPathController* p_controller) { m_controller = p_controller; } + void SetLastTime(MxFloat p_lastTime) { m_lastTime = p_lastTime; } + void SetActorTime(MxFloat p_actorTime) { m_actorTime = p_actorTime; } void UpdatePlane(LegoNamedPlane& p_namedPlane); void PlaceActor(LegoNamedPlane& p_namedPlane); diff --git a/LEGO1/lego/legoomni/src/actors/act3ammo.cpp b/LEGO1/lego/legoomni/src/actors/act3ammo.cpp index a3700e03..0ae3eb1d 100644 --- a/LEGO1/lego/legoomni/src/actors/act3ammo.cpp +++ b/LEGO1/lego/legoomni/src/actors/act3ammo.cpp @@ -12,7 +12,7 @@ DECOMP_SIZE_ASSERT(Act3Ammo, 0x1a0) // FUNCTION: BETA10 0x1001d648 Act3Ammo::Act3Ammo() { - m_unk0x154 = 0; + m_flags = 0; m_unk0x15c = 0; } diff --git a/LEGO1/lego/legoomni/src/worlds/act3.cpp b/LEGO1/lego/legoomni/src/worlds/act3.cpp index 5b384052..a7b568dc 100644 --- a/LEGO1/lego/legoomni/src/worlds/act3.cpp +++ b/LEGO1/lego/legoomni/src/worlds/act3.cpp @@ -2,19 +2,25 @@ #include "3dmanager/lego3dmanager.h" #include "act3_actions.h" +#include "act3brickster.h" +#include "act3cop.h" +#include "act3shark.h" #include "helicopter.h" +#include "jukebox_actions.h" #include "legoanimationmanager.h" #include "legobuildingmanager.h" #include "legocontrolmanager.h" #include "legomain.h" #include "legonavcontroller.h" #include "legoplantmanager.h" +#include "legoutils.h" #include "legovideomanager.h" #include "misc.h" #include "mxbackgroundaudiomanager.h" #include "mxmisc.h" #include "mxnotificationmanager.h" #include "mxticklemanager.h" +#include "mxtimer.h" #include "mxtransitionmanager.h" DECOMP_SIZE_ASSERT(Act3, 0x4274) @@ -37,7 +43,7 @@ Act3::Act3() m_brickster = NULL; m_copter = NULL; m_shark = NULL; - m_unk0x4214 = -1; + m_time = -1; m_unk0x421e = 0; memset(m_unk0x4230, 0, sizeof(m_unk0x4230)); @@ -204,10 +210,85 @@ void Act3::FUN_10073430() TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); } -// STUB: LEGO1 0x10073a90 +// FUNCTION: LEGO1 0x10073a90 void Act3::Enable(MxBool p_enable) { - // TODO + if ((MxBool) m_set0xd0.empty() == p_enable) { + return; + } + + LegoWorld::Enable(p_enable); + + if (p_enable) { + if (GameState()->m_previousArea == LegoGameState::e_infomain) { + GameState()->StopArea(LegoGameState::e_infomain); + } + + FUN_10015820(FALSE, LegoOmni::c_disableInput | LegoOmni::c_disable3d | LegoOmni::c_clearScreen); + PlayMusic(JukeboxScript::c_Act3Music); + GameState()->SetDirty(TRUE); + + if (m_time > 0) { + MxFloat delta = Timer()->GetTime() - m_time - 100.0f; + m_time = -1.0f; + + m_cop1->SetLastTime(m_cop1->GetLastTime() + delta); + m_cop1->SetActorTime(m_cop1->GetActorTime() + delta); + m_cop1->SetUnknown0x20(m_cop1->GetUnknown0x20() + delta); + m_cop1->SetUnknown0x1c(m_cop1->GetUnknown0x1c() + delta); + + m_cop2->SetLastTime(m_cop2->GetLastTime() + delta); + m_cop2->SetActorTime(m_cop2->GetActorTime() + delta); + m_cop2->SetUnknown0x20(m_cop2->GetUnknown0x20() + delta); + m_cop2->SetUnknown0x1c(m_cop2->GetUnknown0x1c() + delta); + + m_brickster->SetLastTime(m_brickster->GetLastTime() + delta); + m_brickster->SetActorTime(m_brickster->GetActorTime() + delta); + m_brickster->SetUnknown0x20(m_brickster->GetUnknown0x20() + delta); + m_brickster->SetUnknown0x24(m_brickster->GetUnknown0x24() + delta); + m_brickster->SetUnknown0x50(m_brickster->GetUnknown0x50() + delta); + m_brickster->SetUnknown0x1c(m_brickster->GetUnknown0x1c() + delta); + + m_copter->SetLastTime(m_copter->GetLastTime() + delta); + m_copter->SetActorTime(m_copter->GetActorTime() + delta); + + m_shark->SetLastTime(m_shark->GetLastTime() + delta); + m_shark->SetActorTime(m_shark->GetActorTime() + delta); + m_shark->SetUnknown0x2c(m_shark->GetUnknown0x2c() + delta); + + MxS32 i; + for (i = 0; i < (MxS32) sizeOfArray(m_pizzas); i++) { + if (m_pizzas[i].GetFlags() & Act3Ammo::c_bit4) { + m_pizzas[i].SetLastTime(m_pizzas[i].GetLastTime() + delta); + m_pizzas[i].SetActorTime(m_pizzas[i].GetActorTime() + delta); + m_pizzas[i].SetUnknown0x158(m_pizzas[i].GetUnknown0x158() + delta); + } + } + + for (i = 0; i < (MxS32) sizeOfArray(m_donuts); i++) { + if (m_donuts[i].GetFlags() & Act3Ammo::c_bit4) { + m_donuts[i].SetLastTime(m_donuts[i].GetLastTime() + delta); + m_donuts[i].SetActorTime(m_donuts[i].GetActorTime() + delta); + m_donuts[i].SetUnknown0x158(m_donuts[i].GetUnknown0x158() + delta); + } + } + + PlaceActor(m_copter); + m_copter->GetBoundary()->AddActor(m_copter); + + InputManager()->SetWorld(this); + InputManager()->Register(this); + SetUserActor(m_copter); + m_copter->VTable0xa8(); + SetAppCursor(e_cursorArrow); + } + } + else { + SetUserActor(NULL); + BackgroundAudioManager()->Stop(); + m_time = Timer()->GetTime(); + TickleManager()->UnregisterClient(this); + } } // FUNCTION: LEGO1 0x10073e40