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.

105 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: steam state machine that handles authenticating steam users
  4. //
  5. //=============================================================================//
  6. #ifndef STEAMUAUTHSERVER_H
  7. #define STEAMUAUTHSERVER_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "baseclient.h"
  12. #include "utlvector.h"
  13. #include "netadr.h"
  14. #include "utlstring.h"
  15. #include "steam/steam_gameserver.h"
  16. class CSteam3Server : public CSteamGameServerAPIContext
  17. {
  18. public:
  19. CSteam3Server();
  20. ~CSteam3Server();
  21. #if !defined(NO_STEAM)
  22. STEAM_GAMESERVER_CALLBACK( CSteam3Server, OnLogonSuccess, SteamServersConnected_t, m_CallbackLogonSuccess );
  23. STEAM_GAMESERVER_CALLBACK( CSteam3Server, OnLogonFailure, SteamServerConnectFailure_t, m_CallbackLogonFailure );
  24. STEAM_GAMESERVER_CALLBACK( CSteam3Server, OnLoggedOff, SteamServersDisconnected_t, m_CallbackLoggedOff );
  25. // game server callbacks
  26. STEAM_GAMESERVER_CALLBACK( CSteam3Server, OnGSPolicyResponse, GSPolicyResponse_t, m_CallbackGSPolicyResponse );
  27. STEAM_GAMESERVER_CALLBACK( CSteam3Server, OnValidateAuthTicketResponse, ValidateAuthTicketResponse_t, m_CallbackValidateAuthTicketResponse );
  28. #endif
  29. // CSteam3 stuff
  30. void Activate();
  31. void NotifyOfLevelChange();
  32. void NotifyOfServerNameChange();
  33. void SendUpdatedServerDetails();
  34. void DeactivateAndLogoff();
  35. void Shutdown();
  36. bool NotifyClientConnect( CBaseClient *client, uint32 unUserID, const ns_address & adr, const void *pvCookie, uint32 ucbCookie );
  37. bool NotifyLocalClientConnect( CBaseClient *client ); // Used for local player on listen server and bots.
  38. void NotifyClientDisconnect( CBaseClient *client );
  39. void RunFrame();
  40. bool BSecure() { return SteamGameServer() && SteamGameServer()->BSecure(); }
  41. bool BIsActive() { return SteamGameServer() && ( m_eServerMode >= eServerModeNoAuthentication ); }
  42. bool BLanOnly() const { return m_eServerMode == eServerModeNoAuthentication; }
  43. bool BWantsSecure() { return m_eServerMode == eServerModeAuthenticationAndSecure; }
  44. bool BLoggedOn() { return SteamGameServer() && SteamGameServer()->BLoggedOn(); }
  45. bool CompareUserID( const USERID_t & id1, const USERID_t & id2 );
  46. const CSteamID& GetGSSteamID() const;
  47. bool BHasLogonResult() const { return m_bLogOnResult; }
  48. uint16 GetQueryPort() const { return m_QueryPort; }
  49. // Fetch public IP. Might return 0 if we don't know
  50. uint32 GetPublicIP() { return SteamGameServer() ? SteamGameServer()->GetPublicIP() : 0; }
  51. bool IsMasterServerUpdaterSharingGameSocket();
  52. /// Select Steam account name / password to use
  53. void SetAccount( const char *pszToken )
  54. {
  55. m_sAccountToken = pszToken;
  56. }
  57. /// What account name was selected?
  58. const char *GetAccountToken() const { return m_sAccountToken.String(); }
  59. private:
  60. bool CheckForDuplicateSteamID( const CBaseClient *client );
  61. CBaseClient *ClientFindFromSteamID( CSteamID & steamIDFind );
  62. void OnValidateAuthTicketResponseHelper( CBaseClient *cl, EAuthSessionResponse eAuthSessionResponse );
  63. void OnInvalidSteamLogonErrorForClient( CBaseClient *cl );
  64. EServerMode GetCurrentServerMode();
  65. EServerMode m_eServerMode;
  66. bool m_bMasterServerUpdaterSharingGameSocket;
  67. bool m_bLogOnFinished;
  68. bool m_bLoggedOn;
  69. bool m_bLogOnResult; // if true, show logon result
  70. bool m_bHasActivePlayers; // player stats updates are only sent if active players are available
  71. CSteamID m_SteamIDGS;
  72. CSteamID m_steamIDLanOnly;
  73. bool m_bActive;
  74. bool m_bWantsSecure;
  75. bool m_bInitialized;
  76. // The port that we are listening for queries on.
  77. uint32 m_unIP;
  78. uint16 m_usPort;
  79. uint16 m_QueryPort;
  80. CUtlString m_sAccountToken;
  81. };
  82. // singleton accessor
  83. CSteam3Server &Steam3Server();
  84. #endif