Skip to content

Commit

Permalink
Move sv_alltalk 1.0 to CanPlayerHearPlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Jan 28, 2018
1 parent a7bdaa0 commit 60b6cf9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
8 changes: 5 additions & 3 deletions regamedll/dlls/multiplay_gamerules.cpp
Expand Up @@ -89,19 +89,21 @@ LINK_HOOK_CLASS_CUSTOM_CHAIN(bool, CCStrikeGameMgrHelper, CSGameRules, CanPlayer

bool CCStrikeGameMgrHelper::__API_HOOK(CanPlayerHearPlayer)(CBasePlayer *pListener, CBasePlayer *pSender)
{
#ifdef REGAMEDLL_ADD
switch ((int)sv_alltalk.value)
{
case 1: // allows everyone to talk
return true;
#ifdef REGAMEDLL_ADD
case 2:
return (pListener->m_iTeam == pSender->m_iTeam);
case 3:
return (pListener->m_iTeam == pSender->m_iTeam || pListener->IsObserver());
case 4:
return (pListener->IsAlive() == pSender->IsAlive() || pSender->IsAlive());
default: // HLDS Behavior
default: // Default behavior
break;
}
#endif
}

if (
#ifndef REGAMEDLL_FIXES
Expand Down
15 changes: 6 additions & 9 deletions regamedll/game_shared/voice_gamemgr.cpp
Expand Up @@ -161,26 +161,23 @@ void CVoiceGameMgr::UpdateMasks()
{
m_UpdateInterval = 0;

bool bAllTalk = sv_alltalk.value == 1.0f;

for (int iClient = 0; iClient < m_nMaxPlayers; iClient++)
{
CBaseEntity *pEnt = UTIL_PlayerByIndex(iClient + 1);
CBasePlayer *pPlayer = UTIL_PlayerByIndex(iClient + 1);

if (!pEnt
if (!pPlayer
#ifndef REGAMEDLL_FIXES
|| !pEnt->IsPlayer()
|| !pPlayer->IsPlayer()
#endif
)
continue;

CBasePlayer *pPlayer = static_cast<CBasePlayer *>(pEnt);
CPlayerBitVec gameRulesMask;

// Request the state of their "VModEnable" cvar.
if (g_bWantModEnable[iClient])
{
MESSAGE_BEGIN(MSG_ONE, m_msgRequestState, nullptr, pEnt->pev);
MESSAGE_BEGIN(MSG_ONE, m_msgRequestState, nullptr, pPlayer->pev);
MESSAGE_END();
}

Expand All @@ -189,8 +186,8 @@ void CVoiceGameMgr::UpdateMasks()
// Build a mask of who they can hear based on the game rules.
for (int iOtherClient = 0; iOtherClient < m_nMaxPlayers; iOtherClient++)
{
CBaseEntity *pEnt = UTIL_PlayerByIndex(iOtherClient + 1);
if (pEnt && (bAllTalk || m_pHelper->CanPlayerHearPlayer(pPlayer, (CBasePlayer *)pEnt)))
CBasePlayer *pSender = UTIL_PlayerByIndex(iOtherClient + 1);
if (pSender && m_pHelper->CanPlayerHearPlayer(pPlayer, pSender))
{
gameRulesMask[iOtherClient] = true;
}
Expand Down

0 comments on commit 60b6cf9

Please sign in to comment.