Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.1 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: This module implements the IVoiceServer interface.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "quakedef.h"
  8. #include "server.h"
  9. #include "ivoiceserver.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. class CVoiceServer : public IVoiceServer
  13. {
  14. public:
  15. virtual bool GetClientListening(int iReceiver, int iSender)
  16. {
  17. // Make into client indices..
  18. --iReceiver;
  19. --iSender;
  20. if(iReceiver < 0 || iReceiver >= sv.GetClientCount() || iSender < 0 || iSender >= sv.GetClientCount() )
  21. return false;
  22. return sv.GetClient(iSender)->IsHearingClient( iReceiver );
  23. }
  24. virtual bool SetClientListening(int iReceiver, int iSender, bool bListen)
  25. {
  26. // Make into client indices..
  27. --iReceiver;
  28. --iSender;
  29. if(iReceiver < 0 || iReceiver >= sv.GetClientCount() || iSender < 0 || iSender >= sv.GetClientCount() )
  30. return false;
  31. CGameClient *cl = sv.Client(iSender);
  32. ConVarRef voice_verbose( "voice_verbose" );
  33. if ( voice_verbose.GetBool() && ( !!cl->m_VoiceStreams.Get( iReceiver ) != !!bListen ) )
  34. {
  35. Msg( "* CVoiceServer::SetClientListening: %s m_VoiceStreams from %s (%s) to %s (%s)\n", bListen ? "Enable" : "Disable", cl->GetClientName(), cl->GetNetChannel() ? cl->GetNetChannel()->GetAddress() : "null", sv.Client(iReceiver)->GetClientName(), sv.Client(iReceiver)->GetNetChannel() ? sv.Client(iReceiver)->GetNetChannel()->GetAddress() : "null" );
  36. }
  37. cl->m_VoiceStreams.Set( iReceiver, bListen?1:0 );
  38. return true;
  39. }
  40. virtual bool SetClientProximity(int iReceiver, int iSender, bool bUseProximity)
  41. {
  42. // Make into client indices..
  43. --iReceiver;
  44. --iSender;
  45. if(iReceiver < 0 || iReceiver >= sv.GetClientCount() || iSender < 0 || iSender >= sv.GetClientCount() )
  46. return false;
  47. CGameClient *cl = sv.Client(iSender);
  48. cl->m_VoiceProximity.Set( iReceiver, bUseProximity );
  49. return true;
  50. }
  51. };
  52. EXPOSE_SINGLE_INTERFACE(CVoiceServer, IVoiceServer, INTERFACEVERSION_VOICESERVER);