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.

598 lines
22 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef BASECLIENTSTATE_H
  7. #define BASECLIENTSTATE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "inetmsghandler.h"
  12. #include "protocol.h"
  13. #include "client_class.h"
  14. #include "cdll_int.h"
  15. #include "tier1/netadr.h"
  16. #include "common.h"
  17. #include "clockdriftmgr.h"
  18. #include "convar.h"
  19. #include "cl_bounded_cvars.h"
  20. #include "tier1/utlstring.h"
  21. #include "netmessages.h"
  22. #include "utlmap.h"
  23. #include "matchmaking/imatchasync.h"
  24. #include "netmessages.pb.h"
  25. // Only send this many requests before timing out.
  26. #define CL_CONNECTION_RETRIES 4
  27. // Mininum time gap (in seconds) before a subsequent connection request is sent.
  28. #define CL_MIN_RESEND_TIME 1.5f
  29. // Max time. The cvar cl_resend is bounded by these.
  30. #define CL_MAX_RESEND_TIME 20.0f
  31. // In release, send commands at least this many times per second
  32. #define MIN_CMD_RATE 10.0f
  33. #define MAX_CMD_RATE 128.0f
  34. typedef intp SerializedEntityHandle_t;
  35. extern ConVar cl_name;
  36. abstract_class CBaseClientState;
  37. // This represents a server's
  38. class C_ServerClassInfo
  39. {
  40. public:
  41. C_ServerClassInfo();
  42. ~C_ServerClassInfo();
  43. public:
  44. ClientClass *m_pClientClass;
  45. char *m_ClassName;
  46. char *m_DatatableName;
  47. // This is an index into the network string table (GetBaseLocalClient().GetInstanceBaselineTable()).
  48. int m_InstanceBaselineIndex; // INVALID_STRING_INDEX if not initialized yet.
  49. };
  50. #define EndGameAssertMsg( assertion, msg ) \
  51. if ( !(assertion) )\
  52. Host_EndGame msg
  53. class CNetworkStringTableContainer;
  54. class PackedEntity;
  55. class INetworkStringTable;
  56. class CEntityReadInfo;
  57. struct DeferredConnection_t
  58. {
  59. DeferredConnection_t()
  60. {
  61. m_bActive = false;
  62. m_nChallenge = 0;
  63. m_nAuthprotocol = 0;
  64. m_unGSSteamID = 0ull;;
  65. m_unLobbyID = 0ull;
  66. m_bGSSecure = false;
  67. m_bRequiresPassword = false;
  68. m_bDCFriendsReqd = false;
  69. m_bOfficialValveServer = false;
  70. m_nEncryptionKey = 0;
  71. m_nEncryptedSize = 0;
  72. memset( m_chLobbyType, 0, sizeof( m_chLobbyType ) );
  73. }
  74. bool m_bActive;
  75. bool m_bGSSecure;
  76. bool m_bRequiresPassword;
  77. bool m_bDCFriendsReqd;
  78. bool m_bOfficialValveServer;
  79. char m_chLobbyType[16];
  80. int m_nChallenge;
  81. int m_nAuthprotocol;
  82. uint64 m_unGSSteamID;
  83. uint64 m_unLobbyID;
  84. ns_address m_adrServerAddress;
  85. int m_nEncryptionKey;
  86. int m_nEncryptedSize;
  87. };
  88. // 0 == public, 1 == private, 2 == double NAT'd private (for direct connection)
  89. struct Remote_t
  90. {
  91. bool Resolve();
  92. CUtlString m_szAlias; // debugging: "public", "private", "direct"
  93. CUtlString m_szRetryAddress;
  94. // Address for actual packets (may differ from m_szRetryAddress)
  95. ns_address m_adrRemote;
  96. };
  97. class CAddressList
  98. {
  99. public:
  100. CAddressList() {}
  101. void RemoveAll();
  102. bool IsRemoteInList( char const *pchAdrCheck ) const;
  103. bool IsAddressInList( const ns_address &adr ) const;
  104. // Only adds if not in list already
  105. void AddRemote( char const *pchAddress, char const *pchAlias );
  106. void Describe( CUtlString &str );
  107. int Count() const;
  108. Remote_t &Get( int index );
  109. const Remote_t &Get( int index ) const;
  110. private:
  111. CUtlVector< Remote_t > m_List;
  112. };
  113. // Classes to help with sending messages to server, with retries and timeouts
  114. // Start by sending the message immediately. Wait for timeout before
  115. // sending message again.
  116. // If maxAttempts exceeded with no response set state to AOS_FAILED and call callback.
  117. // If a response is received set state to AOS_SUCCEEDED and call callback.
  118. // Result is only valid if state == AOS_SUCCEEDED
  119. class CServerMsg : public IMatchAsyncOperation
  120. {
  121. public:
  122. // Methods of IMatchAsyncOperation
  123. bool IsFinished() { return m_eState > AOS_ABORTING; }
  124. AsyncOperationState_t GetState() { return m_eState; }
  125. uint64 GetResult() { return m_result; }
  126. void Abort() { m_eState = AOS_ABORTED; }
  127. // Timeout in seconds
  128. explicit CServerMsg( CBaseClientState *pParent, IMatchAsyncOperationCallback *pCallback,
  129. const ns_address& serverAdr, int socket, uint32 maxAttempts, double timeout );
  130. // Per frame update, check for timeout etc if state == AOS_RUNNING
  131. void Update( void );
  132. // Call this function to check if it is ok to process a msg
  133. bool IsValidResponse( const ns_address &from, uint32 token );
  134. // Called by derived class when response received. Sets state to AOS_SUCCEEDED
  135. // and calls callback
  136. void ResponseReceived( uint64 result );
  137. // Methods derived class must implement. Token is a random number that can be
  138. // used to match up a message-response pair. A new token is generated for each
  139. // SendMsg call; the last token generated can be queried using GetLastToken()
  140. virtual void SendMsg( const ns_address& serverAdr, int socket, uint32 token ) = 0;
  141. // See comment for SendMsg()
  142. uint32 GetLastToken() { return m_lastToken; }
  143. const ns_address& GetServerAddr() { return m_serverAdr; }
  144. // base client state parent
  145. CBaseClientState *m_pParent;
  146. // Data members
  147. AsyncOperationState_t m_eState;
  148. IMatchAsyncOperationCallback *m_pCallback;
  149. ns_address m_serverAdr;
  150. int m_socket;
  151. double m_lastMsgSendTime;
  152. double m_timeOut;
  153. uint32 m_maxAttempts;
  154. uint32 m_numAttempts;
  155. uint64 m_result;
  156. uint32 m_lastToken; // See comment for SendMsg()
  157. };
  158. class CServerMsg_CheckReservation : public CServerMsg
  159. {
  160. public:
  161. explicit CServerMsg_CheckReservation( CBaseClientState *pParent, IMatchAsyncOperationCallback *pCallback,
  162. const ns_address &serverAdr, int socket, uint64 reservationCookie, uint32 uiReservationStage );
  163. void Release();
  164. void SendMsg( const ns_address& serverAdr, int socket, uint32 token );
  165. void ResponseReceived( const ns_address& from, bf_read &msg, int32 hostVersion, uint32 token );
  166. uint64 m_reservationCookie;
  167. uint32 m_uiReservationStage;
  168. };
  169. class CServerMsg_Ping : public CServerMsg
  170. {
  171. public:
  172. explicit CServerMsg_Ping( CBaseClientState *pParent, IMatchAsyncOperationCallback *pCallback,
  173. const ns_address &serverAdr, int socket );
  174. void Release();
  175. void SendMsg( const ns_address& serverAdrserverAdr, int socket, uint32 token );
  176. void ResponseReceived( const ns_address& from, bf_read &msg, int32 hostVersion, uint32 token );
  177. double m_timeLastMsgSent;
  178. };
  179. // CBaseClientState
  180. abstract_class CBaseClientState :
  181. public INetChannelHandler,
  182. public IConnectionlessPacketHandler
  183. {
  184. public:
  185. CBaseClientState();
  186. virtual ~CBaseClientState();
  187. public: // IConnectionlessPacketHandler interface:
  188. virtual bool ProcessConnectionlessPacket(struct netpacket_s *packet);
  189. public: // INetMsgHandler interface:
  190. virtual void ConnectionStart(INetChannel *chan) OVERRIDE;
  191. virtual void ConnectionStop( ) OVERRIDE;
  192. virtual void ConnectionClosing( const char *reason );
  193. virtual void ConnectionCrashed(const char *reason);
  194. virtual void PacketStart(int incoming_sequence, int outgoing_acknowledged) {};
  195. virtual void PacketEnd( void ) {};
  196. virtual void FileReceived( const char *fileName, unsigned int transferID, bool isReplayDemoFile );
  197. virtual void FileRequested(const char *fileName, unsigned int transferID, bool isReplayDemoFile );
  198. virtual void FileDenied(const char *fileName, unsigned int transferID, bool isReplayDemoFile );
  199. virtual void FileSent(const char *fileName, unsigned int transferID, bool isReplayDemoFile );
  200. virtual bool ChangeSplitscreenUser( int nSplitScreenUserSlot ); // interleaved networking used by SS system is changing the SS player slot that the subsequent messages pertain to
  201. public: // IServerMessageHandlers
  202. virtual bool NETMsg_Tick( const CNETMsg_Tick& msg );
  203. static bool NETMsg_Tick_Delegate( CBaseClientState *pThis, const CNETMsg_Tick& msg ) { return pThis->NETMsg_Tick( msg ); }
  204. virtual bool NETMsg_StringCmd( const CNETMsg_StringCmd& msg );
  205. bool NETMsg_SignonState( const CNETMsg_SignonState& msg );
  206. virtual bool NETMsg_PlayerAvatarData( const CNETMsg_PlayerAvatarData& msg );
  207. virtual bool NETMsg_SetConVar( const CNETMsg_SetConVar& msg );
  208. bool SVCMsg_CmdKeyValues( const CSVCMsg_CmdKeyValues& msg);
  209. virtual bool SVCMsg_EncryptedData( const CSVCMsg_EncryptedData& msg );
  210. bool SVCMsg_SendTable( const CSVCMsg_SendTable& msg );
  211. bool SVCMsg_Print( const CSVCMsg_Print& msg );
  212. virtual bool SVCMsg_ServerInfo( const CSVCMsg_ServerInfo& msg );
  213. virtual bool SVCMsg_ClassInfo( const CSVCMsg_ClassInfo& msg );
  214. virtual bool SVCMsg_SetPause( const CSVCMsg_SetPause& msg );
  215. virtual bool SVCMsg_SetView( const CSVCMsg_SetView& msg );
  216. virtual bool SVCMsg_CreateStringTable( const CSVCMsg_CreateStringTable& msg );
  217. virtual bool SVCMsg_UpdateStringTable( const CSVCMsg_UpdateStringTable& msg );
  218. virtual bool SVCMsg_VoiceInit( const CSVCMsg_VoiceInit& msg ) = 0;
  219. virtual bool SVCMsg_VoiceData( const CSVCMsg_VoiceData& msg ) = 0;
  220. virtual bool SVCMsg_FixAngle( const CSVCMsg_FixAngle& msg ) = 0;
  221. virtual bool SVCMsg_Prefetch( const CSVCMsg_Prefetch& msg ) = 0;
  222. virtual bool SVCMsg_CrosshairAngle( const CSVCMsg_CrosshairAngle& msg ) = 0;
  223. virtual bool SVCMsg_BSPDecal( const CSVCMsg_BSPDecal& msg ) = 0;
  224. virtual bool SVCMsg_SplitScreen( const CSVCMsg_SplitScreen& msg );
  225. virtual bool SVCMsg_GetCvarValue( const CSVCMsg_GetCvarValue& msg );
  226. virtual bool SVCMsg_Menu( const CSVCMsg_Menu& msg );
  227. virtual bool SVCMsg_UserMessage( const CSVCMsg_UserMessage& msg ) = 0;
  228. virtual bool SVCMsg_PaintmapData( const CSVCMsg_PaintmapData& msg ) = 0;
  229. virtual bool SVCMsg_GameEvent( const CSVCMsg_GameEvent& msg ) = 0;
  230. virtual bool SVCMsg_GameEventList( const CSVCMsg_GameEventList &msg );
  231. virtual bool SVCMsg_TempEntities( const CSVCMsg_TempEntities& msg ) = 0;
  232. virtual bool SVCMsg_PacketEntities( const CSVCMsg_PacketEntities& msg );
  233. virtual bool SVCMsg_Sounds( const CSVCMsg_Sounds& msg ) = 0;
  234. virtual bool SVCMsg_EntityMsg( const CSVCMsg_EntityMsg& msg ) = 0;
  235. CNetMessageBinder m_NETMsgTick;
  236. CNetMessageBinder m_NETMsgStringCmd;
  237. CNetMessageBinder m_NETMsgSignonState;
  238. CNetMessageBinder m_NETMsgSetConVar;
  239. CNetMessageBinder m_NETMsgPlayerAvatarData;
  240. CNetMessageBinder m_SVCMsgServerInfo;
  241. CNetMessageBinder m_SVCMsgCmdKeyValues;
  242. CNetMessageBinder m_SVCMsg_EncryptedData;
  243. CNetMessageBinder m_SVCMsgClassInfo;
  244. CNetMessageBinder m_SVCMsgSendTable;
  245. CNetMessageBinder m_SVCMsgPrint;
  246. CNetMessageBinder m_SVCMsgSetPause;
  247. CNetMessageBinder m_SVCMsgSetView;
  248. CNetMessageBinder m_SVCMsgCreateStringTable;
  249. CNetMessageBinder m_SVCMsgUpdateStringTable;
  250. CNetMessageBinder m_SVCMsgVoiceInit;
  251. CNetMessageBinder m_SVCMsgVoiceData;
  252. CNetMessageBinder m_SVCMsgFixAngle;
  253. CNetMessageBinder m_SVCMsgPrefetch;
  254. CNetMessageBinder m_SVCMsgCrosshairAngle;
  255. CNetMessageBinder m_SVCMsgBSPDecal;
  256. CNetMessageBinder m_SVCMsgSplitScreen;
  257. CNetMessageBinder m_SVCMsgGetCvarValue;
  258. CNetMessageBinder m_SVCMsgMenu;
  259. CNetMessageBinder m_SVCMsgUserMessage;
  260. CNetMessageBinder m_SVCMsgPaintmapData;
  261. CNetMessageBinder m_SVCMsgGameEvent;
  262. CNetMessageBinder m_SVCMsgGameEventList;
  263. CNetMessageBinder m_SVCMsgTempEntities;
  264. CNetMessageBinder m_SVCMsgPacketEntities;
  265. CNetMessageBinder m_SVCMsgSounds;
  266. CNetMessageBinder m_SVCMsgEntityMsg;
  267. public: // IMatchEventsSink
  268. virtual void OnEvent( KeyValues *pEvent );
  269. public:
  270. inline bool IsActive( void ) const { return m_nSignonState == SIGNONSTATE_FULL; };
  271. inline bool IsConnected( void ) const { return m_nSignonState >= SIGNONSTATE_CONNECTED; };
  272. inline bool IsConnecting( void ) const { return m_nSignonState >= SIGNONSTATE_NONE; }
  273. virtual void Clear( void );
  274. virtual void FullConnect( const ns_address &adr, int nEncryptionKey ); // a connection was established
  275. virtual void Connect( const char *pchPublicAddress, char const *pchPrivateAddress, const char* szJoinType ); // start a connection challenge
  276. virtual void ConnectSplitScreen( const char *pchPublicAddress, char const *pchPrivateAddress, int numPlayers, const char* szJoinType ); // start a connection challenge
  277. virtual bool SetSignonState ( int state, int count, const CNETMsg_SignonState *msg );
  278. virtual void Disconnect( bool bShowMainMenu = true );
  279. virtual void SendConnectPacket ( const ns_address &netAdrRemote, int challengeNr, int authProtocol, uint64 unGSSteamID, bool bGSSecure );
  280. virtual const char *GetCDKeyHash() { return "123"; }
  281. virtual void RunFrame ( void );
  282. virtual void CheckForResend ( bool bForceResendNow = false );
  283. virtual void CheckForReservationResend( void );
  284. virtual void ResendGameDetailsRequest( const ns_address &adr );
  285. virtual void InstallStringTableCallback( char const *tableName ) { }
  286. virtual bool HookClientStringTable( char const *tableName ) { return false; }
  287. virtual bool LinkClasses( void );
  288. virtual int GetConnectionRetryNumber() const { return m_nRetryMax; }
  289. virtual const char *GetClientName() { return cl_name.GetString(); }
  290. virtual void ReserveServer( const ns_address &netAdrPublic, const ns_address &netAdrPrivate, uint64 nServerReservationCookie,
  291. KeyValues *pKVGameSettings, IMatchAsyncOperationCallback *pCallback, IMatchAsyncOperation **ppAsyncOperation );
  292. bool CheckServerReservation( const ns_address &netAdrPublic, uint64 nServerReservationCookie, uint32 uiReservationStage, IMatchAsyncOperationCallback *pCallback, IMatchAsyncOperation **ppAsyncOperation );
  293. bool ServerPing( const ns_address &netAdrPublic, IMatchAsyncOperationCallback *pCallback, IMatchAsyncOperation **ppAsyncOperation );
  294. struct ReservationResponseReply_t
  295. {
  296. ReservationResponseReply_t() { m_uiResponse = 0; m_bValveDS = false; m_numGameSlots = 0; }
  297. ns_address m_adrFrom;
  298. uint8 m_uiResponse;
  299. bool m_bValveDS;
  300. uint32 m_numGameSlots;
  301. };
  302. virtual void HandleReservationResponse( const ReservationResponseReply_t &reply );
  303. virtual void HandleReserveServerChallengeResponse( int nChallengeNr );
  304. virtual void SetServerReservationCookie( uint64 nReservationCookie ) { m_nServerReservationCookie = nReservationCookie; }
  305. static ClientClass* FindClientClass(const char *pClassName);
  306. CClockDriftMgr& GetClockDriftMgr();
  307. int GetClientTickCount() const; // Get the client tick count.
  308. void SetClientTickCount( int tick );
  309. int GetServerTickCount() const;
  310. void SetServerTickCount( int tick );
  311. void SetClientAndServerTickCount( int tick );
  312. INetworkStringTable *GetStringTable( const char * name ) const;
  313. PackedEntity *GetEntityBaseline( int iBaseline, int nEntityIndex );
  314. void SetEntityBaseline(int iBaseline, ClientClass *pClientClass, int index, SerializedEntityHandle_t handle);
  315. void CopyEntityBaseline( int iFrom, int iTo );
  316. void FreeEntityBaselines();
  317. bool GetClassBaseline( int iClass, SerializedEntityHandle_t *pHandle );
  318. void UpdateInstanceBaseline( int nStringNumber );
  319. ClientClass *GetClientClass( int i );
  320. void ForceFullUpdate( char const *pchReason );
  321. void SendStringCmd(const char * command);
  322. virtual void ReadPacketEntities( CEntityReadInfo &u ) = 0;
  323. int GetViewEntity();
  324. void HandleDeferredConnection();
  325. void SetConnectionPassword( char const *pchCurrentPW );
  326. void ResetConnectionRetries();
  327. virtual bool IsClientStateTv() const { return false; }
  328. protected:
  329. bool InternalProcessStringCmd( const CNETMsg_StringCmd& msg );
  330. private:
  331. bool PrepareSteamConnectResponse( uint64 unGSSteamID, bool bGSSecure, const ns_address &adr, bf_write &msg );
  332. void SendReserveServerMsg();
  333. void SendReserveServerChallenge();
  334. void BuildReserveServerPayload( bf_write &msg, int nChallengeNr );
  335. void SendReservationCheckMsg( const ns_address &netAdrPublic, uint64 nServerReservationCookie );
  336. int FindSplitPlayerSlot( int nPlayerIndex );
  337. void ConnectInternal( const char *pchPublicAddress, char const *pchPrivateAddress, int numPlayers, const char* szJoinType );
  338. void RememberIPAddressForLobby( uint64 unLobbyID, const ns_address &adrRemote );
  339. bool IsRemoteInList( char const *pchAdrCheck ) const;
  340. bool ShouldUseDirectConnectAddress( const CAddressList &list ) const;
  341. public:
  342. // Connection to server.
  343. int m_Socket; // network socket
  344. INetChannel *m_NetChannel; // Our sequenced channel to the remote server.
  345. bool m_bSplitScreenUser;
  346. unsigned int m_nChallengeNr; // connection challenge number
  347. double m_flConnectTime; // If gap of connect_time to net_time > 3000, then resend connect packet
  348. int m_nRetryNumber; // number of retry connection attempts
  349. int m_nRetryMax; // max # of retry attempts allowed
  350. // Address for actual packets (may differ from m_szRetryAddress)
  351. CAddressList m_Remote;
  352. struct DirectConnectLobby_t
  353. {
  354. DirectConnectLobby_t() : m_flEndTime( -1 ), m_unLobbyID( 0ull ) {}
  355. float m_flEndTime;
  356. ns_address m_adrRemote;
  357. uint64 m_unLobbyID;
  358. };
  359. DirectConnectLobby_t m_DirectConnectLobby;
  360. uint64 m_ListenServerSteamID;
  361. int m_nSignonState; // see SIGNONSTATE_* definitions
  362. double m_flNextCmdTime; // When can we send the next command packet?
  363. int m_nServerCount; // server identification for prespawns, must match the svs.spawncount which
  364. // is incremented on server spawning. This supercedes svs.spawn_issued, in that
  365. // we can now spend a fair amount of time sitting connected to the server
  366. // but downloading models, sounds, etc. So much time that it is possible that the
  367. // server might change levels again and, if so, we need to know that.
  368. int m_nCurrentSequence; // this is the sequence number of the current incoming packet
  369. uint64 m_ulGameServerSteamID; // Steam ID of the game server we are trying to connect to, or are connected to. Zero if unknown
  370. CClockDriftMgr m_ClockDriftMgr;
  371. int m_nDeltaTick; // last valid received snapshot (server) tick
  372. bool m_bPaused; // send over by server
  373. int m_nViewEntity; // player point of view override
  374. int m_nPlayerSlot; // own player entity index-1. skips world. Add 1 to get cl_entitites index;
  375. int m_nSplitScreenSlot;
  376. char m_szLevelName[ MAX_PATH ]; // for display on solo scoreboard
  377. char m_szLevelNameShort[ 40 ]; // removes maps/ and .bsp extension
  378. char m_szMapGroupName[ 40 ]; //the name of the map group we are currently playing in
  379. char m_szLastLevelNameShort[ 40 ]; // stores the previous value of m_szLevelNameShort when that gets cleared
  380. PublishedFileId_t m_unUGCMapFileID; // If a community map, this is the published file id
  381. int m_nMaxClients; // max clients on server
  382. int m_nNumPlayersToConnect; // number of clients to connect to server.
  383. class CAsyncOperation_ReserveServer : public IMatchAsyncOperation
  384. {
  385. public:
  386. explicit CAsyncOperation_ReserveServer( CBaseClientState *pParent ) : m_eState( AOS_RUNNING ), m_pParent( pParent )
  387. {
  388. m_numGameSlotsForReservation = 0;
  389. }
  390. virtual bool IsFinished() { return m_eState > AOS_ABORTING; }
  391. virtual AsyncOperationState_t GetState() { return m_eState; }
  392. virtual uint64 GetResult();
  393. virtual uint64 GetResultExtraInfo() { return m_numGameSlotsForReservation; }
  394. virtual void Abort() {}
  395. virtual void Release()
  396. {
  397. if ( m_pParent && m_pParent->m_pServerReservationOperation == this )
  398. {
  399. m_pParent->m_pServerReservationOperation = NULL;
  400. m_pParent->m_pServerReservationCallback = NULL;
  401. }
  402. delete this;
  403. }
  404. public:
  405. AsyncOperationState_t m_eState;
  406. ns_address m_adr;
  407. CBaseClientState *m_pParent;
  408. uint32 m_numGameSlotsForReservation;
  409. };
  410. CAsyncOperation_ReserveServer *m_pServerReservationOperation; // server reservation operation
  411. IMatchAsyncOperationCallback *m_pServerReservationCallback; // callback for pending reservation request
  412. CUtlVector< CServerMsg_CheckReservation * > m_arrSvReservationCheck;
  413. CUtlVector< CServerMsg_Ping * > m_arrSvPing;
  414. uint64 m_nServerReservationCookie; // cookie to set during reservation and provide upon connection
  415. KeyValues *m_pKVGameSettings; // game settings to request on reserved server
  416. double m_flReservationMsgSendTime; // time we last sent reservation msg
  417. int m_nReservationMsgRetryNumber; // # of times we've retried sending reservation msg
  418. CAddressList m_netadrReserveServer; // netadr of server we're trying to reserve
  419. bool m_bEnteredPassword;
  420. bool m_bWaitingForPassword;
  421. #if ENGINE_CONNECT_VIA_MMS
  422. bool m_bWaitingForServerGameDetails;
  423. #endif
  424. DeferredConnection_t m_DeferredConnection;
  425. CUtlMap< int32, byte*, int32, CDefLess< int32 > > m_mapGeneratedEncryptionKeys;
  426. PackedEntity *m_pEntityBaselines[2][MAX_EDICTS]; // storing entity baselines
  427. // This stuff manages the receiving of data tables and instantiating of client versions
  428. // of server-side classes.
  429. C_ServerClassInfo *m_pServerClasses;
  430. int m_nServerClasses;
  431. int m_nServerClassBits;
  432. char m_szEncryptionKey[STEAM_KEYSIZE];
  433. unsigned int m_iEncryptionKeySize;
  434. CNetworkStringTableContainer *m_StringTableContainer;
  435. CUtlMap< int, SerializedEntityHandle_t > m_BaselineHandles;
  436. typedef CUtlMap< uint32, CNETMsg_PlayerAvatarData_t *, int, CDefLess< uint32 > > PlayerAvatarDataMap_t;
  437. PlayerAvatarDataMap_t m_mapPlayerAvatarData;
  438. CNETMsg_PlayerAvatarData_t * AllocOwnPlayerAvatarData() const;
  439. bool m_bRestrictServerCommands; // If true, then the server is only allowed to execute commands marked with FCVAR_SERVER_CAN_EXECUTE on the client.
  440. bool m_bRestrictClientCommands; // If true, then IVEngineClient::ClientCmd is only allowed to execute commands marked with FCVAR_CLIENTCMD_CAN_EXECUTE on the client.
  441. // tracks valid reception of server info
  442. bool m_bServerInfoProcessed;
  443. int m_nServerProtocolVersion;
  444. int m_nServerInfoMsgProtocol;
  445. bool m_bServerConnectionRedirect;
  446. };
  447. inline CClockDriftMgr& CBaseClientState::GetClockDriftMgr()
  448. {
  449. return m_ClockDriftMgr;
  450. }
  451. inline void CBaseClientState::SetClientTickCount( int tick )
  452. {
  453. m_ClockDriftMgr.m_nClientTick = tick;
  454. }
  455. inline int CBaseClientState::GetClientTickCount() const
  456. {
  457. return m_ClockDriftMgr.m_nClientTick;
  458. }
  459. inline int CBaseClientState::GetServerTickCount() const
  460. {
  461. return m_ClockDriftMgr.m_nServerTick;
  462. }
  463. inline void CBaseClientState::SetServerTickCount( int tick )
  464. {
  465. m_ClockDriftMgr.m_nServerTick = tick;
  466. }
  467. inline void CBaseClientState::SetClientAndServerTickCount( int tick )
  468. {
  469. m_ClockDriftMgr.m_nServerTick = m_ClockDriftMgr.m_nClientTick = tick;
  470. }
  471. #endif // BASECLIENTSTATE_H