From dede20000fbad11b57e129450b31447a77e9dbc2 Mon Sep 17 00:00:00 2001 From: jonschz <17198703+jonschz@users.noreply.github.com> Date: Sun, 28 Apr 2024 13:23:29 +0200 Subject: [PATCH] Progress towards implementing SkateBoard (#864) * Implement SkateBoard::~SkateBoard() * Implement SkateBoard::VTable0xd4 * Implement SkateBoard::Create() - one typecast is still not clear * Add SkateBoard::VTable0xe4() * apply clang-format * Apply clang-format to legocontrolmanager.h * Address review comments --------- Co-authored-by: jonschz --- LEGO1/lego/legoomni/include/pizza.h | 7 +- LEGO1/lego/legoomni/include/skateboard.h | 6 +- LEGO1/lego/legoomni/src/actors/pizza.cpp | 10 +++ LEGO1/lego/legoomni/src/actors/skateboard.cpp | 66 +++++++++++++++---- 4 files changed, 72 insertions(+), 17 deletions(-) diff --git a/LEGO1/lego/legoomni/include/pizza.h b/LEGO1/lego/legoomni/include/pizza.h index 7884334d..15e34af2 100644 --- a/LEGO1/lego/legoomni/include/pizza.h +++ b/LEGO1/lego/legoomni/include/pizza.h @@ -31,13 +31,18 @@ class Pizza : public IsleActor { undefined4 HandleEndAction(MxEndActionNotificationParam&) override; // vtable+0x74 undefined4 VTable0x80(MxParam&) override; // vtable+0x80 + void FUN_100382b0(); + void FUN_10038380(); + + inline void SetUnknown0x84(undefined* p_unk0x84) { m_unk0x84 = p_unk0x84; } + // SYNTHETIC: LEGO1 0x100380e0 // Pizza::`scalar deleting destructor' private: undefined4 m_unk0x7c; // 0x7c undefined4 m_unk0x80; // 0x80 - undefined4 m_unk0x84; // 0x84 + undefined* m_unk0x84; // 0x84 undefined4 m_unk0x88; // 0x88 undefined4 m_unk0x8c; // 0x8c undefined4 m_unk0x90; // 0x90 diff --git a/LEGO1/lego/legoomni/include/skateboard.h b/LEGO1/lego/legoomni/include/skateboard.h index b5d4fbf1..dc567b9f 100644 --- a/LEGO1/lego/legoomni/include/skateboard.h +++ b/LEGO1/lego/legoomni/include/skateboard.h @@ -9,6 +9,7 @@ class SkateBoard : public IslePathActor { public: SkateBoard(); + ~SkateBoard() override; // FUNCTION: LEGO1 0x1000fdd0 inline const char* ClassName() const override // vtable+0x0c @@ -35,9 +36,8 @@ class SkateBoard : public IslePathActor { // SkateBoard::`scalar deleting destructor' private: - // TODO: SkateBoard types - undefined m_unk0x160; - undefined m_unk0x161[0x7]; + undefined m_unk0x160; // 0x160 + undefined* m_unk0x164; // 0x164 }; #endif // SKATEBOARD_H diff --git a/LEGO1/lego/legoomni/src/actors/pizza.cpp b/LEGO1/lego/legoomni/src/actors/pizza.cpp index 6a16c580..106ea918 100644 --- a/LEGO1/lego/legoomni/src/actors/pizza.cpp +++ b/LEGO1/lego/legoomni/src/actors/pizza.cpp @@ -30,6 +30,16 @@ MxResult Pizza::Create(MxDSAction& p_dsAction) return SUCCESS; } +// STUB: LEGO1 0x100382b0 +void Pizza::FUN_100382b0() +{ +} + +// STUB: LEGO1 0x10038380 +void Pizza::FUN_10038380() +{ +} + // STUB: LEGO1 0x100383f0 undefined4 Pizza::VTable0x68() { diff --git a/LEGO1/lego/legoomni/src/actors/skateboard.cpp b/LEGO1/lego/legoomni/src/actors/skateboard.cpp index a111c7a7..93d29c00 100644 --- a/LEGO1/lego/legoomni/src/actors/skateboard.cpp +++ b/LEGO1/lego/legoomni/src/actors/skateboard.cpp @@ -1,33 +1,66 @@ #include "skateboard.h" #include "decomp.h" +#include "isle_actions.h" +#include "legoutils.h" +#include "misc.h" #include "mxmisc.h" #include "mxnotificationmanager.h" +#include "pizza.h" DECOMP_SIZE_ASSERT(SkateBoard, 0x168) // FUNCTION: LEGO1 0x1000fd40 SkateBoard::SkateBoard() { - this->m_unk0x160 = 0; - this->m_unk0x13c = 15.0; - this->m_unk0x150 = 3.5; - this->m_unk0x148 = 1; + m_unk0x160 = 0; + m_unk0x13c = 15.0; + m_unk0x150 = 3.5; + m_unk0x148 = 1; NotificationManager()->Register(this); } -// STUB: LEGO1 0x10010000 -MxResult SkateBoard::Create(MxDSAction& p_dsAction) +// FUNCTION: LEGO1 0x1000ff80 +SkateBoard::~SkateBoard() { - // TODO - return SUCCESS; + ControlManager()->Unregister(this); + NotificationManager()->Unregister(this); } -// STUB: LEGO1 0x10010050 +// FUNCTION: LEGO1 0x10010000 +MxResult SkateBoard::Create(MxDSAction& p_dsAction) +{ + MxResult result = IslePathActor::Create(p_dsAction); + + if (result == SUCCESS) { + m_world = CurrentWorld(); + m_world->Add(this); + // The type `Pizza` is an educated guesss, inferred from VTable0xe4() below + Pizza* findResult = (Pizza*) CurrentWorld()->Find(*g_isleScript, IsleScript::c_Pizza_Actor); + if (findResult) { + findResult->SetUnknown0x84((undefined*) this); + } + } + + return result; +} + +// FUNCTION: LEGO1 0x10010050 void SkateBoard::VTable0xe4() { - // TODO + // TODO: Work out what kind of structure this points to + if (*(int*) (m_unk0x164 + 0x18) == 3) { + Pizza* pizza = (Pizza*) CurrentWorld()->Find(*g_isleScript, IsleScript::c_Pizza_Actor); + pizza->FUN_10038380(); + pizza->FUN_100382b0(); + m_unk0x160 = 0; + } + IslePathActor::VTable0xe4(); + GameState()->m_currentArea = LegoGameState::Area::e_skateboard; + RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_SkateArms_Ctl); + RemoveFromCurrentWorld(*g_isleScript, IsleScript::c_SkatePizza_Bitmap); + ControlManager()->Unregister(this); } // STUB: LEGO1 0x100100e0 @@ -37,11 +70,18 @@ MxU32 SkateBoard::VTable0xcc() return 0; } -// STUB: LEGO1 0x10010230 +// FUNCTION: LEGO1 0x10010230 MxU32 SkateBoard::VTable0xd4(LegoControlManagerEvent& p_param) { - // TODO - return 0; + MxU32 result = 0; + + if (p_param.GetUnknown0x28() == 1 && p_param.GetClickedObjectId() == 0xc3) { + VTable0xe4(); + GameState()->m_currentArea = LegoGameState::Area::e_unk66; + result = 1; + } + + return result; } // STUB: LEGO1 0x100104f0