From 03a06a144d2cca85a50b183773ad4366cb7adf4a Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Thu, 3 Oct 2024 02:56:08 +0300 Subject: [PATCH] Use CHN_WORLD for MAPSOUNDWORLD and CHN_GLOBAL for MAPSOUNDGLOBAL The whole idea behind custom sounds was to use them as replacement for built-in sounds (depending on the gameplay). We have to use the same channels instead of the MAP (aka 'ambient') channel to have the same volume for both sets of messages. Otherwise we have situation of players reporting 'no sound' because they have `snd_ambient_volume 0` in the configs. NETMSGTYPE_SV_MAPSOUNDGLOBAL is NETMSGTYPE_SV_SOUNDGLOBAL which uses map assets as the sounds container. Use the same CSounds::CHN_GLOBAL to make the sound messages equivalent. NETEVENTTYPE_MAPSOUNDWORLD is NETEVENTTYPE_SOUNDWORLD which uses map assets as the sounds container. Use the same CSounds::CHN_WORLD to make the sound events equivalent. --- src/game/client/components/mapsounds.cpp | 8 ++++---- src/game/client/components/mapsounds.h | 4 ++-- src/game/client/gameclient.cpp | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/game/client/components/mapsounds.cpp b/src/game/client/components/mapsounds.cpp index eee0017fc..fd65b9d4b 100644 --- a/src/game/client/components/mapsounds.cpp +++ b/src/game/client/components/mapsounds.cpp @@ -17,20 +17,20 @@ CMapSounds::CMapSounds() m_Count = 0; } -void CMapSounds::Play(int SoundId) +void CMapSounds::Play(int Channel, int SoundId) { if(SoundId < 0 || SoundId >= m_Count) return; - m_pClient->m_Sounds.PlaySample(CSounds::CHN_MAPSOUND, m_aSounds[SoundId], 0, 1.0f); + m_pClient->m_Sounds.PlaySample(Channel, m_aSounds[SoundId], 0, 1.0f); } -void CMapSounds::PlayAt(int SoundId, vec2 Position) +void CMapSounds::PlayAt(int Channel, int SoundId, vec2 Position) { if(SoundId < 0 || SoundId >= m_Count) return; - m_pClient->m_Sounds.PlaySampleAt(CSounds::CHN_MAPSOUND, m_aSounds[SoundId], 0, 1.0f, Position); + m_pClient->m_Sounds.PlaySampleAt(Channel, m_aSounds[SoundId], 0, 1.0f, Position); } void CMapSounds::OnMapLoad() diff --git a/src/game/client/components/mapsounds.h b/src/game/client/components/mapsounds.h index a623303aa..ffca022e5 100644 --- a/src/game/client/components/mapsounds.h +++ b/src/game/client/components/mapsounds.h @@ -33,8 +33,8 @@ public: CMapSounds(); virtual int Sizeof() const override { return sizeof(*this); } - void Play(int SoundId); - void PlayAt(int SoundId, vec2 Position); + void Play(int Channel, int SoundId); + void PlayAt(int Channel, int SoundId, vec2 Position); virtual void OnMapLoad() override; virtual void OnRender() override; diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index b1d701552..cc5fc66b3 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1105,7 +1105,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, int Conn, bool Dumm return; CNetMsg_Sv_MapSoundGlobal *pMsg = (CNetMsg_Sv_MapSoundGlobal *)pRawMsg; - m_MapSounds.Play(pMsg->m_SoundId); + m_MapSounds.Play(CSounds::CHN_GLOBAL, pMsg->m_SoundId); } } @@ -1286,7 +1286,7 @@ void CGameClient::ProcessEvents() if(!Config()->m_SndGame) continue; - m_MapSounds.PlayAt(pEvent->m_SoundId, vec2(pEvent->m_X, pEvent->m_Y)); + m_MapSounds.PlayAt(CSounds::CHN_WORLD, pEvent->m_SoundId, vec2(pEvent->m_X, pEvent->m_Y)); } } }