Add support for isteamgameserver 005-011

This commit is contained in:
Mr_Goldberg 2019-05-20 12:35:55 -04:00
parent 2b1368ccac
commit 68b8e0241a
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
10 changed files with 865 additions and 6 deletions

View File

@ -482,9 +482,33 @@ S_API HSteamUser S_CALLTYPE SteamGameServer_GetHSteamUser()
return SERVER_HSTEAMUSER;
}
S_API bool S_CALLTYPE SteamGameServer_InitSafe(uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString )
//See: SteamGameServer_Init
//S_API bool S_CALLTYPE SteamGameServer_InitSafe(uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString )
S_API bool S_CALLTYPE SteamGameServer_InitSafe( uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 unknown, EServerMode eServerMode, void *unknown1, void *unknown2, void *unknown3 )
{
return SteamInternal_GameServer_Init( unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString );
const char *pchVersionString;
EServerMode serverMode;
uint16 usQueryPort;
SteamGameServerClient();
bool logon_anon = false;
if (strcmp(old_gameserver, "SteamGameServer010") == 0 || strstr(old_gameserver, "SteamGameServer00") == old_gameserver) {
PRINT_DEBUG("Old game server init safe\n");
pchVersionString = (char *)unknown3;
memcpy(&serverMode, &unknown1, sizeof(serverMode));
memcpy(&usQueryPort, (char *)&eServerMode, sizeof(usQueryPort));
logon_anon = true;
} else {
pchVersionString = (char *)unknown1;
serverMode = eServerMode;
usQueryPort = unknown;
}
bool ret = SteamInternal_GameServer_Init( unIP, usSteamPort, usGamePort, usQueryPort, serverMode, pchVersionString );
if (logon_anon) {
get_steam_client()->steam_gameserver->LogOnAnonymous();
}
return ret;
}
S_API bool S_CALLTYPE SteamInternal_GameServer_Init( uint32 unIP, uint16 usPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString )
@ -495,9 +519,37 @@ S_API bool S_CALLTYPE SteamInternal_GameServer_Init( uint32 unIP, uint16 usPort,
return get_steam_client()->steam_gameserver->InitGameServer(unIP, usGamePort, usQueryPort, eServerMode, 0, pchVersionString);
}
S_API bool SteamGameServer_Init( uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString )
//SteamGameServer004 and before:
//S_API bool SteamGameServer_Init( uint32 unIP, uint16 usPort, uint16 usGamePort, uint16 usSpectatorPort, uint16 usQueryPort, EServerMode eServerMode, int nGameAppId, const char *pchGameDir, const char *pchVersionString );
//SteamGameServer010 and before:
//S_API bool SteamGameServer_Init( uint32 unIP, uint16 usPort, uint16 usGamePort, uint16 usSpectatorPort, uint16 usQueryPort, EServerMode eServerMode, const char *pchGameDir, const char *pchVersionString );
//SteamGameServer011 and later:
//S_API bool SteamGameServer_Init( uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString );
S_API bool SteamGameServer_Init( uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 unknown, EServerMode eServerMode, void *unknown1, void *unknown2, void *unknown3 )
{
return SteamInternal_GameServer_Init( unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString );
const char *pchVersionString;
EServerMode serverMode;
uint16 usQueryPort;
SteamGameServerClient();
bool logon_anon = false;
if (strcmp(old_gameserver, "SteamGameServer010") == 0 || strstr(old_gameserver, "SteamGameServer00") == old_gameserver) {
PRINT_DEBUG("Old game server init\n");
pchVersionString = (char *)unknown3;
memcpy(&serverMode, &unknown1, sizeof(serverMode));
memcpy(&usQueryPort, (char *)&eServerMode, sizeof(usQueryPort));
logon_anon = true;
} else {
pchVersionString = (char *)unknown1;
serverMode = eServerMode;
usQueryPort = unknown;
}
bool ret = SteamInternal_GameServer_Init( unIP, usSteamPort, usGamePort, usQueryPort, serverMode, pchVersionString );
if (logon_anon) {
get_steam_client()->steam_gameserver->LogOnAnonymous();
}
return ret;
}
S_API void SteamGameServer_Shutdown()

View File

@ -477,6 +477,26 @@ ISteamGameServer *Steam_Client::GetISteamGameServer( HSteamUser hSteamUser, HSte
PRINT_DEBUG("GetISteamGameServer %s\n", pchVersion);
if (!hSteamPipe || !hSteamUser) return NULL;
if (!server_init) return NULL;
if (strcmp(pchVersion, "SteamGameServer005") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer005 *)steam_gameserver;
} else if (strcmp(pchVersion, "SteamGameServer006") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer008 *)steam_gameserver;
} else if (strcmp(pchVersion, "SteamGameServer007") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer008 *)steam_gameserver;
} else if (strcmp(pchVersion, "SteamGameServer008") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer008 *)steam_gameserver;
} else if (strcmp(pchVersion, "SteamGameServer009") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer009 *)steam_gameserver;
} else if (strcmp(pchVersion, "SteamGameServer010") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer010 *)steam_gameserver;
} else if (strcmp(pchVersion, "SteamGameServer011") == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer011 *)steam_gameserver;
} else if (strcmp(pchVersion, STEAMGAMESERVER_INTERFACE_VERSION) == 0) {
return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver;
} else {
return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver;
}
return steam_gameserver;
}

View File

@ -55,6 +55,7 @@ bool Steam_GameServer::InitGameServer( uint32 unIP, uint16 usGamePort, uint16 us
server_data.set_query_port(usQueryPort);
server_data.set_offline(false);
if (!settings->get_local_game_id().AppID()) settings->set_game_id(CGameID(nGameAppId));
//TODO: flags should be k_unServerFlag
flags = unFlags;
policy_response_called = false;
call_servers_connected = false;
@ -123,6 +124,14 @@ void Steam_GameServer::LogOn( const char *pszToken )
logged_in = true;
}
void Steam_GameServer::LogOn(
const char *pszAccountName,
const char *pszPassword
)
{
PRINT_DEBUG("LogOn %s %s\n", pszAccountName, pszPassword);
LogOn(pszAccountName);
}
/// Login to a generic, anonymous account.
///
@ -136,6 +145,11 @@ void Steam_GameServer::LogOnAnonymous()
logged_in = true;
}
void Steam_GameServer::LogOn()
{
PRINT_DEBUG("LogOn\n");
LogOnAnonymous();
}
/// Begin process of logging game server out of steam
void Steam_GameServer::LogOff()
@ -370,6 +384,78 @@ bool Steam_GameServer::BUpdateUserData( CSteamID steamIDUser, const char *pchPla
return true;
}
// You shouldn't need to call this as it is called internally by SteamGameServer_Init() and can only be called once.
//
// To update the data in this call which may change during the servers lifetime see UpdateServerStatus() below.
//
// Input: nGameAppID - The Steam assigned AppID for the game
// unServerFlags - Any applicable combination of flags (see k_unServerFlag____ constants below)
// unGameIP - The IP Address the server is listening for client connections on (might be INADDR_ANY)
// unGamePort - The port which the server is listening for client connections on
// unSpectatorPort - the port on which spectators can join to observe the server, 0 if spectating is not supported
// usQueryPort - The port which the ISteamMasterServerUpdater API should use in order to listen for matchmaking requests
// pchGameDir - A unique string identifier for your game
// pchVersion - The current version of the server as a string like 1.0.0.0
// bLanMode - Is this a LAN only server?
//
// bugbug jmccaskey - figure out how to remove this from the API and only expose via SteamGameServer_Init... or make this actually used,
// and stop calling it in SteamGameServer_Init()?
bool Steam_GameServer::BSetServerType( uint32 unServerFlags, uint32 unGameIP, uint16 unGamePort,
uint16 unSpectatorPort, uint16 usQueryPort, const char *pchGameDir, const char *pchVersion, bool bLANMode )
{
PRINT_DEBUG("BSetServerType\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
server_data.set_ip(unGameIP);
server_data.set_port(unGamePort);
server_data.set_query_port(usQueryPort);
server_data.set_spectator_port(unSpectatorPort);
std::string version(pchVersion);
version.erase(std::remove(version.begin(), version.end(), ' '), version.end());
version.erase(std::remove(version.begin(), version.end(), '.'), version.end());
server_data.set_version(stoi(version));
//TODO?
return true;
}
// Updates server status values which shows up in the server browser and matchmaking APIs
void Steam_GameServer::UpdateServerStatus( int cPlayers, int cPlayersMax, int cBotPlayers,
const char *pchServerName, const char *pSpectatorServerName,
const char *pchMapName )
{
PRINT_DEBUG("UpdateServerStatus\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
server_data.set_num_players(cPlayers);
server_data.set_max_player_count(cPlayersMax);
server_data.set_bot_player_count(cBotPlayers);
server_data.set_server_name(pchServerName);
server_data.set_spectator_server_name(pSpectatorServerName);
server_data.set_map_name(pchMapName);
}
// This can be called if spectator goes away or comes back (passing 0 means there is no spectator server now).
void Steam_GameServer::UpdateSpectatorPort( uint16 unSpectatorPort )
{
PRINT_DEBUG("UpdateSpectatorPort\n");
SetSpectatorPort(unSpectatorPort);
}
// Sets a string defining the "gametype" for this server, this is optional, but if it is set
// it allows users to filter in the matchmaking/server-browser interfaces based on the value
void Steam_GameServer::SetGameType( const char *pchGameType )
{
PRINT_DEBUG("SetGameType\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
}
// Ask if a user has a specific achievement for this game, will get a callback on reply
bool Steam_GameServer::BGetUserAchievementStatus( CSteamID steamID, const char *pchAchievementName )
{
PRINT_DEBUG("BGetUserAchievementStatus\n");
std::lock_guard<std::recursive_mutex> lock(global_mutex);
return false;
}
// New auth system APIs - do not mix with the old auth system APIs.
// ----------------------------------------------------------------

View File

@ -28,7 +28,13 @@ struct Gameserver_Outgoing_Packet {
uint16 port;
};
class Steam_GameServer : public ISteamGameServer
class Steam_GameServer :
public ISteamGameServer005,
public ISteamGameServer008,
public ISteamGameServer009,
public ISteamGameServer010,
public ISteamGameServer011,
public ISteamGameServer
{
class Settings *settings;
class Networking *network;
@ -88,6 +94,11 @@ public:
/// @see SteamServerConnectFailure_t
/// @see SteamServersDisconnected_t
void LogOn( const char *pszToken );
void LogOn(
const char *pszAccountName,
const char *pszPassword
);
void LogOn();
/// Login to a generic, anonymous account.
///
@ -195,6 +206,40 @@ public:
// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore );
// You shouldn't need to call this as it is called internally by SteamGameServer_Init() and can only be called once.
//
// To update the data in this call which may change during the servers lifetime see UpdateServerStatus() below.
//
// Input: nGameAppID - The Steam assigned AppID for the game
// unServerFlags - Any applicable combination of flags (see k_unServerFlag____ constants below)
// unGameIP - The IP Address the server is listening for client connections on (might be INADDR_ANY)
// unGamePort - The port which the server is listening for client connections on
// unSpectatorPort - the port on which spectators can join to observe the server, 0 if spectating is not supported
// usQueryPort - The port which the ISteamMasterServerUpdater API should use in order to listen for matchmaking requests
// pchGameDir - A unique string identifier for your game
// pchVersion - The current version of the server as a string like 1.0.0.0
// bLanMode - Is this a LAN only server?
//
// bugbug jmccaskey - figure out how to remove this from the API and only expose via SteamGameServer_Init... or make this actually used,
// and stop calling it in SteamGameServer_Init()?
bool BSetServerType( uint32 unServerFlags, uint32 unGameIP, uint16 unGamePort,
uint16 unSpectatorPort, uint16 usQueryPort, const char *pchGameDir, const char *pchVersion, bool bLANMode );
// Updates server status values which shows up in the server browser and matchmaking APIs
void UpdateServerStatus( int cPlayers, int cPlayersMax, int cBotPlayers,
const char *pchServerName, const char *pSpectatorServerName,
const char *pchMapName );
// This can be called if spectator goes away or comes back (passing 0 means there is no spectator server now).
void UpdateSpectatorPort( uint16 unSpectatorPort );
// Sets a string defining the "gametype" for this server, this is optional, but if it is set
// it allows users to filter in the matchmaking/server-browser interfaces based on the value
void SetGameType( const char *pchGameType );
// Ask if a user has a specific achievement for this game, will get a callback on reply
bool BGetUserAchievementStatus( CSteamID steamID, const char *pchAchievementName );
// New auth system APIs - do not mix with the old auth system APIs.
// ----------------------------------------------------------------

View File

@ -0,0 +1,84 @@
#ifndef ISTEAMGAMESERVER005_H
#define ISTEAMGAMESERVER005_H
#ifdef STEAM_WIN32
#pragma once
#endif
class ISteamGameServer005
{
public:
// connection functions
virtual void LogOn() = 0;
virtual void LogOff() = 0;
// status functions
virtual bool BLoggedOn() = 0;
virtual bool BSecure() = 0;
virtual CSteamID GetSteamID() = 0;
// Handles receiving a new connection from a Steam user. This call will ask the Steam
// servers to validate the users identity, app ownership, and VAC status. If the Steam servers
// are off-line, then it will validate the cached ticket itself which will validate app ownership
// and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection()
// and must then be sent up to the game server for authentication.
//
// 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
// If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication
// for the user has succeeded or failed (the steamid in the callback will match the one returned by this call)
virtual bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser ) = 0;
// Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.
//
// Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect()
// when this user leaves the server just like you would for a real user.
virtual CSteamID CreateUnauthenticatedUserConnection() = 0;
// Should be called whenever a user leaves our game server, this lets Steam internally
// track which users are currently on which servers for the purposes of preventing a single
// account being logged into multiple servers, showing who is currently on a server, etc.
virtual void SendUserDisconnect( CSteamID steamIDUser ) = 0;
// Update the data to be displayed in the server browser and matchmaking interfaces for a user
// currently connected to the server. For regular users you must call this after you receive a
// GSUserValidationSuccess callback.
//
// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
virtual bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) = 0;
// You shouldn't need to call this as it is called internally by SteamGameServer_Init() and can only be called once.
//
// To update the data in this call which may change during the servers lifetime see UpdateServerStatus() below.
//
// Input: nGameAppID - The Steam assigned AppID for the game
// unServerFlags - Any applicable combination of flags (see k_unServerFlag____ constants below)
// unGameIP - The IP Address the server is listening for client connections on (might be INADDR_ANY)
// unGamePort - The port which the server is listening for client connections on
// unSpectatorPort - the port on which spectators can join to observe the server, 0 if spectating is not supported
// usQueryPort - The port which the ISteamMasterServerUpdater API should use in order to listen for matchmaking requests
// pchGameDir - A unique string identifier for your game
// pchVersion - The current version of the server as a string like 1.0.0.0
// bLanMode - Is this a LAN only server?
//
// bugbug jmccaskey - figure out how to remove this from the API and only expose via SteamGameServer_Init... or make this actually used,
// and stop calling it in SteamGameServer_Init()?
virtual bool BSetServerType( uint32 unServerFlags, uint32 unGameIP, uint16 unGamePort,
uint16 unSpectatorPort, uint16 usQueryPort, const char *pchGameDir, const char *pchVersion, bool bLANMode ) = 0;
// Updates server status values which shows up in the server browser and matchmaking APIs
virtual void UpdateServerStatus( int cPlayers, int cPlayersMax, int cBotPlayers,
const char *pchServerName, const char *pSpectatorServerName,
const char *pchMapName ) = 0;
// This can be called if spectator goes away or comes back (passing 0 means there is no spectator server now).
virtual void UpdateSpectatorPort( uint16 unSpectatorPort ) = 0;
// Sets a string defining the "gametype" for this server, this is optional, but if it is set
// it allows users to filter in the matchmaking/server-browser interfaces based on the value
virtual void SetGameType( const char *pchGameType ) = 0;
// Ask if a user has a specific achievement for this game, will get a callback on reply
virtual bool BGetUserAchievementStatus( CSteamID steamID, const char *pchAchievementName ) = 0;
};
#endif // ISTEAMGAMESERVER005_H

View File

@ -0,0 +1,96 @@
#ifndef ISTEAMGAMESERVER008_H
#define ISTEAMGAMESERVER008_H
#ifdef STEAM_WIN32
#pragma once
#endif
//same as 007 and 006
class ISteamGameServer008
{
public:
// connection functions
virtual void LogOn() = 0;
virtual void LogOff() = 0;
// status functions
virtual bool BLoggedOn() = 0;
virtual bool BSecure() = 0;
virtual CSteamID GetSteamID() = 0;
// Handles receiving a new connection from a Steam user. This call will ask the Steam
// servers to validate the users identity, app ownership, and VAC status. If the Steam servers
// are off-line, then it will validate the cached ticket itself which will validate app ownership
// and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection()
// and must then be sent up to the game server for authentication.
//
// 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
// If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication
// for the user has succeeded or failed (the steamid in the callback will match the one returned by this call)
virtual bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser ) = 0;
// Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.
//
// Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect()
// when this user leaves the server just like you would for a real user.
virtual CSteamID CreateUnauthenticatedUserConnection() = 0;
// Should be called whenever a user leaves our game server, this lets Steam internally
// track which users are currently on which servers for the purposes of preventing a single
// account being logged into multiple servers, showing who is currently on a server, etc.
virtual void SendUserDisconnect( CSteamID steamIDUser ) = 0;
// Update the data to be displayed in the server browser and matchmaking interfaces for a user
// currently connected to the server. For regular users you must call this after you receive a
// GSUserValidationSuccess callback.
//
// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
virtual bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) = 0;
// You shouldn't need to call this as it is called internally by SteamGameServer_Init() and can only be called once.
//
// To update the data in this call which may change during the servers lifetime see UpdateServerStatus() below.
//
// Input: nGameAppID - The Steam assigned AppID for the game
// unServerFlags - Any applicable combination of flags (see k_unServerFlag____ constants below)
// unGameIP - The IP Address the server is listening for client connections on (might be INADDR_ANY)
// unGamePort - The port which the server is listening for client connections on
// unSpectatorPort - the port on which spectators can join to observe the server, 0 if spectating is not supported
// usQueryPort - The port which the ISteamMasterServerUpdater API should use in order to listen for matchmaking requests
// pchGameDir - A unique string identifier for your game
// pchVersion - The current version of the server as a string like 1.0.0.0
// bLanMode - Is this a LAN only server?
//
// bugbug jmccaskey - figure out how to remove this from the API and only expose via SteamGameServer_Init... or make this actually used,
// and stop calling it in SteamGameServer_Init()?
virtual bool BSetServerType( uint32 unServerFlags, uint32 unGameIP, uint16 unGamePort,
uint16 unSpectatorPort, uint16 usQueryPort, const char *pchGameDir, const char *pchVersion, bool bLANMode ) = 0;
// Updates server status values which shows up in the server browser and matchmaking APIs
virtual void UpdateServerStatus( int cPlayers, int cPlayersMax, int cBotPlayers,
const char *pchServerName, const char *pSpectatorServerName,
const char *pchMapName ) = 0;
// This can be called if spectator goes away or comes back (passing 0 means there is no spectator server now).
virtual void UpdateSpectatorPort( uint16 unSpectatorPort ) = 0;
// Sets a string defining the "gametype" for this server, this is optional, but if it is set
// it allows users to filter in the matchmaking/server-browser interfaces based on the value
virtual void SetGameType( const char *pchGameType ) = 0;
// Ask if a user has a specific achievement for this game, will get a callback on reply
virtual bool BGetUserAchievementStatus( CSteamID steamID, const char *pchAchievementName ) = 0;
// Ask for the gameplay stats for the server. Results returned in a callback
virtual void GetGameplayStats( ) = 0;
// Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t
// returns false if we're not connected to the steam servers and thus cannot ask
virtual bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup ) = 0;
// Returns the public IP of the server according to Steam, useful when the server is
// behind NAT and you want to advertise its IP in a lobby for other clients to directly
// connect to
virtual uint32 GetPublicIP() = 0;
};
#endif // ISTEAMGAMESERVER008_H

View File

@ -0,0 +1,106 @@
#ifndef ISTEAMGAMESERVER009_H
#define ISTEAMGAMESERVER009_H
#ifdef STEAM_WIN32
#pragma once
#endif
class ISteamGameServer009
{
public:
// connection functions
virtual void LogOn() = 0;
virtual void LogOff() = 0;
// status functions
virtual bool BLoggedOn() = 0;
virtual bool BSecure() = 0;
virtual CSteamID GetSteamID() = 0;
// Handles receiving a new connection from a Steam user. This call will ask the Steam
// servers to validate the users identity, app ownership, and VAC status. If the Steam servers
// are off-line, then it will validate the cached ticket itself which will validate app ownership
// and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection()
// and must then be sent up to the game server for authentication.
//
// 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
// If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication
// for the user has succeeded or failed (the steamid in the callback will match the one returned by this call)
virtual bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser ) = 0;
// Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.
//
// Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect()
// when this user leaves the server just like you would for a real user.
virtual CSteamID CreateUnauthenticatedUserConnection() = 0;
// Should be called whenever a user leaves our game server, this lets Steam internally
// track which users are currently on which servers for the purposes of preventing a single
// account being logged into multiple servers, showing who is currently on a server, etc.
virtual void SendUserDisconnect( CSteamID steamIDUser ) = 0;
// Update the data to be displayed in the server browser and matchmaking interfaces for a user
// currently connected to the server. For regular users you must call this after you receive a
// GSUserValidationSuccess callback.
//
// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
virtual bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) = 0;
// You shouldn't need to call this as it is called internally by SteamGameServer_Init() and can only be called once.
//
// To update the data in this call which may change during the servers lifetime see UpdateServerStatus() below.
//
// Input: nGameAppID - The Steam assigned AppID for the game
// unServerFlags - Any applicable combination of flags (see k_unServerFlag____ constants below)
// unGameIP - The IP Address the server is listening for client connections on (might be INADDR_ANY)
// unGamePort - The port which the server is listening for client connections on
// unSpectatorPort - the port on which spectators can join to observe the server, 0 if spectating is not supported
// usQueryPort - The port which the ISteamMasterServerUpdater API should use in order to listen for matchmaking requests
// pchGameDir - A unique string identifier for your game
// pchVersion - The current version of the server as a string like 1.0.0.0
// bLanMode - Is this a LAN only server?
//
// bugbug jmccaskey - figure out how to remove this from the API and only expose via SteamGameServer_Init... or make this actually used,
// and stop calling it in SteamGameServer_Init()?
virtual bool BSetServerType( uint32 unServerFlags, uint32 unGameIP, uint16 unGamePort,
uint16 unSpectatorPort, uint16 usQueryPort, const char *pchGameDir, const char *pchVersion, bool bLANMode ) = 0;
// Updates server status values which shows up in the server browser and matchmaking APIs
virtual void UpdateServerStatus( int cPlayers, int cPlayersMax, int cBotPlayers,
const char *pchServerName, const char *pSpectatorServerName,
const char *pchMapName ) = 0;
// This can be called if spectator goes away or comes back (passing 0 means there is no spectator server now).
virtual void UpdateSpectatorPort( uint16 unSpectatorPort ) = 0;
// Sets a string defining the "gametype" for this server, this is optional, but if it is set
// it allows users to filter in the matchmaking/server-browser interfaces based on the value
virtual void SetGameType( const char *pchGameType ) = 0;
// Ask if a user has a specific achievement for this game, will get a callback on reply
virtual bool BGetUserAchievementStatus( CSteamID steamID, const char *pchAchievementName ) = 0;
// Ask for the gameplay stats for the server. Results returned in a callback
virtual void GetGameplayStats( ) = 0;
// Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t
// returns false if we're not connected to the steam servers and thus cannot ask
virtual bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup ) = 0;
// Returns the public IP of the server according to Steam, useful when the server is
// behind NAT and you want to advertise its IP in a lobby for other clients to directly
// connect to
virtual uint32 GetPublicIP() = 0;
// Sets a string defining the "gamedata" for this server, this is optional, but if it is set
// it allows users to filter in the matchmaking/server-browser interfaces based on the value
// don't set this unless it actually changes, its only uploaded to the master once (when
// acknowledged)
virtual void SetGameData( const char *pchGameData) = 0;
// After receiving a user's authentication data, and passing it to SendUserConnectAndAuthenticate, use this function
// to determine if the user owns downloadable content specified by the provided AppID.
virtual EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) = 0;
};
#endif // ISTEAMGAMESERVER009_H

View File

@ -0,0 +1,124 @@
#ifndef ISTEAMGAMESERVER010_H
#define ISTEAMGAMESERVER010_H
#ifdef STEAM_WIN32
#pragma once
#endif
class ISteamGameServer010
{
public:
// connection functions
virtual void LogOn() = 0;
virtual void LogOff() = 0;
// status functions
virtual bool BLoggedOn() = 0;
virtual bool BSecure() = 0;
virtual CSteamID GetSteamID() = 0;
// Handles receiving a new connection from a Steam user. This call will ask the Steam
// servers to validate the users identity, app ownership, and VAC status. If the Steam servers
// are off-line, then it will validate the cached ticket itself which will validate app ownership
// and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection()
// and must then be sent up to the game server for authentication.
//
// 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
// If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication
// for the user has succeeded or failed (the steamid in the callback will match the one returned by this call)
virtual bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser ) = 0;
// Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.
//
// Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect()
// when this user leaves the server just like you would for a real user.
virtual CSteamID CreateUnauthenticatedUserConnection() = 0;
// Should be called whenever a user leaves our game server, this lets Steam internally
// track which users are currently on which servers for the purposes of preventing a single
// account being logged into multiple servers, showing who is currently on a server, etc.
virtual void SendUserDisconnect( CSteamID steamIDUser ) = 0;
// Update the data to be displayed in the server browser and matchmaking interfaces for a user
// currently connected to the server. For regular users you must call this after you receive a
// GSUserValidationSuccess callback.
//
// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
virtual bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) = 0;
// You shouldn't need to call this as it is called internally by SteamGameServer_Init() and can only be called once.
//
// To update the data in this call which may change during the servers lifetime see UpdateServerStatus() below.
//
// Input: nGameAppID - The Steam assigned AppID for the game
// unServerFlags - Any applicable combination of flags (see k_unServerFlag____ constants below)
// unGameIP - The IP Address the server is listening for client connections on (might be INADDR_ANY)
// unGamePort - The port which the server is listening for client connections on
// unSpectatorPort - the port on which spectators can join to observe the server, 0 if spectating is not supported
// usQueryPort - The port which the ISteamMasterServerUpdater API should use in order to listen for matchmaking requests
// pchGameDir - A unique string identifier for your game
// pchVersion - The current version of the server as a string like 1.0.0.0
// bLanMode - Is this a LAN only server?
//
// bugbug jmccaskey - figure out how to remove this from the API and only expose via SteamGameServer_Init... or make this actually used,
// and stop calling it in SteamGameServer_Init()?
virtual bool BSetServerType( uint32 unServerFlags, uint32 unGameIP, uint16 unGamePort,
uint16 unSpectatorPort, uint16 usQueryPort, const char *pchGameDir, const char *pchVersion, bool bLANMode ) = 0;
// Updates server status values which shows up in the server browser and matchmaking APIs
virtual void UpdateServerStatus( int cPlayers, int cPlayersMax, int cBotPlayers,
const char *pchServerName, const char *pSpectatorServerName,
const char *pchMapName ) = 0;
// This can be called if spectator goes away or comes back (passing 0 means there is no spectator server now).
virtual void UpdateSpectatorPort( uint16 unSpectatorPort ) = 0;
// Sets a string defining the "gametags" for this server, this is optional, but if it is set
// it allows users to filter in the matchmaking/server-browser interfaces based on the value
virtual void SetGameTags( const char *pchGameTags ) = 0;
// Ask for the gameplay stats for the server. Results returned in a callback
virtual void GetGameplayStats( ) = 0;
// Gets the reputation score for the game server. This API also checks if the server or some
// other server on the same IP is banned from the Steam master servers.
virtual SteamAPICall_t GetServerReputation( ) = 0;
// Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t
// returns false if we're not connected to the steam servers and thus cannot ask
virtual bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup ) = 0;
// Returns the public IP of the server according to Steam, useful when the server is
// behind NAT and you want to advertise its IP in a lobby for other clients to directly
// connect to
virtual uint32 GetPublicIP() = 0;
// Sets a string defining the "gamedata" for this server, this is optional, but if it is set
// it allows users to filter in the matchmaking/server-browser interfaces based on the value
// don't set this unless it actually changes, its only uploaded to the master once (when
// acknowledged)
virtual void SetGameData( const char *pchGameData) = 0;
// After receiving a user's authentication data, and passing it to SendUserConnectAndAuthenticate, use this function
// to determine if the user owns downloadable content specified by the provided AppID.
virtual EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) = 0;
// New auth system APIs - do not mix with the old auth system APIs.
// ----------------------------------------------------------------
// Retrieve ticket to be sent to the entity who wishes to authenticate you ( using BeginAuthSession API ).
// pcbTicket retrieves the length of the actual ticket.
virtual HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0;
// Authenticate ticket ( from GetAuthSessionTicket ) from entity steamID to be sure it is valid and isnt reused
// Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )
virtual EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID ) = 0;
// Stop tracking started by BeginAuthSession - called when no longer playing game with this entity
virtual void EndAuthSession( CSteamID steamID ) = 0;
// Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to
virtual void CancelAuthTicket( HAuthTicket hAuthTicket ) = 0;
};
#endif // ISTEAMGAMESERVER010_H

View File

@ -0,0 +1,240 @@
#ifndef ISTEAMGAMESERVER011_H
#define ISTEAMGAMESERVER011_H
#ifdef STEAM_WIN32
#pragma once
#endif
class ISteamGameServer011
{
public:
//
// Basic server data. These properties, if set, must be set before before calling LogOn. They
// may not be changed after logged in.
//
/// This is called by SteamGameServer_Init, and you will usually not need to call it directly
virtual bool InitGameServer( uint32 unIP, uint16 usGamePort, uint16 usQueryPort, uint32 unFlags, AppId_t nGameAppId, const char *pchVersionString ) = 0;
/// Game product identifier. This is currently used by the master server for version checking purposes.
/// It's a required field, but will eventually will go away, and the AppID will be used for this purpose.
virtual void SetProduct( const char *pszProduct ) = 0;
/// Description of the game. This is a required field and is displayed in the steam server browser....for now.
/// This is a required field, but it will go away eventually, as the data should be determined from the AppID.
virtual void SetGameDescription( const char *pszGameDescription ) = 0;
/// If your game is a "mod," pass the string that identifies it. The default is an empty string, meaning
/// this application is the original game, not a mod.
///
/// @see k_cbMaxGameServerGameDir
virtual void SetModDir( const char *pszModDir ) = 0;
/// Is this is a dedicated server? The default value is false.
virtual void SetDedicatedServer( bool bDedicated ) = 0;
//
// Login
//
/// Begin process to login to a persistent game server account
///
/// You need to register for callbacks to determine the result of this operation.
/// @see SteamServersConnected_t
/// @see SteamServerConnectFailure_t
/// @see SteamServersDisconnected_t
virtual void LogOn(
const char *pszAccountName,
const char *pszPassword
) = 0;
/// Login to a generic, anonymous account.
///
/// Note: in previous versions of the SDK, this was automatically called within SteamGameServer_Init,
/// but this is no longer the case.
virtual void LogOnAnonymous() = 0;
/// Begin process of logging game server out of steam
virtual void LogOff() = 0;
// status functions
virtual bool BLoggedOn() = 0;
virtual bool BSecure() = 0;
virtual CSteamID GetSteamID() = 0;
/// Returns true if the master server has requested a restart.
/// Only returns true once per request.
virtual bool WasRestartRequested() = 0;
//
// Server state. These properties may be changed at any time.
//
/// Max player count that will be reported to server browser and client queries
virtual void SetMaxPlayerCount( int cPlayersMax ) = 0;
/// Number of bots. Default value is zero
virtual void SetBotPlayerCount( int cBotplayers ) = 0;
/// Set the name of server as it will appear in the server browser
///
/// @see k_cbMaxGameServerName
virtual void SetServerName( const char *pszServerName ) = 0;
/// Set name of map to report in the server browser
///
/// @see k_cbMaxGameServerName
virtual void SetMapName( const char *pszMapName ) = 0;
/// Let people know if your server will require a password
virtual void SetPasswordProtected( bool bPasswordProtected ) = 0;
/// Spectator server. The default value is zero, meaning the service
/// is not used.
virtual void SetSpectatorPort( uint16 unSpectatorPort ) = 0;
/// Name of the spectator server. (Only used if spectator port is nonzero.)
///
/// @see k_cbMaxGameServerMapName
virtual void SetSpectatorServerName( const char *pszSpectatorServerName ) = 0;
/// Call this to clear the whole list of key/values that are sent in rules queries.
virtual void ClearAllKeyValues() = 0;
/// Call this to add/update a key/value pair.
virtual void SetKeyValue( const char *pKey, const char *pValue ) = 0;
/// Sets a string defining the "gametags" for this server, this is optional, but if it is set
/// it allows users to filter in the matchmaking/server-browser interfaces based on the value
///
/// @see k_cbMaxGameServerTags
virtual void SetGameTags( const char *pchGameTags ) = 0;
/// Sets a string defining the "gamedata" for this server, this is optional, but if it is set
/// it allows users to filter in the matchmaking/server-browser interfaces based on the value
/// don't set this unless it actually changes, its only uploaded to the master once (when
/// acknowledged)
///
/// @see k_cbMaxGameServerGameData
virtual void SetGameData( const char *pchGameData ) = 0;
/// Region identifier. This is an optional field, the default value is empty, meaning the "world" region
virtual void SetRegion( const char *pszRegion ) = 0;
//
// Player list management / authentication
//
// Handles receiving a new connection from a Steam user. This call will ask the Steam
// servers to validate the users identity, app ownership, and VAC status. If the Steam servers
// are off-line, then it will validate the cached ticket itself which will validate app ownership
// and identity. The AuthBlob here should be acquired on the game client using SteamUser()->InitiateGameConnection()
// and must then be sent up to the game server for authentication.
//
// 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
// If the call succeeds then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication
// for the user has succeeded or failed (the steamid in the callback will match the one returned by this call)
virtual bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser ) = 0;
// Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.
//
// Return Value: Returns a SteamID for the user to be tracked with, you should call HandleUserDisconnect()
// when this user leaves the server just like you would for a real user.
virtual CSteamID CreateUnauthenticatedUserConnection() = 0;
// Should be called whenever a user leaves our game server, this lets Steam internally
// track which users are currently on which servers for the purposes of preventing a single
// account being logged into multiple servers, showing who is currently on a server, etc.
virtual void SendUserDisconnect( CSteamID steamIDUser ) = 0;
// Update the data to be displayed in the server browser and matchmaking interfaces for a user
// currently connected to the server. For regular users you must call this after you receive a
// GSUserValidationSuccess callback.
//
// Return Value: true if successful, false if failure (ie, steamIDUser wasn't for an active player)
virtual bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore ) = 0;
// New auth system APIs - do not mix with the old auth system APIs.
// ----------------------------------------------------------------
// Retrieve ticket to be sent to the entity who wishes to authenticate you ( using BeginAuthSession API ).
// pcbTicket retrieves the length of the actual ticket.
virtual HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket ) = 0;
// Authenticate ticket ( from GetAuthSessionTicket ) from entity steamID to be sure it is valid and isnt reused
// Registers for callbacks if the entity goes offline or cancels the ticket ( see ValidateAuthTicketResponse_t callback and EAuthSessionResponse )
virtual EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID ) = 0;
// Stop tracking started by BeginAuthSession - called when no longer playing game with this entity
virtual void EndAuthSession( CSteamID steamID ) = 0;
// Cancel auth ticket from GetAuthSessionTicket, called when no longer playing game with the entity you gave the ticket to
virtual void CancelAuthTicket( HAuthTicket hAuthTicket ) = 0;
// After receiving a user's authentication data, and passing it to SendUserConnectAndAuthenticate, use this function
// to determine if the user owns downloadable content specified by the provided AppID.
virtual EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID ) = 0;
// Ask if a user in in the specified group, results returns async by GSUserGroupStatus_t
// returns false if we're not connected to the steam servers and thus cannot ask
virtual bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup ) = 0;
// these two functions s are deprecated, and will not return results
// they will be removed in a future version of the SDK
virtual void GetGameplayStats( ) = 0;
virtual SteamAPICall_t GetServerReputation( ) = 0;
// Returns the public IP of the server according to Steam, useful when the server is
// behind NAT and you want to advertise its IP in a lobby for other clients to directly
// connect to
virtual uint32 GetPublicIP() = 0;
// These are in GameSocketShare mode, where instead of ISteamGameServer creating its own
// socket to talk to the master server on, it lets the game use its socket to forward messages
// back and forth. This prevents us from requiring server ops to open up yet another port
// in their firewalls.
//
// the IP address and port should be in host order, i.e 127.0.0.1 == 0x7f000001
// These are used when you've elected to multiplex the game server's UDP socket
// rather than having the master server updater use its own sockets.
//
// Source games use this to simplify the job of the server admins, so they
// don't have to open up more ports on their firewalls.
// Call this when a packet that starts with 0xFFFFFFFF comes in. That means
// it's for us.
virtual bool HandleIncomingPacket( const void *pData, int cbData, uint32 srcIP, uint16 srcPort ) = 0;
// AFTER calling HandleIncomingPacket for any packets that came in that frame, call this.
// This gets a packet that the master server updater needs to send out on UDP.
// It returns the length of the packet it wants to send, or 0 if there are no more packets to send.
// Call this each frame until it returns 0.
virtual int GetNextOutgoingPacket( void *pOut, int cbMaxOut, uint32 *pNetAdr, uint16 *pPort ) = 0;
//
// Control heartbeats / advertisement with master server
//
// Call this as often as you like to tell the master server updater whether or not
// you want it to be active (default: off).
virtual void EnableHeartbeats( bool bActive ) = 0;
// You usually don't need to modify this.
// Pass -1 to use the default value for iHeartbeatInterval.
// Some mods change this.
virtual void SetHeartbeatInterval( int iHeartbeatInterval ) = 0;
// Force a heartbeat to steam at the next opportunity
virtual void ForceHeartbeat() = 0;
// associate this game server with this clan for the purposes of computing player compat
virtual SteamAPICall_t AssociateWithClan( CSteamID steamIDClan ) = 0;
// ask if any of the current players dont want to play with this new player - or vice versa
virtual SteamAPICall_t ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer ) = 0;
};
#endif // ISTEAMGAMESERVER011_H

View File

@ -12,6 +12,11 @@
#include "steam_api.h"
#include "isteamgameserver.h"
#include "isteamgameserver011.h"
#include "isteamgameserver010.h"
#include "isteamgameserver009.h"
#include "isteamgameserver008.h"
#include "isteamgameserver005.h"
#include "isteamgameserverstats.h"
enum EServerMode
@ -40,10 +45,11 @@ enum EServerMode
// UDP packets for the master server updater. See references to GameSocketShare in isteamgameserver.h.
// - The version string is usually in the form x.x.x.x, and is used by the master server to detect when the
// server is out of date. (Only servers with the latest version will be listed.)
#ifndef STEAM_API_EXPORTS
S_API bool SteamGameServer_Init( uint32 unIP, uint16 usSteamPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString );
#endif
S_API bool S_CALLTYPE SteamInternal_GameServer_Init( uint32 unIP, uint16 usPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString );
// Shutdown SteamGameSeverXxx interfaces, log out, and free resources.
S_API void SteamGameServer_Shutdown();