Skip to content

all games: Add ConVars for configuring proximity voice chat #1277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/game/shared/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,13 @@ ConVarRef suitcharger( "sk_suitcharger" );
pAllTalk->SetString( "tag", "alltalk" );

pCvarTagList->AddSubKey( pAllTalk );

// sv_proximity_voice_enable
KeyValues *pProximityVoice = new KeyValues( "sv_proximity_voice_enable" );
pProximityVoice->SetString( "convar", "sv_proximity_voice_enable" );
pProximityVoice->SetString( "tag", "proximity_voice" );

pCvarTagList->AddSubKey( pProximityVoice );
}

#else
Expand Down
12 changes: 4 additions & 8 deletions src/game/shared/voice_gamemgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ ConVar voice_serverdebug( "voice_serverdebug", "0" );
// Muted players still can't talk to each other.
ConVar sv_alltalk( "sv_alltalk", "0", FCVAR_NOTIFY | FCVAR_REPLICATED, "Players can hear all other players, no team restrictions" );

ConVar sv_proximity_voice_enable( "sv_proximity_voice_enable", "0", FCVAR_NOTIFY | FCVAR_REPLICATED, "Enable proximity voice chat" );
ConVar sv_proximity_voice_distance( "sv_proximity_voice_distance", "16", FCVAR_NOTIFY | FCVAR_REPLICATED, "Max distance at which voice will be projected" );

CVoiceGameMgr g_VoiceGameMgr;

Expand Down Expand Up @@ -103,7 +105,6 @@ CVoiceGameMgr::CVoiceGameMgr()
{
m_UpdateInterval = 0;
m_nMaxPlayers = 0;
m_iProximityDistance = -1;
}


Expand Down Expand Up @@ -225,7 +226,7 @@ void CVoiceGameMgr::UpdateMasks()

CPlayerBitVec gameRulesMask;
CPlayerBitVec ProximityMask;
bool bProximity = false;
bool bProximity = sv_proximity_voice_enable.GetBool();
if( g_PlayerModEnable[iClient] )
{
// Build a mask of who they can hear based on the game rules.
Expand Down Expand Up @@ -278,14 +279,9 @@ bool CVoiceGameMgr::IsPlayerIgnoringPlayer( int iTalker, int iListener )
return !!g_BanMasks[iListener-1][iTalker-1];
}

void CVoiceGameMgr::SetProximityDistance( int iDistance )
{
m_iProximityDistance = iDistance;
}

bool CVoiceGameMgr::CheckProximity( int iDistance )
{
if ( m_iProximityDistance >= iDistance )
if ( sv_proximity_voice_distance.GetInt() >= iDistance )
return true;

return false;
Expand Down
2 changes: 0 additions & 2 deletions src/game/shared/voice_gamemgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class CVoiceGameMgr
bool ClientCommand(CBasePlayer *pPlayer, const CCommand &args );

bool CheckProximity( int iDistance );
void SetProximityDistance( int iDistance );

bool IsPlayerIgnoringPlayer( int iTalker, int iListener );

Expand All @@ -69,7 +68,6 @@ class CVoiceGameMgr
IVoiceGameMgrHelper *m_pHelper;
int m_nMaxPlayers;
double m_UpdateInterval; // How long since the last update.
int m_iProximityDistance;
};


Expand Down