From f43f7b105061a96119393663550351c5751b2c17 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Wed, 14 Feb 2024 11:36:13 -0500 Subject: [PATCH] Style/naming --- LEGO1/lego/legoomni/include/jukeboxentity.h | 4 +- LEGO1/lego/legoomni/include/jukeboxstate.h | 6 +-- .../include/mxbackgroundaudiomanager.h | 4 +- .../src/audio/mxbackgroundaudiomanager.cpp | 16 +++++--- .../lego/legoomni/src/isle/jukeboxentity.cpp | 37 ++++++++++++------- LEGO1/lego/legoomni/src/isle/radio.cpp | 2 +- 6 files changed, 41 insertions(+), 28 deletions(-) diff --git a/LEGO1/lego/legoomni/include/jukeboxentity.h b/LEGO1/lego/legoomni/include/jukeboxentity.h index bdc2e618..feb02ee3 100644 --- a/LEGO1/lego/legoomni/include/jukeboxentity.h +++ b/LEGO1/lego/legoomni/include/jukeboxentity.h @@ -28,13 +28,13 @@ class JukeBoxEntity : public LegoEntity { void StartAction(); void StopAction(MxU32 p_state); - inline MxBool IsBackgroundAudioEnabled() { return m_enableBGA; } + inline MxBool IsBackgroundAudioEnabled() { return m_audioEnabled; } // SYNTHETIC: LEGO1 0x10085db0 // JukeBoxEntity::`scalar deleting destructor' protected: - MxBool m_enableBGA; // 0x68 + MxBool m_audioEnabled; // 0x68 }; #endif // JUKEBOXENTITY_H diff --git a/LEGO1/lego/legoomni/include/jukeboxstate.h b/LEGO1/lego/legoomni/include/jukeboxstate.h index f603fabb..a12c97e5 100644 --- a/LEGO1/lego/legoomni/include/jukeboxstate.h +++ b/LEGO1/lego/legoomni/include/jukeboxstate.h @@ -23,15 +23,15 @@ class JukeBoxState : public LegoState { MxBool VTable0x14() override; // vtable+0x14 inline MxU32 IsActive() { return m_active; } - inline void SetActive(MxBool p_active) { m_active = p_active; } + inline void SetActive(MxU32 p_active) { m_active = p_active; } inline MxU32 GetState() { return m_state; } // SYNTHETIC: LEGO1 0x1000f3d0 // JukeBoxState::`scalar deleting destructor' protected: - MxU32 m_state; // 0x8 - MxU32 m_active; // 0xc + MxU32 m_state; // 0x08 + MxU32 m_active; // 0x0c }; #endif // JUKEBOXSTATE_H diff --git a/LEGO1/lego/legoomni/include/mxbackgroundaudiomanager.h b/LEGO1/lego/legoomni/include/mxbackgroundaudiomanager.h index 3e7793f6..4b70e9e8 100644 --- a/LEGO1/lego/legoomni/include/mxbackgroundaudiomanager.h +++ b/LEGO1/lego/legoomni/include/mxbackgroundaudiomanager.h @@ -31,7 +31,7 @@ class MxBackgroundAudioManager : public MxCore { return !strcmp(p_name, MxBackgroundAudioManager::ClassName()) || MxCore::IsA(p_name); } - inline MxBool GetMusicEnabled() { return m_musicEnabled; } + inline MxBool GetEnabled() { return m_enabled; } void StartAction(MxParam& p_param); void StopAction(MxParam& p_param); @@ -56,7 +56,7 @@ class MxBackgroundAudioManager : public MxCore { MxResult OpenMusic(MxAtomId& p_script); void DestroyMusic(); - MxBool m_musicEnabled; // 0x08 + MxBool m_enabled; // 0x08 MxDSAction m_action1; // 0x0c MxAudioPresenter* m_unk0xa0; // 0xa0 MxDSAction m_action2; // 0xa4 diff --git a/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp b/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp index f04be02b..734c9be7 100644 --- a/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp +++ b/LEGO1/lego/legoomni/src/audio/mxbackgroundaudiomanager.cpp @@ -21,7 +21,7 @@ MxBackgroundAudioManager::MxBackgroundAudioManager() m_unk0x140 = 0; m_targetVolume = 0; m_unk0x148 = 0; - m_musicEnabled = FALSE; + m_enabled = FALSE; } // FUNCTION: LEGO1 0x1007ec20 @@ -39,7 +39,7 @@ MxResult MxBackgroundAudioManager::Create(MxAtomId& p_script, MxU32 p_frequencyM if (result == SUCCESS) { TickleManager()->RegisterClient(this, p_frequencyMS); - m_musicEnabled = TRUE; + m_enabled = TRUE; } return result; @@ -71,7 +71,7 @@ void MxBackgroundAudioManager::DestroyMusic() ds.SetUnknown24(-2); DeleteObject(ds); Streamer()->Close(m_script.GetInternal()); - m_musicEnabled = FALSE; + m_enabled = FALSE; } } @@ -237,9 +237,10 @@ void MxBackgroundAudioManager::StopAction(MxParam& p_param) // FUNCTION: LEGO1 0x1007f2f0 MxResult MxBackgroundAudioManager::PlayMusic(MxDSAction& p_action, undefined4 p_unk0x140, undefined4 p_unk0x13c) { - if (!m_musicEnabled) { + if (!m_enabled) { return SUCCESS; } + if (m_action2.GetObjectId() == -1 && m_action1.GetObjectId() != p_action.GetObjectId()) { MxDSAction action; action.SetAtomId(GetCurrentAction().GetAtomId()); @@ -261,8 +262,10 @@ MxResult MxBackgroundAudioManager::PlayMusic(MxDSAction& p_action, undefined4 p_ m_unk0x13c = p_unk0x13c; m_unk0x140 = p_unk0x140; } + return result; } + return FAILURE; } @@ -317,8 +320,9 @@ void MxBackgroundAudioManager::RaiseVolume() // FUNCTION: LEGO1 0x1007f5f0 void MxBackgroundAudioManager::Enable(MxBool p_enable) { - if (this->m_musicEnabled != p_enable) { - this->m_musicEnabled = p_enable; + if (this->m_enabled != p_enable) { + this->m_enabled = p_enable; + if (!p_enable) { Stop(); } diff --git a/LEGO1/lego/legoomni/src/isle/jukeboxentity.cpp b/LEGO1/lego/legoomni/src/isle/jukeboxentity.cpp index eb6578ee..4168275a 100644 --- a/LEGO1/lego/legoomni/src/isle/jukeboxentity.cpp +++ b/LEGO1/lego/legoomni/src/isle/jukeboxentity.cpp @@ -24,17 +24,20 @@ JukeBoxEntity::~JukeBoxEntity() // FUNCTION: LEGO1 0x10085e40 MxLong JukeBoxEntity::Notify(MxParam& p_param) { - if (((MxNotificationParam&) p_param).GetType() == 0xb) { + if (((MxNotificationParam&) p_param).GetType() == c_notificationType11) { if (!FUN_1003ef60()) { return 1; } + if (CurrentVehicle()->VTable0x60() != GameState()->GetUnknownC()) { CurrentVehicle()->VTable0xe4(); } + ((Isle*) FindWorld(*g_isleScript, 0))->SetUnknown13c(0x35); TransitionManager()->StartTransition(MxTransitionManager::e_pixelation, 50, FALSE, FALSE); return 1; } + return 0; } @@ -43,9 +46,10 @@ void JukeBoxEntity::StartAction() { MxDSAction action; BackgroundAudioManager()->Stop(); - JukeBoxState* jbs = (JukeBoxState*) GameState()->GetState("JukeBoxState"); - jbs->SetActive(TRUE); - switch (jbs->GetState()) { + JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState"); + state->SetActive(TRUE); + + switch (state->GetState()) { case 0: InvokeAction(Extra::e_start, *g_isleScript, 0x319, NULL); GameState()->SetUnknown0x41c(0x37); @@ -71,46 +75,51 @@ void JukeBoxEntity::StartAction() GameState()->SetUnknown0x41c(0x3c); break; } + action.SetAtomId(*g_jukeboxScript); action.SetObjectId(GameState()->GetUnknown0x41c()); - m_enableBGA = BackgroundAudioManager()->GetMusicEnabled(); - if (!m_enableBGA) { + m_audioEnabled = BackgroundAudioManager()->GetEnabled(); + + if (!m_audioEnabled) { BackgroundAudioManager()->Enable(TRUE); } + BackgroundAudioManager()->PlayMusic(action, 5, 4); } // FUNCTION: LEGO1 0x100860f0 void JukeBoxEntity::StopAction(MxU32 p_state) { - JukeBoxState* jbs = (JukeBoxState*) GameState()->GetState("JukeBoxState"); - if (jbs && jbs->IsActive()) { + JukeBoxState* state = (JukeBoxState*) GameState()->GetState("JukeBoxState"); + + if (state && state->IsActive()) { switch (p_state) { case 0x37: - jbs->SetActive(FALSE); + state->SetActive(FALSE); InvokeAction(Extra::e_stop, *g_isleScript, 0x319, NULL); break; case 0x38: - jbs->SetActive(FALSE); + state->SetActive(FALSE); InvokeAction(Extra::e_stop, *g_isleScript, 0x31e, NULL); break; case 0x39: - jbs->SetActive(FALSE); + state->SetActive(FALSE); InvokeAction(Extra::e_stop, *g_isleScript, 0x31b, NULL); break; case 0x3a: - jbs->SetActive(FALSE); + state->SetActive(FALSE); InvokeAction(Extra::e_stop, *g_isleScript, 0x31a, NULL); break; case 0x3b: - jbs->SetActive(FALSE); + state->SetActive(FALSE); InvokeAction(Extra::e_stop, *g_isleScript, 0x31f, NULL); break; case 0x3c: - jbs->SetActive(FALSE); + state->SetActive(FALSE); InvokeAction(Extra::e_stop, *g_isleScript, 0x31c, NULL); break; } + BackgroundAudioManager()->Enable(IsBackgroundAudioEnabled()); } } diff --git a/LEGO1/lego/legoomni/src/isle/radio.cpp b/LEGO1/lego/legoomni/src/isle/radio.cpp index 52bda8f2..17f67d15 100644 --- a/LEGO1/lego/legoomni/src/isle/radio.cpp +++ b/LEGO1/lego/legoomni/src/isle/radio.cpp @@ -61,7 +61,7 @@ void Radio::Play() action.SetAtomId(*g_jukeboxScript); action.SetLoopCount(1); - m_bgAudioPreviouslyEnabled = BackgroundAudioManager()->GetMusicEnabled(); + m_bgAudioPreviouslyEnabled = BackgroundAudioManager()->GetEnabled(); if (!m_bgAudioPreviouslyEnabled) { BackgroundAudioManager()->Enable(TRUE); }