public/steam/isteamgameserver.h
author Nicholas Hastings <nshastings@gmail.com>
Sun Nov 03 09:37:43 2013 -0500 (2013-11-03)
changeset 29 e827f56d0c8f
permissions -rw-r--r--
Recompile linux and mac tier1.
[email protected]
     1
//========= Copyright Valve Corporation, All rights reserved. ============//
[email protected]
     2
//
[email protected]
     3
// Purpose: interface to steam for game servers
[email protected]
     4
//
[email protected]
     5
//=============================================================================
[email protected]
     6
[email protected]
     7
#ifndef ISTEAMGAMESERVER_H
[email protected]
     8
#define ISTEAMGAMESERVER_H
[email protected]
     9
#ifdef _WIN32
[email protected]
    10
#pragma once
[email protected]
    11
#endif
[email protected]
    12
[email protected]
    13
#include "isteamclient.h"
[email protected]
    14
[email protected]
    15
#define MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE	((uint16)-1)
[email protected]
    16
[email protected]
    17
//-----------------------------------------------------------------------------
[email protected]
    18
// Purpose: Functions for authenticating users via Steam to play on a game server
[email protected]
    19
//-----------------------------------------------------------------------------
[email protected]
    20
class ISteamGameServer
[email protected]
    21
{
[email protected]
    22
public:
[email protected]
    23
[email protected]
    24
//
[email protected]
    25
// Basic server data.  These properties, if set, must be set before before calling LogOn.  They
[email protected]
    26
// may not be changed after logged in.
[email protected]
    27
//
[email protected]
    28
[email protected]
    29
	/// This is called by SteamGameServer_Init, and you will usually not need to call it directly
[email protected]
    30
	virtual bool InitGameServer( uint32 unIP, uint16 usGamePort, uint16 usQueryPort, uint32 unFlags, AppId_t nGameAppId, const char *pchVersionString ) = 0;
[email protected]
    31
[email protected]
    32
	/// Game product identifier.  This is currently used by the master server for version checking purposes.
[email protected]
    33
	/// It's a required field, but will eventually will go away, and the AppID will be used for this purpose.
[email protected]
    34
	virtual void SetProduct( const char *pszProduct ) = 0;
[email protected]
    35
[email protected]
    36
	/// Description of the game.  This is a required field and is displayed in the steam server browser....for now.
[email protected]
    37
	/// This is a required field, but it will go away eventually, as the data should be determined from the AppID.
[email protected]
    38
	virtual void SetGameDescription( const char *pszGameDescription ) = 0;
[email protected]
    39
[email protected]
    40
	/// If your game is a "mod," pass the string that identifies it.  The default is an empty string, meaning
[email protected]
    41
	/// this application is the original game, not a mod.
[email protected]
    42
	///
[email protected]
    43
	/// @see k_cbMaxGameServerGameDir
[email protected]
    44
	virtual void SetModDir( const char *pszModDir ) = 0;
[email protected]
    45
[email protected]
    46
	/// Is this is a dedicated server?  The default value is false.
[email protected]
    47
	virtual void SetDedicatedServer( bool bDedicated ) = 0;
[email protected]
    48
[email protected]
    49
//
[email protected]
    50
// Login
[email protected]
    51
//
[email protected]
    52
[email protected]
    53
	/// Begin process to login to a persistent game server account
[email protected]
    54
	///
[email protected]
    55
	/// You need to register for callbacks to determine the result of this operation.
[email protected]
    56
	/// @see SteamServersConnected_t
[email protected]
    57
	/// @see SteamServerConnectFailure_t
[email protected]
    58
	/// @see SteamServersDisconnected_t
[email protected]
    59
	virtual void LogOn(
[email protected]
    60
		const char *pszAccountName,
[email protected]
    61
		const char *pszPassword
[email protected]
    62
	) = 0;
[email protected]
    63
[email protected]
    64
	/// Login to a generic, anonymous account.
[email protected]
    65
	///
[email protected]
    66
	/// Note: in previous versions of the SDK, this was automatically called within SteamGameServer_Init,
[email protected]
    67
	/// but this is no longer the case.
[email protected]
    68
	virtual void LogOnAnonymous() = 0;
[email protected]
    69
[email protected]
    70
	/// Begin process of logging game server out of steam
[email protected]
    71
	virtual void LogOff() = 0;
[email protected]
    72
	
[email protected]
    73
	// status functions
[email protected]
    74
	virtual bool BLoggedOn() = 0;
[email protected]
    75
	virtual bool BSecure() = 0; 
[email protected]
    76
	virtual CSteamID GetSteamID() = 0;
[email protected]
    77
[email protected]
    78
	/// Returns true if the master server has requested a restart.
[email protected]
    79
	/// Only returns true once per request.
[email protected]
    80
	virtual bool WasRestartRequested() = 0;
[email protected]
    81
[email protected]
    82
//
[email protected]
    83
// Server state.  These properties may be changed at any time.
[email protected]
    84
//
[email protected]
    85
[email protected]
    86
	/// Max player count that will be reported to server browser and client queries
[email protected]
    87
	virtual void SetMaxPlayerCount( int cPlayersMax ) = 0;
[email protected]
    88
[email protected]
    89
	/// Number of bots.  Default value is zero
[email protected]
    90
	virtual void SetBotPlayerCount( int cBotplayers ) = 0;
[email protected]
    91
[email protected]
    92
	/// Set the name of server as it will appear in the server browser
[email protected]
    93
	///
[email protected]
    94
	/// @see k_cbMaxGameServerName
[email protected]
    95
	virtual void SetServerName( const char *pszServerName ) = 0;
[email protected]
    96
[email protected]
    97
	/// Set name of map to report in the server browser
[email protected]
    98
	///
[email protected]
    99
	/// @see k_cbMaxGameServerName
[email protected]
   100
	virtual void SetMapName( const char *pszMapName ) = 0;
[email protected]
   101
[email protected]
   102
	/// Let people know if your server will require a password
[email protected]
   103
	virtual void SetPasswordProtected( bool bPasswordProtected ) = 0;
[email protected]
   104
[email protected]
   105
	/// Spectator server.  The default value is zero, meaning the service
[email protected]
   106
	/// is not used.
[email protected]
   107
	virtual void SetSpectatorPort( uint16 unSpectatorPort ) = 0;
[email protected]
   108
[email protected]
   109
	/// Name of the spectator server.  (Only used if spectator port is nonzero.)
[email protected]
   110
	///
[email protected]
   111
	/// @see k_cbMaxGameServerMapName
[email protected]
   112
	virtual void SetSpectatorServerName( const char *pszSpectatorServerName ) = 0;
[email protected]
   113
[email protected]
   114
	/// Call this to clear the whole list of key/values that are sent in rules queries.
[email protected]
   115
	virtual void ClearAllKeyValues() = 0;
[email protected]
   116
	
[email protected]
   117
	/// Call this to add/update a key/value pair.
[email protected]
   118
	virtual void SetKeyValue( const char *pKey, const char *pValue ) = 0;
[email protected]
   119
[email protected]
   120
	/// Sets a string defining the "gametags" for this server, this is optional, but if it is set
[email protected]
   121
	/// it allows users to filter in the matchmaking/server-browser interfaces based on the value
[email protected]
   122
	///
[email protected]
   123
	/// @see k_cbMaxGameServerTags
[email protected]
   124
	virtual void SetGameTags( const char *pchGameTags ) = 0; 
[email protected]
   125
[email protected]
   126
	/// Sets a string defining the "gamedata" for this server, this is optional, but if it is set
[email protected]
   127
	/// it allows users to filter in the matchmaking/server-browser interfaces based on the value
[email protected]
   128
	/// don't set this unless it actually changes, its only uploaded to the master once (when
[email protected]
   129
	/// acknowledged)
[email protected]
   130
	///
[email protected]
   131
	/// @see k_cbMaxGameServerGameData
[email protected]
   132
	virtual void SetGameData( const char *pchGameData) = 0; 
[email protected]
   133
[email protected]
   134
	/// Region identifier.  This is an optional field, the default value is empty, meaning the "world" region
[email protected]
   135
	virtual void SetRegion( const char *pszRegion ) = 0;
[email protected]
   136
[email protected]
   137
//
[email protected]
   138
// Player list management / authentication
[email protected]
   139
//
[email protected]
   140
[email protected]
   141
	// Handles receiving a new connection from a Steam user.  This call will ask the Steam
[email protected]
   142
	// servers to validate the users identity, app ownership, and VAC status.  If the Steam servers 
[email protected]
   143
	// are off-line, then it will validate the cached ticket itself which will validate app ownership 
[email protected]
   144
	// and identity.  The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection()
[email protected]
   145
	// and must then be sent up to the game server for authentication.
[email protected]
   146
	//
[email protected]
   147
	// Return Value: returns true if the users ticket passes basic checks. pSteamIDUser will contain the Steam ID of this user. pSteamIDUser must NOT be NULL
[email protected]
   148
	// If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication
[email protected]
   149
	// for the user has succeeded or failed (the steamid in the callback will match the one returned by this call)
[email protected]
   150
	virtual bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser ) = 0;
[email protected]
   151
[email protected]
   152
	// Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.  
[email protected]
   153
	// 
[email protected]
   154
	// Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect()
[email protected]
   155
	// when this user leaves the server just like you would for a real user.
[email protected]
   156
	virtual CSteamID CreateUnauthenticatedUserConnection() = 0;
[email protected]
   157
[email protected]
   158
	// Should be called whenever a user leaves our game server, this lets Steam internally
[email protected]
   159
	// track which users are currently on which servers for the purposes of preventing a single
[email protected]
   160
	// account being logged into multiple servers, showing who is currently on a server, etc.
[email protected]
   161
	virtual void SendUserDisconnect( CSteamID steamIDUser ) = 0;
[email protected]
   162
[email protected]
   163
	// Update the data to be displayed in the server browser and matchmaking interfaces for a user
[email protected]
   164
	// currently connected to the server.  For regular users you must call this after you receive a
[email protected]
   165
	// GSUserValidationSuccess callback.
[email protected]
   166
	// 
[email protected]
   167
	// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
[email protected]
   168
	virtual bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) = 0;
[email protected]
   169
[email protected]
   170
	// New auth system APIs - do not mix with the old auth system APIs.
[email protected]
   171
	// ----------------------------------------------------------------
[email protected]
   172
[email protected]
   173
	// Retrieve ticket to be sent to the entity who wishes to authenticate you ( using BeginAuthSession API ). 
[email protected]
   174
	// pcbTicket retrieves the length of the actual ticket.
[email protected]
   175
	virtual HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0;
[email protected]
   176
[email protected]
   177
	// Authenticate ticket ( from GetAuthSessionTicket ) from entity steamID to be sure it is valid and isnt reused
[email protected]
   178
	// Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )
[email protected]
   179
	virtual EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID ) = 0;
[email protected]
   180
[email protected]
   181
	// Stop tracking started by BeginAuthSession - called when no longer playing game with this entity
[email protected]
   182
	virtual void EndAuthSession( CSteamID steamID ) = 0;
[email protected]
   183
[email protected]
   184
	// Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to
[email protected]
   185
	virtual void CancelAuthTicket( HAuthTicket hAuthTicket ) = 0;
[email protected]
   186
[email protected]
   187
	// After receiving a user's authentication data, and passing it to SendUserConnectAndAuthenticate, use this function
[email protected]
   188
	// to determine if the user owns downloadable content specified by the provided AppID.
[email protected]
   189
	virtual EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) = 0;
[email protected]
   190
[email protected]
   191
	// Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t
[email protected]
   192
	// returns false if we're not connected to the steam servers and thus cannot ask
[email protected]
   193
	virtual bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup ) = 0;
[email protected]
   194
[email protected]
   195
//
[email protected]
   196
// Query steam for server data
[email protected]
   197
//
[email protected]
   198
[email protected]
   199
	// Ask for the gameplay stats for the server. Results returned in a callback
[email protected]
   200
	virtual void GetGameplayStats( ) = 0;
[email protected]
   201
[email protected]
   202
	// Gets the reputation score for the game server. This API also checks if the server or some
[email protected]
   203
	// other server on the same IP is banned from the Steam master servers.
[email protected]
   204
	virtual SteamAPICall_t GetServerReputation( ) = 0;
[email protected]
   205
[email protected]
   206
	// Returns the public IP of the server according to Steam, useful when the server is 
[email protected]
   207
	// behind NAT and you want to advertise its IP in a lobby for other clients to directly
[email protected]
   208
	// connect to
[email protected]
   209
	virtual uint32 GetPublicIP() = 0;
[email protected]
   210
[email protected]
   211
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own
[email protected]
   212
// socket to talk to the master server on, it lets the game use its socket to forward messages
[email protected]
   213
// back and forth. This prevents us from requiring server ops to open up yet another port
[email protected]
   214
// in their firewalls.
[email protected]
   215
//
[email protected]
   216
// the IP address and port should be in host order, i.e 127.0.0.1 == 0x7f000001
[email protected]
   217
	
[email protected]
   218
	// These are used when you've elected to multiplex the game server's UDP socket
[email protected]
   219
	// rather than having the master server updater use its own sockets.
[email protected]
   220
	// 
[email protected]
   221
	// Source games use this to simplify the job of the server admins, so they 
[email protected]
   222
	// don't have to open up more ports on their firewalls.
[email protected]
   223
	
[email protected]
   224
	// Call this when a packet that starts with 0xFFFFFFFF comes in. That means
[email protected]
   225
	// it's for us.
[email protected]
   226
	virtual bool HandleIncomingPacket( const void *pData, int cbData, uint32 srcIP, uint16 srcPort ) = 0;
[email protected]
   227
[email protected]
   228
	// AFTER calling HandleIncomingPacket for any packets that came in that frame, call this.
[email protected]
   229
	// This gets a packet that the master server updater needs to send out on UDP.
[email protected]
   230
	// It returns the length of the packet it wants to send, or 0 if there are no more packets to send.
[email protected]
   231
	// Call this each frame until it returns 0.
[email protected]
   232
	virtual int GetNextOutgoingPacket( void *pOut, int cbMaxOut, uint32 *pNetAdr, uint16 *pPort ) = 0;
[email protected]
   233
[email protected]
   234
//
[email protected]
   235
// Control heartbeats / advertisement with master server
[email protected]
   236
//
[email protected]
   237
[email protected]
   238
	// Call this as often as you like to tell the master server updater whether or not
[email protected]
   239
	// you want it to be active (default: off).
[email protected]
   240
	virtual void EnableHeartbeats( bool bActive ) = 0;
[email protected]
   241
[email protected]
   242
	// You usually don't need to modify this.
[email protected]
   243
	// Pass -1 to use the default value for iHeartbeatInterval.
[email protected]
   244
	// Some mods change this.
[email protected]
   245
	virtual void SetHeartbeatInterval( int iHeartbeatInterval ) = 0;
[email protected]
   246
[email protected]
   247
	// Force a heartbeat to steam at the next opportunity
[email protected]
   248
	virtual void ForceHeartbeat() = 0;
[email protected]
   249
[email protected]
   250
	// associate this game server with this clan for the purposes of computing player compat
[email protected]
   251
	virtual SteamAPICall_t AssociateWithClan( CSteamID steamIDClan ) = 0;
[email protected]
   252
	
[email protected]
   253
	// ask if any of the current players dont want to play with this new player - or vice versa
[email protected]
   254
	virtual SteamAPICall_t ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer ) = 0;
[email protected]
   255
[email protected]
   256
};
[email protected]
   257
[email protected]
   258
#define STEAMGAMESERVER_INTERFACE_VERSION "SteamGameServer011"
[email protected]
   259
[email protected]
   260
// game server flags
[email protected]
   261
const uint32 k_unServerFlagNone			= 0x00;
[email protected]
   262
const uint32 k_unServerFlagActive		= 0x01;		// server has users playing
[email protected]
   263
const uint32 k_unServerFlagSecure		= 0x02;		// server wants to be secure
[email protected]
   264
const uint32 k_unServerFlagDedicated	= 0x04;		// server is dedicated
[email protected]
   265
const uint32 k_unServerFlagLinux		= 0x08;		// linux build
[email protected]
   266
const uint32 k_unServerFlagPassworded	= 0x10;		// password protected
[email protected]
   267
const uint32 k_unServerFlagPrivate		= 0x20;		// server shouldn't list on master server and
[email protected]
   268
													// won't enforce authentication of users that connect to the server.
[email protected]
   269
													// Useful when you run a server where the clients may not
[email protected]
   270
													// be connected to the internet but you want them to play (i.e LANs)
[email protected]
   271
[email protected]
   272
[email protected]
   273
// callbacks
[email protected]
   274
#if defined( VALVE_CALLBACK_PACK_SMALL )
[email protected]
   275
#pragma pack( push, 4 )
[email protected]
   276
#elif defined( VALVE_CALLBACK_PACK_LARGE )
[email protected]
   277
#pragma pack( push, 8 )
[email protected]
   278
#else
[email protected]
   279
#error isteamclient.h must be included
[email protected]
   280
#endif 
[email protected]
   281
[email protected]
   282
[email protected]
   283
// client has been approved to connect to this game server
[email protected]
   284
struct GSClientApprove_t
[email protected]
   285
{
[email protected]
   286
	enum { k_iCallback = k_iSteamGameServerCallbacks + 1 };
[email protected]
   287
	CSteamID m_SteamID;
[email protected]
   288
};
[email protected]
   289
[email protected]
   290
[email protected]
   291
// client has been denied to connection to this game server
[email protected]
   292
struct GSClientDeny_t
[email protected]
   293
{
[email protected]
   294
	enum { k_iCallback = k_iSteamGameServerCallbacks + 2 };
[email protected]
   295
	CSteamID m_SteamID;
[email protected]
   296
	EDenyReason m_eDenyReason;
[email protected]
   297
	char m_rgchOptionalText[128];
[email protected]
   298
};
[email protected]
   299
[email protected]
   300
[email protected]
   301
// request the game server should kick the user
[email protected]
   302
struct GSClientKick_t
[email protected]
   303
{
[email protected]
   304
	enum { k_iCallback = k_iSteamGameServerCallbacks + 3 };
[email protected]
   305
	CSteamID m_SteamID;
[email protected]
   306
	EDenyReason m_eDenyReason;
[email protected]
   307
};
[email protected]
   308
[email protected]
   309
// NOTE: callback values 4 and 5 are skipped because they are used for old deprecated callbacks, 
[email protected]
   310
// do not reuse them here.
[email protected]
   311
[email protected]
   312
[email protected]
   313
// client achievement info
[email protected]
   314
struct GSClientAchievementStatus_t
[email protected]
   315
{
[email protected]
   316
	enum { k_iCallback = k_iSteamGameServerCallbacks + 6 };
[email protected]
   317
	uint64 m_SteamID;
[email protected]
   318
	char m_pchAchievement[128];
[email protected]
   319
	bool m_bUnlocked;
[email protected]
   320
};
[email protected]
   321
[email protected]
   322
// received when the game server requests to be displayed as secure (VAC protected)
[email protected]
   323
// m_bSecure is true if the game server should display itself as secure to users, false otherwise
[email protected]
   324
struct GSPolicyResponse_t
[email protected]
   325
{
[email protected]
   326
	enum { k_iCallback = k_iSteamUserCallbacks + 15 };
[email protected]
   327
	uint8 m_bSecure;
[email protected]
   328
};
[email protected]
   329
[email protected]
   330
// GS gameplay stats info
[email protected]
   331
struct GSGameplayStats_t
[email protected]
   332
{
[email protected]
   333
	enum { k_iCallback = k_iSteamGameServerCallbacks + 7 };
[email protected]
   334
	EResult m_eResult;					// Result of the call
[email protected]
   335
	int32	m_nRank;					// Overall rank of the server (0-based)
[email protected]
   336
	uint32	m_unTotalConnects;			// Total number of clients who have ever connected to the server
[email protected]
   337
	uint32	m_unTotalMinutesPlayed;		// Total number of minutes ever played on the server
[email protected]
   338
};
[email protected]
   339
[email protected]
   340
// send as a reply to RequestUserGroupStatus()
[email protected]
   341
struct GSClientGroupStatus_t
[email protected]
   342
{
[email protected]
   343
	enum { k_iCallback = k_iSteamGameServerCallbacks + 8 };
[email protected]
   344
	CSteamID m_SteamIDUser;
[email protected]
   345
	CSteamID m_SteamIDGroup;
[email protected]
   346
	bool m_bMember;
[email protected]
   347
	bool m_bOfficer;
[email protected]
   348
};
[email protected]
   349
[email protected]
   350
// Sent as a reply to GetServerReputation()
[email protected]
   351
struct GSReputation_t
[email protected]
   352
{
[email protected]
   353
	enum { k_iCallback = k_iSteamGameServerCallbacks + 9 };
[email protected]
   354
	EResult	m_eResult;				// Result of the call;
[email protected]
   355
	uint32	m_unReputationScore;	// The reputation score for the game server
[email protected]
   356
	bool	m_bBanned;				// True if the server is banned from the Steam
[email protected]
   357
									// master servers
[email protected]
   358
[email protected]
   359
	// The following members are only filled out if m_bBanned is true. They will all 
[email protected]
   360
	// be set to zero otherwise. Master server bans are by IP so it is possible to be
[email protected]
   361
	// banned even when the score is good high if there is a bad server on another port.
[email protected]
   362
	// This information can be used to determine which server is bad.
[email protected]
   363
[email protected]
   364
	uint32	m_unBannedIP;		// The IP of the banned server
[email protected]
   365
	uint16	m_usBannedPort;		// The port of the banned server
[email protected]
   366
	uint64	m_ulBannedGameID;	// The game ID the banned server is serving
[email protected]
   367
	uint32	m_unBanExpires;		// Time the ban expires, expressed in the Unix epoch (seconds since 1/1/1970)
[email protected]
   368
};
[email protected]
   369
[email protected]
   370
// Sent as a reply to AssociateWithClan()
[email protected]
   371
struct AssociateWithClanResult_t
[email protected]
   372
{
[email protected]
   373
	enum { k_iCallback = k_iSteamGameServerCallbacks + 10 };
[email protected]
   374
	EResult	m_eResult;				// Result of the call;
[email protected]
   375
};
[email protected]
   376
[email protected]
   377
// Sent as a reply to ComputeNewPlayerCompatibility()
[email protected]
   378
struct ComputeNewPlayerCompatibilityResult_t
[email protected]
   379
{
[email protected]
   380
	enum { k_iCallback = k_iSteamGameServerCallbacks + 11 };
[email protected]
   381
	EResult	m_eResult;				// Result of the call;
[email protected]
   382
	int m_cPlayersThatDontLikeCandidate;
[email protected]
   383
	int m_cPlayersThatCandidateDoesntLike;
[email protected]
   384
	int m_cClanPlayersThatDontLikeCandidate;
[email protected]
   385
	CSteamID m_SteamIDCandidate;
[email protected]
   386
};
[email protected]
   387
[email protected]
   388
[email protected]
   389
#pragma pack( pop )
[email protected]
   390
[email protected]
   391
#endif // ISTEAMGAMESERVER_H