From ac4e8da662039188654c986423ae8c0fee8a665c Mon Sep 17 00:00:00 2001 From: Christian Semmler <mail@csemmler.com> Date: Sat, 1 Jun 2024 13:45:22 -0400 Subject: [PATCH] Implement/match Lego3DSound::SetDistance and Reset (#984) --- LEGO1/lego/legoomni/include/lego3dsound.h | 4 +-- LEGO1/lego/legoomni/include/legocachsound.h | 4 +-- LEGO1/lego/legoomni/include/legoworld.h | 4 +-- LEGO1/lego/legoomni/src/audio/lego3dsound.cpp | 34 +++++++++++++++---- .../lego/legoomni/src/audio/legocachsound.cpp | 10 +++--- .../src/build/legobuildingmanager.cpp | 2 +- .../src/common/legoanimationmanager.cpp | 1 + LEGO1/lego/legoomni/src/entity/legoworld.cpp | 2 ++ 8 files changed, 42 insertions(+), 19 deletions(-) diff --git a/LEGO1/lego/legoomni/include/lego3dsound.h b/LEGO1/lego/legoomni/include/lego3dsound.h index 315858d0..e52c249b 100644 --- a/LEGO1/lego/legoomni/include/lego3dsound.h +++ b/LEGO1/lego/legoomni/include/lego3dsound.h @@ -20,8 +20,8 @@ public: MxResult Create(LPDIRECTSOUNDBUFFER p_directSoundBuffer, const char* p_name, MxS32 p_volume); void Destroy(); MxU32 UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer); - void FUN_10011ca0(); - MxS32 FUN_10011cf0(undefined4, undefined4); + void Reset(); + MxS32 SetDistance(MxS32 p_min, MxS32 p_max); // SYNTHETIC: LEGO1 0x10011650 // Lego3DSound::`scalar deleting destructor' diff --git a/LEGO1/lego/legoomni/include/legocachsound.h b/LEGO1/lego/legoomni/include/legocachsound.h index f424a465..86255152 100644 --- a/LEGO1/lego/legoomni/include/legocachsound.h +++ b/LEGO1/lego/legoomni/include/legocachsound.h @@ -37,7 +37,7 @@ public: MxResult FUN_10006a30(const char* p_str, MxBool); void FUN_10006b80(); void FUN_10006be0(); - void FUN_10006cb0(undefined4 p_und1, undefined4 p_und2); + void SetDistance(MxS32 p_min, MxS32 p_max); // SYNTHETIC: LEGO1 0x10006610 // LegoCacheSound::`scalar deleting destructor' @@ -47,7 +47,7 @@ private: LPDIRECTSOUNDBUFFER m_dsBuffer; // 0x08 undefined m_unk0xc[4]; // 0x0c - Lego3DSound m_unk0x10; // 0x10 + Lego3DSound m_sound; // 0x10 undefined* m_unk0x40; // 0x40 undefined4 m_unk0x44; // 0x44 MxString m_string0x48; // 0x48 diff --git a/LEGO1/lego/legoomni/include/legoworld.h b/LEGO1/lego/legoomni/include/legoworld.h index 79088500..766d5ca5 100644 --- a/LEGO1/lego/legoomni/include/legoworld.h +++ b/LEGO1/lego/legoomni/include/legoworld.h @@ -1,14 +1,14 @@ #ifndef LEGOWORLD_H #define LEGOWORLD_H -#include "legocachesoundlist.h" #include "legoentity.h" -#include "legoentitylist.h" #include "legopathcontrollerlist.h" #include "mxpresenterlist.h" #include "roi/legoroi.h" +class LegoCacheSoundList; class LegoCameraController; +class LegoEntityList; class LegoPathBoundary; class LegoHideAnimPresenter; diff --git a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp index d93e0c6d..5f6c1a95 100644 --- a/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/lego3dsound.cpp @@ -184,15 +184,35 @@ MxU32 Lego3DSound::UpdatePosition(LPDIRECTSOUNDBUFFER p_directSoundBuffer) return updated; } -// STUB: LEGO1 0x10011ca0 -void Lego3DSound::FUN_10011ca0() +// FUNCTION: LEGO1 0x10011ca0 +void Lego3DSound::Reset() { - // TODO + if (m_enabled && m_roi && CharacterManager()) { + if (m_isActor) { + CharacterManager()->ReleaseActor(m_roi); + } + else { + CharacterManager()->ReleaseAutoROI(m_roi); + } + } + + m_roi = NULL; + m_positionROI = NULL; + m_actor = NULL; } -// STUB: LEGO1 0x10011cf0 -MxS32 Lego3DSound::FUN_10011cf0(undefined4, undefined4) +// FUNCTION: LEGO1 0x10011cf0 +MxS32 Lego3DSound::SetDistance(MxS32 p_min, MxS32 p_max) { - // TODO - return 0; + if (MxOmni::IsSound3D()) { + if (m_ds3dBuffer == NULL) { + return -1; + } + + m_ds3dBuffer->SetMinDistance(p_min, 0); + m_ds3dBuffer->SetMaxDistance(p_max, 0); + return 0; + } + + return 1; } diff --git a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp index 3c2ab5f1..2a6b70ca 100644 --- a/LEGO1/lego/legoomni/src/audio/legocachsound.cpp +++ b/LEGO1/lego/legoomni/src/audio/legocachsound.cpp @@ -100,7 +100,7 @@ void LegoCacheSound::FUN_10006b80() m_unk0x58 = 0; m_unk0x6a = FALSE; - m_unk0x10.FUN_10011ca0(); + m_sound.Reset(); if (m_string0x74.GetLength() != 0) { m_string0x74 = ""; } @@ -123,7 +123,7 @@ void LegoCacheSound::FUN_10006be0() if (dwStatus == 0) { m_dsBuffer->Stop(); - m_unk0x10.FUN_10011ca0(); + m_sound.Reset(); if (m_string0x74.GetLength() != 0) { m_string0x74 = ""; } @@ -134,7 +134,7 @@ void LegoCacheSound::FUN_10006be0() } if (m_string0x74.GetLength() != 0 && !m_unk0x84) { - if (!m_unk0x10.UpdatePosition(m_dsBuffer)) { + if (!m_sound.UpdatePosition(m_dsBuffer)) { if (m_unk0x6a) { return; } @@ -150,9 +150,9 @@ void LegoCacheSound::FUN_10006be0() } // FUNCTION: LEGO1 0x10006cb0 -void LegoCacheSound::FUN_10006cb0(undefined4 p_und1, undefined4 p_und2) +void LegoCacheSound::SetDistance(MxS32 p_min, MxS32 p_max) { - m_unk0x10.FUN_10011cf0(p_und1, p_und2); + m_sound.SetDistance(p_min, p_max); } // FUNCTION: LEGO1 0x10006cd0 diff --git a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp index 3aeef9bb..863520da 100644 --- a/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp +++ b/LEGO1/lego/legoomni/src/build/legobuildingmanager.cpp @@ -619,7 +619,7 @@ void LegoBuildingManager::ScheduleAnimation(LegoEntity* p_entity, MxU32 p_length if (p_haveSound) { m_sound = SoundManager()->GetCacheSoundManager()->FindSoundByKey("bcrash"); - m_sound->FUN_10006cb0(35, 60); + m_sound->SetDistance(35, 60); } if (m_numEntries == 0) { diff --git a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp index 3c358af4..19ff9fa3 100644 --- a/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp +++ b/LEGO1/lego/legoomni/src/common/legoanimationmanager.cpp @@ -9,6 +9,7 @@ #include "legoanimpresenter.h" #include "legocharactermanager.h" #include "legoendanimnotificationparam.h" +#include "legoentitylist.h" #include "legoextraactor.h" #include "legogamestate.h" #include "legolocomotionanimpresenter.h" diff --git a/LEGO1/lego/legoomni/src/entity/legoworld.cpp b/LEGO1/lego/legoomni/src/entity/legoworld.cpp index 9da873e0..fcec9fdd 100644 --- a/LEGO1/lego/legoomni/src/entity/legoworld.cpp +++ b/LEGO1/lego/legoomni/src/entity/legoworld.cpp @@ -4,9 +4,11 @@ #include "legoanimationmanager.h" #include "legoanimpresenter.h" #include "legobuildingmanager.h" +#include "legocachesoundlist.h" #include "legocachesoundmanager.h" #include "legocameracontroller.h" #include "legocontrolmanager.h" +#include "legoentitylist.h" #include "legogamestate.h" #include "legoinputmanager.h" #include "legolocomotionanimpresenter.h"