From 52d74647bef329fdc47cefce7f8b8900918c854a Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Mon, 18 Mar 2024 15:00:58 -0400 Subject: [PATCH] Implement/match Isle::HandleEndAction and Isle::HandleElevatorEndAction (#691) * WIP * Match --- LEGO1/lego/legoomni/include/act1state.h | 2 +- LEGO1/lego/legoomni/include/isle.h | 3 +- LEGO1/lego/legoomni/include/jukeboxentity.h | 11 ++- LEGO1/lego/legoomni/include/legogamestate.h | 21 +++-- LEGO1/lego/legoomni/src/act1/act1state.cpp | 2 +- .../legoomni/src/actors/jukeboxentity.cpp | 54 +++++------ .../src/audio/mxbackgroundaudiomanager.cpp | 2 +- .../legoomni/src/common/legogamestate.cpp | 3 +- LEGO1/lego/legoomni/src/worlds/isle.cpp | 91 ++++++++++++++++++- LEGO1/omni/include/mxomni.h | 2 +- LEGO1/omni/src/main/mxomni.cpp | 4 +- 11 files changed, 149 insertions(+), 46 deletions(-) diff --git a/LEGO1/lego/legoomni/include/act1state.h b/LEGO1/lego/legoomni/include/act1state.h index c12e49c0..20b8d44b 100644 --- a/LEGO1/lego/legoomni/include/act1state.h +++ b/LEGO1/lego/legoomni/include/act1state.h @@ -101,7 +101,7 @@ class Act1State : public LegoState { MxS32 m_unk0x014; // 0x014 MxU32 m_unk0x018; // 0x018 MxS16 m_elevFloor; // 0x01c - undefined m_unk0x01e; // 0x01e + MxBool m_unk0x01e; // 0x01e MxBool m_unk0x01f; // 0x01f MxBool m_planeActive; // 0x020 undefined m_unk0x021; // 0x021 diff --git a/LEGO1/lego/legoomni/include/isle.h b/LEGO1/lego/legoomni/include/isle.h index 31d60b2d..7ded407f 100644 --- a/LEGO1/lego/legoomni/include/isle.h +++ b/LEGO1/lego/legoomni/include/isle.h @@ -78,10 +78,11 @@ class Isle : public LegoWorld { void Enable(MxBool p_enable) override; // vtable+68 virtual void VTable0x6c(IslePathActor* p_actor); // vtable+6c - MxLong StopAction(MxParam& p_param); + MxLong HandleEndAction(MxEndActionNotificationParam& p_param); MxLong HandleClick(LegoControlManagerEvent& p_param); MxLong HandleType19Notification(MxParam& p_param); MxLong HandleTransitionEnd(); + void HandleElevatorEndAction(); void FUN_10031590(); void FUN_10032620(); void FUN_100330e0(); diff --git a/LEGO1/lego/legoomni/include/jukeboxentity.h b/LEGO1/lego/legoomni/include/jukeboxentity.h index feb02ee3..f992ea37 100644 --- a/LEGO1/lego/legoomni/include/jukeboxentity.h +++ b/LEGO1/lego/legoomni/include/jukeboxentity.h @@ -3,6 +3,15 @@ #include "legoentity.h" +namespace JukeboxScript +{ +#ifdef COMPAT_MODE +enum Script : int; +#else +enum Script; +#endif +} // namespace JukeboxScript + // VTABLE: LEGO1 0x100da8a0 // SIZE 0x6c class JukeBoxEntity : public LegoEntity { @@ -26,7 +35,7 @@ class JukeBoxEntity : public LegoEntity { } void StartAction(); - void StopAction(MxU32 p_state); + void StopAction(JukeboxScript::Script p_script); inline MxBool IsBackgroundAudioEnabled() { return m_audioEnabled; } diff --git a/LEGO1/lego/legoomni/include/legogamestate.h b/LEGO1/lego/legoomni/include/legogamestate.h index 0fafb95a..1048bdb7 100644 --- a/LEGO1/lego/legoomni/include/legogamestate.h +++ b/LEGO1/lego/legoomni/include/legogamestate.h @@ -17,6 +17,15 @@ struct ColorStringStruct { const char* m_colorName; }; +namespace JukeboxScript +{ +#ifdef COMPAT_MODE +enum Script : int; +#else +enum Script; +#endif +} // namespace JukeboxScript + // SIZE 0x430 class LegoGameState { public: @@ -159,7 +168,7 @@ class LegoGameState { inline Act GetLoadedAct() { return m_loadedAct; } inline Area GetCurrentArea() { return m_currentArea; } inline Area GetPreviousArea() { return m_previousArea; } - inline MxU32 GetUnknown0x41c() { return m_unk0x41c; } + inline JukeboxScript::Script GetUnknown0x41c() { return m_unk0x41c; } inline Area GetUnknown0x42c() { return m_unk0x42c; } inline History* GetHistory() { return &m_history; } @@ -167,7 +176,7 @@ class LegoGameState { inline void SetCurrentArea(Area p_currentArea) { m_currentArea = p_currentArea; } inline void SetPreviousArea(Area p_previousArea) { m_previousArea = p_previousArea; } inline void SetActorId(MxU8 p_actorId) { m_actorId = p_actorId; } - inline void SetUnknown0x41c(undefined4 p_unk0x41c) { m_unk0x41c = p_unk0x41c; } + inline void SetUnknown0x41c(JukeboxScript::Script p_unk0x41c) { m_unk0x41c = p_unk0x41c; } inline void SetUnknown0x42c(Area p_unk0x42c) { m_unk0x42c = p_unk0x42c; } inline Username* GetPlayersIndex(MxS32 p_index) { return &m_players[p_index]; } inline MxS16 GetPlayerCount() { return m_playerCount; } @@ -202,10 +211,10 @@ class LegoGameState { Username m_players[9]; // 0x28 private: - History m_history; // 0xa6 - undefined2 m_unk0x41a; // 0x41a - undefined4 m_unk0x41c; // 0x41c - MxBool m_isDirty; // 0x420 + History m_history; // 0xa6 + undefined2 m_unk0x41a; // 0x41a + JukeboxScript::Script m_unk0x41c; // 0x41c + MxBool m_isDirty; // 0x420 public: Area m_currentArea; // 0x424 diff --git a/LEGO1/lego/legoomni/src/act1/act1state.cpp b/LEGO1/lego/legoomni/src/act1/act1state.cpp index 99ddb8f5..71bd7039 100644 --- a/LEGO1/lego/legoomni/src/act1/act1state.cpp +++ b/LEGO1/lego/legoomni/src/act1/act1state.cpp @@ -17,7 +17,7 @@ extern MxAtomId* g_isleScript; // STUB: LEGO1 0x100334b0 Act1State::Act1State() : m_unk0x00c(0), m_unk0x00e(0), m_unk0x008(NULL), m_unk0x010(0) { - m_unk0x01e = 0; + m_unk0x01e = FALSE; m_unk0x018 = 1; m_unk0x010 = 0; m_planeActive = FALSE; diff --git a/LEGO1/lego/legoomni/src/actors/jukeboxentity.cpp b/LEGO1/lego/legoomni/src/actors/jukeboxentity.cpp index 7104b6f4..7e7a708b 100644 --- a/LEGO1/lego/legoomni/src/actors/jukeboxentity.cpp +++ b/LEGO1/lego/legoomni/src/actors/jukeboxentity.cpp @@ -1,7 +1,9 @@ #include "jukeboxentity.h" #include "isle.h" +#include "isle_actions.h" #include "islepathactor.h" +#include "jukebox_actions.h" #include "jukeboxstate.h" #include "legogamestate.h" #include "legoomni.h" @@ -54,28 +56,28 @@ void JukeBoxEntity::StartAction() switch (state->GetState()) { case 0: - InvokeAction(Extra::e_start, *g_isleScript, 0x319, NULL); - GameState()->SetUnknown0x41c(0x37); + InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz001bd_RunAnim, NULL); + GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic1); break; case 1: - InvokeAction(Extra::e_start, *g_isleScript, 0x31e, NULL); - GameState()->SetUnknown0x41c(0x38); + InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz006bd_RunAnim, NULL); + GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic2); break; case 2: - InvokeAction(Extra::e_start, *g_isleScript, 0x31b, NULL); - GameState()->SetUnknown0x41c(0x39); + InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz003bd_RunAnim, NULL); + GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic3); break; case 3: - InvokeAction(Extra::e_start, *g_isleScript, 0x31a, NULL); - GameState()->SetUnknown0x41c(0x3a); + InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz002bd_RunAnim, NULL); + GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic4); break; case 4: - InvokeAction(Extra::e_start, *g_isleScript, 0x31f, NULL); - GameState()->SetUnknown0x41c(0x3b); + InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz007bd_RunAnim, NULL); + GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic5); break; case 5: - InvokeAction(Extra::e_start, *g_isleScript, 0x31c, NULL); - GameState()->SetUnknown0x41c(0x3c); + InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_npz004bd_RunAnim, NULL); + GameState()->SetUnknown0x41c(JukeboxScript::c_JBMusic6); break; } @@ -91,35 +93,35 @@ void JukeBoxEntity::StartAction() } // FUNCTION: LEGO1 0x100860f0 -void JukeBoxEntity::StopAction(MxU32 p_state) +void JukeBoxEntity::StopAction(JukeboxScript::Script p_script) { JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState"); if (state && state->IsActive()) { - switch (p_state) { - case 0x37: + switch (p_script) { + case JukeboxScript::c_JBMusic1: state->SetActive(FALSE); - InvokeAction(Extra::e_stop, *g_isleScript, 0x319, NULL); + InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz001bd_RunAnim, NULL); break; - case 0x38: + case JukeboxScript::c_JBMusic2: state->SetActive(FALSE); - InvokeAction(Extra::e_stop, *g_isleScript, 0x31e, NULL); + InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz006bd_RunAnim, NULL); break; - case 0x39: + case JukeboxScript::c_JBMusic3: state->SetActive(FALSE); - InvokeAction(Extra::e_stop, *g_isleScript, 0x31b, NULL); + InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz003bd_RunAnim, NULL); break; - case 0x3a: + case JukeboxScript::c_JBMusic4: state->SetActive(FALSE); - InvokeAction(Extra::e_stop, *g_isleScript, 0x31a, NULL); + InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz002bd_RunAnim, NULL); break; - case 0x3b: + case JukeboxScript::c_JBMusic5: state->SetActive(FALSE); - InvokeAction(Extra::e_stop, *g_isleScript, 0x31f, NULL); + InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz007bd_RunAnim, NULL); break; - case 0x3c: + case JukeboxScript::c_JBMusic6: state->SetActive(FALSE); - InvokeAction(Extra::e_stop, *g_isleScript, 0x31c, NULL); + InvokeAction(Extra::e_stop, *g_isleScript, IsleScript::c_npz004bd_RunAnim, NULL); break; } diff --git a/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp b/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp index a5acbc8d..4a3a0eda 100644 --- a/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp +++ b/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp @@ -232,7 +232,7 @@ void MxBackgroundAudioManager::StopAction(MxParam& p_param) m_action2.SetObjectId(-1); } - Lego()->HandleActionEnd(p_param); + Lego()->HandleEndAction(p_param); } // FUNCTION: LEGO1 0x1007f2f0 diff --git a/LEGO1/lego/legoomni/src/common/legogamestate.cpp b/LEGO1/lego/legoomni/src/common/legogamestate.cpp index 5acfce1b..442dd32a 100644 --- a/LEGO1/lego/legoomni/src/common/legogamestate.cpp +++ b/LEGO1/lego/legoomni/src/common/legogamestate.cpp @@ -8,6 +8,7 @@ #include "isle.h" #include "islepathactor.h" #include "jetski.h" +#include "jukebox_actions.h" #include "legoanimationmanager.h" #include "legobuildingmanager.h" #include "legocharactermanager.h" @@ -93,7 +94,7 @@ LegoGameState::LegoGameState() m_actorId = 0; m_savePath = NULL; m_stateArray = NULL; - m_unk0x41c = -1; + m_unk0x41c = JukeboxScript::c_noneJukebox; m_currentArea = e_undefined; m_previousArea = e_undefined; m_unk0x42c = e_undefined; diff --git a/LEGO1/lego/legoomni/src/worlds/isle.cpp b/LEGO1/lego/legoomni/src/worlds/isle.cpp index 727b5f4c..c3d8a6ad 100644 --- a/LEGO1/lego/legoomni/src/worlds/isle.cpp +++ b/LEGO1/lego/legoomni/src/worlds/isle.cpp @@ -21,6 +21,7 @@ #include "legovideomanager.h" #include "misc.h" #include "motocycle.h" +#include "mxbackgroundaudiomanager.h" #include "mxmisc.h" #include "mxnotificationmanager.h" #include "mxstillpresenter.h" @@ -123,7 +124,7 @@ MxLong Isle::Notify(MxParam& p_param) if (m_worldStarted) { switch (((MxNotificationParam&) p_param).GetNotification()) { case c_notificationEndAction: - result = StopAction(p_param); + result = HandleEndAction((MxEndActionNotificationParam&) p_param); break; case c_notificationButtonUp: case c_notificationButtonDown: @@ -167,10 +168,90 @@ MxLong Isle::Notify(MxParam& p_param) return result; } -// STUB: LEGO1 0x10030d90 -MxLong Isle::StopAction(MxParam& p_param) +// FUNCTION: LEGO1 0x10030d90 +MxLong Isle::HandleEndAction(MxEndActionNotificationParam& p_param) { - return 0; + MxLong result; + + switch (m_act1state->m_unk0x018) { + case 2: + HandleElevatorEndAction(); + result = 1; + break; + case 3: + result = m_pizza->Notify(p_param); + break; + case 8: + result = m_towtrack->Notify(p_param); + break; + case 10: + result = m_ambulance->Notify(p_param); + break; + default: + result = m_radio.Notify(p_param); + + if (result == 0) { + MxDSAction* action = p_param.GetAction(); + + // TODO: Should be signed, but worsens match + MxU32 script; + + if (action->GetAtomId() == *g_jukeboxScript) { + script = action->GetObjectId(); + + if (script >= JukeboxScript::c_JBMusic1 && script <= JukeboxScript::c_JBMusic6) { + m_jukebox->StopAction((JukeboxScript::Script) script); + result = 1; + } + } + else if (m_act1state->m_planeActive) { + script = action->GetObjectId(); + + if (script >= IsleScript::c_nic002pr_RunAnim && script <= IsleScript::c_nic004pr_RunAnim) { + m_act1state->m_planeActive = FALSE; + } + } + else { + script = action->GetObjectId(); + + if (script == IsleScript::c_Avo917In_PlayWav || + (script >= IsleScript::c_Avo900Ps_PlayWav && script <= IsleScript::c_Avo907Ps_PlayWav)) { + BackgroundAudioManager()->RaiseVolume(); + } + } + } + } + + return result; +} + +// FUNCTION: LEGO1 0x10030ef0 +void Isle::HandleElevatorEndAction() +{ + switch (m_act1state->m_elevFloor) { + case Act1State::c_floor1: + m_destLocation = LegoGameState::e_infomain; + TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); + m_act1state->m_unk0x018 = 0; + break; + case Act1State::c_floor2: + if (m_act1state->m_unk0x01e) { + m_act1state->m_unk0x01e = FALSE; + m_act1state->m_unk0x018 = 0; + InputManager()->EnableInputProcessing(); + } + else { + InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Floor2, NULL); + InputManager()->EnableInputProcessing(); + m_act1state->m_unk0x01e = TRUE; + } + break; + case Act1State::c_floor3: + m_destLocation = LegoGameState::e_elevopen; + TransitionManager()->StartTransition(MxTransitionManager::e_mosaic, 50, FALSE, FALSE); + m_act1state->m_unk0x018 = 0; + break; + } } // FUNCTION: LEGO1 0x10030fc0 @@ -228,7 +309,7 @@ MxLong Isle::HandleClick(LegoControlManagerEvent& p_param) break; case Act1State::c_floor2: InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Floor2, NULL); - m_act1state->m_unk0x01e = 1; + m_act1state->m_unk0x01e = TRUE; break; case Act1State::c_floor3: InvokeAction(Extra::e_start, *g_isleScript, IsleScript::c_Elev3_2_Ride, NULL); diff --git a/LEGO1/omni/include/mxomni.h b/LEGO1/omni/include/mxomni.h index 26bb4dfc..5aca3e23 100644 --- a/LEGO1/omni/include/mxomni.h +++ b/LEGO1/omni/include/mxomni.h @@ -70,7 +70,7 @@ class MxOmni : public MxCore { MxMusicManager* GetMusicManager() const { return this->m_musicManager; } MxEventManager* GetEventManager() const { return this->m_eventManager; } MxAtomIdCounterSet* GetAtomIdCounterSet() const { return this->m_atomIdCounterSet; } - MxLong HandleActionEnd(MxParam& p_param); + MxLong HandleEndAction(MxParam& p_param); // SYNTHETIC: LEGO1 0x100aefd0 // MxOmni::`scalar deleting destructor' diff --git a/LEGO1/omni/src/main/mxomni.cpp b/LEGO1/omni/src/main/mxomni.cpp index 70bb751c..052099b1 100644 --- a/LEGO1/omni/src/main/mxomni.cpp +++ b/LEGO1/omni/src/main/mxomni.cpp @@ -344,11 +344,11 @@ MxLong MxOmni::Notify(MxParam& p_param) return 0; } - return HandleActionEnd(p_param); + return HandleEndAction(p_param); } // FUNCTION: LEGO1 0x100b0880 -MxLong MxOmni::HandleActionEnd(MxParam& p_param) +MxLong MxOmni::HandleEndAction(MxParam& p_param) { MxDSAction* action = ((MxEndActionNotificationParam&) p_param).GetAction(); MxStreamController* controller = Streamer()->GetOpenStream(action->GetAtomId().GetInternal());