Team Fortress 2 Source Code as on 22/4/2020
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.

157 lines
4.6 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // CGameClient: represents a player client in a game server
  4. //
  5. //===========================================================================//
  6. #ifndef SV_CLIENT_H
  7. #define SV_CLIENT_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "const.h"
  12. #include "bitbuf.h"
  13. #include "net.h"
  14. #include "checksum_engine.h"
  15. #include "event_system.h"
  16. #include "utlvector.h"
  17. #include "bitvec.h"
  18. #include "protocol.h"
  19. #include <inetmsghandler.h>
  20. #include "baseclient.h"
  21. #include "clientframe.h"
  22. #include <soundinfo.h>
  23. //-----------------------------------------------------------------------------
  24. // Forward declarations
  25. //-----------------------------------------------------------------------------
  26. class INetChannel;
  27. class CClientFrame;
  28. class CFrameSnapshot;
  29. class CClientMsgHandler;
  30. struct edict_t;
  31. struct SoundInfo_t;
  32. class KeyValues;
  33. class CHLTVServer;
  34. class CReplayServer;
  35. class CPerClientLogoInfo;
  36. class CCommand;
  37. //-----------------------------------------------------------------------------
  38. // CGameClient: represents a player client in a game server
  39. //-----------------------------------------------------------------------------
  40. class CGameClient : public CBaseClient, public CClientFrameManager
  41. {
  42. public:
  43. CGameClient(int slot, CBaseServer *pServer);
  44. ~CGameClient();
  45. // INetMsgHandler interface
  46. void ConnectionClosing( const char *reason );
  47. void ConnectionCrashed(const char *reason);
  48. void PacketStart (int incoming_sequence, int outgoing_acknowledged);
  49. void PacketEnd( void );
  50. void FileReceived( const char *fileName, unsigned int transferID );
  51. void FileRequested(const char *fileName, unsigned int transferID );
  52. void FileDenied( const char *fileName, unsigned int transferID );
  53. void FileSent( const char *fileName, unsigned int transferID );
  54. bool ProcessConnectionlessPacket( netpacket_t *packet );
  55. // IClient interface
  56. void Connect( const char * szName, int nUserID, INetChannel *pNetChannel, bool bFakePlayer, int clientChallenge );
  57. void Inactivate( void );
  58. void Reconnect( void );
  59. void Disconnect( PRINTF_FORMAT_STRING const char *reason, ... );
  60. void SetRate( int nRate, bool bForce );
  61. void SetUpdateRate( int nUpdateRate, bool bForce );
  62. virtual bool IsHearingClient( int index ) const;
  63. virtual bool IsProximityHearingClient( int index ) const;
  64. void Clear( void );
  65. bool SendNetMsg(INetMessage &msg, bool bForceReliable = false);
  66. bool ExecuteStringCommand( const char *s );
  67. public: // IClientMessageHandlers
  68. PROCESS_CLC_MESSAGE( ClientInfo );
  69. PROCESS_CLC_MESSAGE( Move );
  70. PROCESS_CLC_MESSAGE( VoiceData );
  71. PROCESS_CLC_MESSAGE( RespondCvarValue );
  72. PROCESS_CLC_MESSAGE( FileCRCCheck );
  73. PROCESS_CLC_MESSAGE( FileMD5Check );
  74. #if defined( REPLAY_ENABLED )
  75. PROCESS_CLC_MESSAGE( SaveReplay );
  76. #endif
  77. PROCESS_CLC_MESSAGE( CmdKeyValues );
  78. public:
  79. void UpdateUserSettings( void );
  80. bool UpdateAcknowledgedFramecount(int tick);
  81. void WriteGameSounds( bf_write &buf );
  82. bool SetSignonState(int state, int spawncount);
  83. void SendSnapshot( CClientFrame *pFrame );
  84. bool ShouldSendMessages( void );
  85. bool CheckConnect( void );
  86. void SpawnPlayer( void );
  87. bool SendSignonData( void );
  88. void ActivatePlayer( void );
  89. void SetupPackInfo( CFrameSnapshot *pSnapshot );
  90. void SetupPrevPackInfo();
  91. void DownloadCustomizations();
  92. void WriteViewAngleUpdate( void );
  93. CClientFrame *GetDeltaFrame( int nTick );
  94. CClientFrame *GetSendFrame();
  95. void SendSound( SoundInfo_t &sound, bool isReliable );
  96. void GetReplayData( int& ticks, int& entity);
  97. bool IgnoreTempEntity( CEventInfo *event );
  98. const CCheckTransmitInfo* GetPrevPackInfo();
  99. private:
  100. bool IsEngineClientCommand( const CCommand &args ) const;
  101. int FillSoundsMessage( SVC_Sounds &msg );
  102. public:
  103. bool m_bVoiceLoopback; // if true, client wants own voice loopback
  104. CBitVec< ABSOLUTE_PLAYER_LIMIT > m_VoiceStreams; // Which other clients does this guy's voice stream go to?
  105. CBitVec< ABSOLUTE_PLAYER_LIMIT > m_VoiceProximity; // Should we use proximity for this guy?
  106. int m_LastMovementTick; // for move commands
  107. int m_nSoundSequence; // increases with each reliable sound
  108. // Identity information.
  109. edict_t *edict; // EDICT_NUM(clientnum+1)
  110. CUtlVector<SoundInfo_t> m_Sounds; // game sounds
  111. const edict_t *m_pViewEntity; // View Entity (camera or the client itself)
  112. CClientFrame *m_pCurrentFrame; // last added frame
  113. CCheckTransmitInfo m_PackInfo;
  114. bool m_bIsInReplayMode;
  115. CCheckTransmitInfo m_PrevPackInfo; // Used to speed up CheckTransmit.
  116. CBitVec<MAX_EDICTS> m_PrevTransmitEdict;
  117. #if defined( REPLAY_ENABLED )
  118. float m_flLastSaveReplayTime;
  119. #endif
  120. };
  121. #endif // SV_CLIENT_H