From 8b224f6130a4979520c81d408a4e0218181717dd Mon Sep 17 00:00:00 2001 From: Diavolo Date: Sun, 14 Aug 2022 13:33:28 +0200 Subject: [PATCH] [Voice] Clear muted list when dc --- src/Components/Modules/Voice.cpp | 12 ++++++++---- src/Components/Modules/Voice.hpp | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Components/Modules/Voice.cpp b/src/Components/Modules/Voice.cpp index 76f7ba8a..90714ffd 100644 --- a/src/Components/Modules/Voice.cpp +++ b/src/Components/Modules/Voice.cpp @@ -242,6 +242,11 @@ namespace Components } } + void Voice::CL_ClearMutedList() + { + std::memset(s_playerMute, 0, sizeof(s_playerMute)); + } + bool Voice::CL_IsPlayerMuted_Hk([[maybe_unused]] Game::SessionData* session, [[maybe_unused]] const int localClientNum, const int muteClientIndex) { AssertIn(muteClientIndex, Game::MAX_CLIENTS); @@ -313,10 +318,7 @@ namespace Components void Voice::UI_Mute_player(int clientNum, const int localClientNum) { - if (Game::cgArray->clientNum != Game::sharedUiInfo->playerClientNums[clientNum]) - { - CL_TogglePlayerMute(localClientNum, Game::sharedUiInfo->playerClientNums[clientNum]); - } + CL_TogglePlayerMute(localClientNum, Game::sharedUiInfo->playerClientNums[clientNum]); } __declspec(naked) void Voice::UI_Mute_Player_Stub() @@ -342,6 +344,8 @@ namespace Components std::memset(voicePacketCount, 0, sizeof(voicePacketCount)); std::memset(s_playerMute, 0, sizeof(s_playerMute)); + Events::OnSteamDisconnect(CL_ClearMutedList); + // Write voice packets to the server instead of other clients Utils::Hook(0x487935, CL_WriteVoicePacket_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x5AD945, CL_WriteVoicePacket_Hk, HOOK_CALL).install()->quick(); diff --git a/src/Components/Modules/Voice.hpp b/src/Components/Modules/Voice.hpp index 6c4cc2b7..d4b02efc 100644 --- a/src/Components/Modules/Voice.hpp +++ b/src/Components/Modules/Voice.hpp @@ -31,6 +31,7 @@ namespace Components static void SV_PreGameUserVoice(Game::client_t* cl, Game::msg_t* msg); static void SV_VoicePacket(Game::netadr_t from, Game::msg_t* msg); + static void CL_ClearMutedList(); static bool CL_IsPlayerMuted_Hk(Game::SessionData* session, int localClientNum, int muteClientIndex); static void CL_MutePlayer_Hk(Game::SessionData* session, int muteClientIndex); static void Voice_UnmuteMember_Hk(Game::SessionData* session, int clientNum);