From fe1b1307288f9ecd2d14e1bf059915f27668d031 Mon Sep 17 00:00:00 2001 From: In-line Date: Thu, 2 Nov 2017 14:50:37 +0400 Subject: [PATCH] Refactor CanPlayerHearPlayer (#192) --- regamedll/dlls/multiplay_gamerules.cpp | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 42772915..38338e99 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -103,31 +103,20 @@ bool CCStrikeGameMgrHelper::CanPlayerHearPlayer(CBasePlayer *pListener, CBasePla #ifndef REGAMEDLL_FIXES !pSender->IsPlayer() || #endif - pListener->m_iTeam != pSender->m_iTeam) + pListener->m_iTeam != pSender->m_iTeam) // Different teams can't hear each other { return false; } + if (pListener->IsObserver()) // 2 spectators don't need isAlive() checks. + { + return true; + } + BOOL bListenerAlive = pListener->IsAlive(); BOOL bSenderAlive = pSender->IsAlive(); - if (pListener->IsObserver()) - { - return true; - } - - if (bListenerAlive) - { - if (!bSenderAlive) - return false; - } - else - { - if (bSenderAlive) - return true; - } - - return (bListenerAlive == bSenderAlive); + return (bListenerAlive == bSenderAlive || bSenderAlive); // Dead/alive voice chats are separated, but dead can hear alive. } void Broadcast(const char *sentence)