extensions/sdktools/voice.cpp
changeset 1468 b90faced4648
parent 1330 ab94316bb52b
child 1947 e73a1e51833b
     1.1 --- a/extensions/sdktools/voice.cpp	Sun Sep 23 20:33:22 2007 +0000
     1.2 +++ b/extensions/sdktools/voice.cpp	Sun Sep 23 21:01:07 2007 +0000
     1.3 @@ -8,7 +8,7 @@
     1.4   * This program is free software; you can redistribute it and/or modify it under
     1.5   * the terms of the GNU General Public License, version 3.0, as published by the
     1.6   * Free Software Foundation.
     1.7 - * 
     1.8 + *
     1.9   * This program is distributed in the hope that it will be useful, but WITHOUT
    1.10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.11   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.12 @@ -35,6 +35,8 @@
    1.13  #define SPEAK_MUTED			1
    1.14  #define SPEAK_ALL			2
    1.15  #define SPEAK_LISTENALL		4
    1.16 +#define SPEAK_TEAM			8
    1.17 +#define SPEAK_LISTENTEAM	16
    1.18  
    1.19  size_t g_VoiceFlags[65];
    1.20  size_t g_VoiceFlagsCount = 0;
    1.21 @@ -43,19 +45,31 @@
    1.22  
    1.23  bool SDKTools::OnSetClientListening(int iReceiver, int iSender, bool bListen)
    1.24  {
    1.25 -	if (g_VoiceFlags[iSender] & SPEAK_MUTED) 
    1.26 +	if (g_VoiceFlags[iSender] & SPEAK_MUTED)
    1.27  	{
    1.28  		RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVoiceServer::SetClientListening, (iReceiver, iSender, false));
    1.29  	}
    1.30  
    1.31 -	if (g_VoiceFlags[iSender] & SPEAK_ALL)
    1.32 +	if ((g_VoiceFlags[iSender] & SPEAK_ALL) || (g_VoiceFlags[iReceiver] & SPEAK_LISTENALL))
    1.33  	{
    1.34  		RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVoiceServer::SetClientListening, (iReceiver, iSender, true));
    1.35  	}
    1.36  
    1.37 -	if (g_VoiceFlags[iReceiver] & SPEAK_LISTENALL)
    1.38 +	if ((g_VoiceFlags[iSender] & SPEAK_TEAM) || (g_VoiceFlags[iReceiver] & SPEAK_LISTENTEAM))
    1.39  	{
    1.40 -		RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVoiceServer::SetClientListening, (iReceiver, iSender, true));
    1.41 +		IGamePlayer *pReceiver = playerhelpers->GetGamePlayer(iReceiver);
    1.42 +		IGamePlayer *pSender = playerhelpers->GetGamePlayer(iSender);
    1.43 +
    1.44 +		if (pReceiver && pSender && pReceiver->IsInGame() && pSender->IsInGame())
    1.45 +		{
    1.46 +			IPlayerInfo *pRInfo = pReceiver->GetPlayerInfo();
    1.47 +			IPlayerInfo *pSInfo = pSender->GetPlayerInfo();
    1.48 +
    1.49 +			if (pRInfo && pSInfo && pRInfo->GetTeamIndex() == pSInfo->GetTeamIndex())
    1.50 +			{
    1.51 +				RETURN_META_VALUE_NEWPARAMS(MRES_IGNORED, bListen, &IVoiceServer::SetClientListening, (iReceiver, iSender, true));
    1.52 +			}
    1.53 +		}
    1.54  	}
    1.55  
    1.56  	RETURN_META_VALUE(MRES_IGNORED, bListen);
    1.57 @@ -64,7 +78,7 @@
    1.58  void SDKTools::OnClientDisconnecting(int client)
    1.59  {
    1.60  	if (g_VoiceFlags[client])
    1.61 -	{	
    1.62 +	{
    1.63  		g_VoiceFlags[client] = 0;
    1.64  		if (!--g_VoiceFlagsCount)
    1.65  		{
    1.66 @@ -143,7 +157,7 @@
    1.67  	return voiceserver->GetClientListening(params[1], params[2]) ? 1 : 0;
    1.68  }
    1.69  
    1.70 -sp_nativeinfo_t g_VoiceNatives[] = 
    1.71 +sp_nativeinfo_t g_VoiceNatives[] =
    1.72  {
    1.73  	{"SetClientListeningFlags",		SetClientListeningFlags},
    1.74  	{"GetClientListeningFlags",		GetClientListeningFlags},