From 7bee5fc6a5cb0ea80369ecf4fee1c373690d50f9 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 1 Jul 2024 16:43:03 -0700 Subject: [PATCH] Implement/match GasStation::HandleButtonDown (#1052) * Implement/match GasStation::HandleButtonDown * Use enum --- LEGO1/lego/legoomni/include/gasstation.h | 8 ++-- LEGO1/lego/legoomni/src/worlds/gasstation.cpp | 48 +++++++++++++++++-- 2 files changed, 49 insertions(+), 7 deletions(-) diff --git a/LEGO1/lego/legoomni/include/gasstation.h b/LEGO1/lego/legoomni/include/gasstation.h index af224e79..7d4a301b 100644 --- a/LEGO1/lego/legoomni/include/gasstation.h +++ b/LEGO1/lego/legoomni/include/gasstation.h @@ -38,7 +38,8 @@ class GasStationState : public LegoState { // SYNTHETIC: LEGO1 0x10006290 // GasStationState::`scalar deleting destructor' - void FUN_10006430(undefined4); + void FUN_10006430(GarageScript::Script); + void FUN_10006460(GarageScript::Script); void FUN_10006490(); // TODO: Most likely getters/setters are not used according to BETA. @@ -82,12 +83,13 @@ class GasStation : public LegoWorld { void Enable(MxBool p_enable) override; // vtable+0x68 virtual MxLong HandleControl(LegoControlManagerNotificationParam& p_param); // vtable+0x6c - inline void PlayAction(MxU32 p_objectId); - // SYNTHETIC: LEGO1 0x100048a0 // GasStation::`scalar deleting destructor' private: + inline void PlayAction(GarageScript::Script p_objectId); + inline void StopAction(GarageScript::Script p_objectId); + MxLong HandleEndAction(MxEndActionNotificationParam& p_param); MxLong HandleKeyPress(MxS8 p_key); MxLong HandleButtonDown(LegoControlManagerNotificationParam& p_param); diff --git a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp index a2bcb82c..fb809668 100644 --- a/LEGO1/lego/legoomni/src/worlds/gasstation.cpp +++ b/LEGO1/lego/legoomni/src/worlds/gasstation.cpp @@ -8,6 +8,7 @@ #include "legogamestate.h" #include "legoinputmanager.h" #include "legomain.h" +#include "legoutils.h" #include "misc.h" #include "mxbackgroundaudiomanager.h" #include "mxmisc.h" @@ -276,7 +277,8 @@ void GasStation::ReadyWorld() } // FUNCTION: LEGO1 0x10005590 -inline void GasStation::PlayAction(MxU32 p_objectId) +// FUNCTION: BETA10 0x10029e30 +inline void GasStation::PlayAction(GarageScript::Script p_objectId) { MxDSAction action; action.SetAtomId(*g_garageScript); @@ -287,6 +289,16 @@ inline void GasStation::PlayAction(MxU32 p_objectId) m_state->FUN_10006430(p_objectId); } +// FUNCTION: BETA10 0x10029f00 +inline void GasStation::StopAction(GarageScript::Script p_objectId) +{ + if (p_objectId != GarageScript::c_noneGarage) { + InvokeAction(Extra::e_stop, *g_garageScript, p_objectId, NULL); + BackgroundAudioManager()->RaiseVolume(); + m_state->FUN_10006460(p_objectId); + } +} + // STUB: LEGO1 0x10005660 MxLong GasStation::HandleEndAction(MxEndActionNotificationParam& p_param) { @@ -305,10 +317,32 @@ MxLong GasStation::HandleKeyPress(MxS8 p_key) return 0; } -// STUB: LEGO1 0x10005960 +// FUNCTION: LEGO1 0x10005960 +// FUNCTION: BETA10 0x10029319 MxLong GasStation::HandleButtonDown(LegoControlManagerNotificationParam& p_param) { - // TODO + if (m_unk0x104 == 1 || m_unk0x104 == 2) { + LegoROI* roi = PickROI(p_param.GetX(), p_param.GetY()); + + if (roi != NULL) { + if (!strnicmp(roi->GetName(), "capdb", 5) || !strnicmp(roi->GetName(), "*capdb", 6)) { + m_unk0x104 = 3; + m_unk0x114 = FALSE; + + if (m_state->m_unk0x14.m_unk0x00 == 7) { + m_state->m_unk0x14.m_unk0x00 = 8; + PlayAction(GarageScript::c_wgs029nu_RunAnim); + m_unk0x106 = 1; + } + else { + StopAction(GarageScript::c_wgs023nu_RunAnim); + } + + return 1; + } + } + } + return 0; } @@ -459,7 +493,13 @@ MxResult GasStationState::Serialize(LegoFile* p_file) } // STUB: LEGO1 0x10006430 -void GasStationState::FUN_10006430(undefined4) +void GasStationState::FUN_10006430(GarageScript::Script) +{ + // TODO +} + +// STUB: LEGO1 0x10006460 +void GasStationState::FUN_10006460(GarageScript::Script) { // TODO }