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.

169 lines
5.5 KiB

  1. //========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef ICLIENT_H
  7. #define ICLIENT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "inetmsghandler.h"
  12. #include "tier0/platform.h"
  13. #include "userid.h"
  14. #include "tier1/utlvector.h"
  15. class IServer;
  16. class INetMessage;
  17. struct NetMessageCvar_t;
  18. class CMsg_CVars;
  19. enum CrossPlayPlatform_t
  20. {
  21. CROSSPLAYPLATFORM_UNKNOWN = 0,
  22. CROSSPLAYPLATFORM_PC,
  23. CROSSPLAYPLATFORM_X360,
  24. CROSSPLAYPLATFORM_PS3,
  25. CROSSPLAYPLATFORM_LAST = CROSSPLAYPLATFORM_PS3,
  26. };
  27. inline bool IsCrossPlayPlatformAConsole( CrossPlayPlatform_t platform )
  28. {
  29. return (platform == CROSSPLAYPLATFORM_X360) || (platform == CROSSPLAYPLATFORM_PS3);
  30. }
  31. //provide the compiled code's platform for convenience
  32. #if defined( _GAMECONSOLE )
  33. # if defined( PLATFORM_X360 )
  34. # define CROSSPLAYPLATFORM_THISPLATFORM CROSSPLAYPLATFORM_X360
  35. # elif defined( PLATFORM_PS3 )
  36. # define CROSSPLAYPLATFORM_THISPLATFORM CROSSPLAYPLATFORM_PS3
  37. # else
  38. #pragma message( "Unknown console, please update this platform definition" )
  39. # define CROSSPLAYPLATFORM_THISPLATFORM CROSSPLAYPLATFORM_UNKNOWN
  40. # endif
  41. #else
  42. # define CROSSPLAYPLATFORM_THISPLATFORM CROSSPLAYPLATFORM_PC
  43. #endif
  44. struct HltvReplayParams_t
  45. {
  46. HltvReplayParams_t()
  47. {
  48. m_nPrimaryTargetEntIndex = 0;
  49. m_flPlaybackSpeed = 1.0f;
  50. m_flDelay = 10.0f;
  51. m_flStopAt = 0.0f;
  52. m_flSlowdownBeginAt = 0;
  53. m_flSlowdownEndAt = 0;
  54. m_flSlowdownRate = 1.0f;
  55. m_bAbortCurrentReplay = false;
  56. }
  57. int m_nPrimaryTargetEntIndex;
  58. float m_flDelay;
  59. float m_flStopAt;
  60. float m_flPlaybackSpeed;
  61. float m_flSlowdownBeginAt;
  62. float m_flSlowdownEndAt;
  63. float m_flSlowdownRate;
  64. bool m_bAbortCurrentReplay; // even if replay is in progress, restart it - this may cause a stutter on the client, so use with care
  65. };
  66. abstract_class IClient : public INetChannelHandler
  67. {
  68. public:
  69. virtual ~IClient() {}
  70. // connect client
  71. virtual void Connect( const char * szName, int nUserID, INetChannel *pNetChannel, bool bFakePlayer, CrossPlayPlatform_t clientPlatform, const CMsg_CVars *pVecCvars = NULL ) = 0;
  72. // set the client in a pending state waiting for a new game
  73. virtual void Inactivate( void ) = 0;
  74. // Reconnect without dropiing the netchannel
  75. virtual void Reconnect( void ) = 0; // froce reconnect
  76. // disconnects a client with a given reason
  77. virtual void Disconnect( const char *reason ) = 0;
  78. virtual bool ChangeSplitscreenUser( int nSplitScreenUserSlot ) = 0;
  79. virtual int GetPlayerSlot() const = 0; // returns client slot (usually entity number-1)
  80. virtual int GetUserID() const = 0; // unique ID on this server
  81. virtual const USERID_t GetNetworkID() const = 0; // network wide ID
  82. virtual const char *GetClientName() const = 0; // returns client name
  83. virtual INetChannel *GetNetChannel() = 0; // returns client netchannel
  84. virtual IServer *GetServer() = 0; // returns the object server the client belongs to
  85. virtual const char *GetUserSetting(const char *cvar) const = 0; // returns a clients FCVAR_USERINFO setting
  86. virtual const char *GetNetworkIDString() const = 0; // returns a human readable representation of the network id
  87. // set/get client data rate in bytes/second
  88. virtual void SetRate( int nRate, bool bForce ) = 0;
  89. virtual int GetRate( void ) const = 0;
  90. // set/get updates/second rate
  91. virtual void SetUpdateRate( float fUpdateRate, bool bForce ) = 0;
  92. virtual float GetUpdateRate( void ) const = 0;
  93. // clear complete object & free all memory
  94. virtual void Clear( void ) = 0;
  95. // returns the highest world tick number acknowledge by client
  96. virtual int GetMaxAckTickCount() const = 0;
  97. // execute a client command
  98. virtual bool ExecuteStringCommand( const char *s ) = 0;
  99. // send client a network message
  100. virtual bool SendNetMsg(INetMessage &msg, bool bForceReliable = false, bool bVoice = false ) = 0;
  101. // send client a text message
  102. virtual void ClientPrintf (const char *fmt, ...) = 0;
  103. // client has established network channels, nothing else
  104. virtual bool IsConnected( void ) const = 0;
  105. // client is downloading signon data
  106. virtual bool IsSpawned( void ) const = 0;
  107. // client active is ingame, receiving snapshots
  108. virtual bool IsActive( void ) const = 0;
  109. // returns true, if client is not a real player
  110. virtual bool IsFakeClient( void ) const = 0;
  111. // returns true, if client is a HLTV proxy
  112. virtual bool IsHLTV( void ) const = 0;
  113. #if defined( REPLAY_ENABLED )
  114. // returns true, if client is a Replay proxy
  115. virtual bool IsReplay( void ) const = 0;
  116. #endif
  117. // returns true, if client hears this player
  118. virtual bool IsHearingClient(int index) const = 0;
  119. // returns true, if client hears this player by proximity
  120. virtual bool IsProximityHearingClient(int index) const = 0;
  121. virtual void SetMaxRoutablePayloadSize( int nMaxRoutablePayloadSize ) = 0;
  122. // returns true, if client is a split screen user
  123. virtual bool IsSplitScreenUser( void ) const = 0;
  124. virtual bool CheckConnect( void ) = 0;
  125. virtual bool IsLowViolenceClient( void ) const = 0;
  126. virtual IClient *GetSplitScreenOwner() = 0;
  127. // get the number of players on this client's machine
  128. virtual int GetNumPlayers() = 0;
  129. virtual bool IsHumanPlayer() const = 0;
  130. virtual CrossPlayPlatform_t GetClientPlatform() const = 0;
  131. virtual bool StartHltvReplay( const HltvReplayParams_t &params ) = 0;
  132. virtual void StopHltvReplay() = 0;
  133. virtual int GetHltvReplayDelay() = 0;
  134. virtual const char * GetHltvReplayStatus()const { return ""; }
  135. virtual bool CanStartHltvReplay() = 0;
  136. virtual void ResetReplayRequestTime() = 0;
  137. };
  138. #endif // ICLIENT_H