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.

111 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. //
  4. //
  5. //=============================================================================
  6. #ifndef GC_CLIENTSYSTEM_H
  7. #define GC_CLIENTSYSTEM_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #ifdef CLIENT_DLL
  12. #include "clientsteamcontext.h"
  13. #endif
  14. //=============================================================================
  15. //
  16. // Client GC System.
  17. //
  18. //=============================================================================
  19. class CGCClientSystem : public CAutoGameSystemPerFrame
  20. {
  21. DECLARE_CLASS_GAMEROOT( CGCClientSystem, CAutoGameSystem );
  22. public:
  23. // Constructor/Destructor.
  24. CGCClientSystem();
  25. ~CGCClientSystem();
  26. // Init/Shutdown.
  27. virtual void PostInit() OVERRIDE;
  28. virtual void LevelInitPreEntity() OVERRIDE;
  29. virtual void LevelShutdownPostEntity() OVERRIDE;
  30. virtual void Shutdown() OVERRIDE;
  31. // Updates. Gameservers do this at a slightly different place than clients
  32. #ifdef CLIENT_DLL
  33. virtual void Update( float frametime ) OVERRIDE;
  34. #else
  35. virtual void PreClientUpdate() OVERRIDE;
  36. #endif
  37. // Connection status
  38. bool BConnectedtoGC() const { return m_bConnectedToGC; }
  39. // GC Messages
  40. bool BSendMessage( uint32 unMsgType, const uint8 *pubData, uint32 cubData );
  41. bool BSendMessage( const GCSDK::CGCMsgBase& msg );
  42. bool BSendMessage( const GCSDK::CProtoBufMsgBase& msg );
  43. // GC SOCache
  44. GCSDK::CGCClientSharedObjectCache *GetSOCache( const CSteamID &steamID );
  45. GCSDK::CGCClientSharedObjectCache *FindOrAddSOCache( const CSteamID &steamID );
  46. // GC Client
  47. GCSDK::CGCClient *GetGCClient();
  48. // Steam
  49. #ifndef CLIENT_DLL
  50. void GameServerActivate();
  51. #endif
  52. protected:
  53. void SetupGC();
  54. virtual void InitGC();
  55. virtual void PreInitGC() {}
  56. virtual void PostInitGC() {}
  57. #ifdef CLIENT_DLL
  58. friend class CGCClientJobClientWelcome;
  59. virtual void ReceivedClientWelcome( const CMsgClientWelcome &msg );
  60. friend class CGCClientJobClientGoodbye;
  61. virtual void ReceivedClientGoodbye( const CMsgClientGoodbye &msg );
  62. #else
  63. friend class CGCClientJobServerWelcome;
  64. virtual void ReceivedServerWelcome( const CMsgServerWelcome &msg );
  65. friend class CGCClientJobServerGoodbye;
  66. virtual void ReceivedServerGoodbye( const CMsgServerGoodbye &msg );
  67. #endif
  68. void SetConnectedToGC( bool bConnected ) { m_bConnectedToGC = bConnected; }
  69. private:
  70. #ifdef CLIENT_DLL
  71. void SteamLoggedOnCallback( const SteamLoggedOnChange_t &loggedOnState );
  72. #else
  73. STEAM_GAMESERVER_CALLBACK( CGCClientSystem, OnLogonSuccess, SteamServersConnected_t, m_CallbackLogonSuccess );
  74. #endif
  75. bool m_bInittedGC;
  76. bool m_bConnectedToGC;
  77. bool m_bLoggedOn;
  78. GCSDK::CGCClient m_GCClient;
  79. double m_timeLastSendHello;
  80. void ThinkConnection();
  81. friend class CGCClientSystemJob;
  82. };
  83. void SetGCClientSystem( CGCClientSystem* pGCClientSystem );
  84. CGCClientSystem *GCClientSystem();
  85. #endif // GC_CLIENTSYSTEM_H