mirror of
https://gitlab.com/Mr_Goldberg/goldberg_emulator.git
synced 2024-12-17 22:06:47 +01:00
195 lines
11 KiB
C
195 lines
11 KiB
C
|
|
||
|
#ifndef ISTEAMMATCHMAKING007_H
|
||
|
#define ISTEAMMATCHMAKING007_H
|
||
|
#ifdef STEAM_WIN32
|
||
|
#pragma once
|
||
|
#endif
|
||
|
|
||
|
//-----------------------------------------------------------------------------
|
||
|
// Purpose: Functions for match making services for clients to get to favorites
|
||
|
// and to operate on game lobbies.
|
||
|
//-----------------------------------------------------------------------------
|
||
|
class ISteamMatchmaking007
|
||
|
{
|
||
|
public:
|
||
|
// game server favorites storage
|
||
|
// saves basic details about a multiplayer game server locally
|
||
|
|
||
|
// returns the number of favorites servers the user has stored
|
||
|
virtual int GetFavoriteGameCount() = 0;
|
||
|
|
||
|
// returns the details of the game server
|
||
|
// iGame is of range [0,GetFavoriteGameCount())
|
||
|
// *pnIP, *pnConnPort are filled in the with IP:port of the game server
|
||
|
// *punFlags specify whether the game server was stored as an explicit favorite or in the history of connections
|
||
|
// *pRTime32LastPlayedOnServer is filled in the with the Unix time the favorite was added
|
||
|
virtual bool GetFavoriteGame( int iGame, AppId_t *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint16 *pnQueryPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ) = 0;
|
||
|
|
||
|
// adds the game server to the local list; updates the time played of the server if it already exists in the list
|
||
|
virtual int AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) =0;
|
||
|
|
||
|
// removes the game server from the local storage; returns true if one was removed
|
||
|
virtual bool RemoveFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags ) = 0;
|
||
|
|
||
|
///////
|
||
|
// Game lobby functions
|
||
|
|
||
|
// Get a list of relevant lobbies
|
||
|
// this is an asynchronous request
|
||
|
// results will be returned by LobbyMatchList_t callback & call result, with the number of lobbies found
|
||
|
// this will never return lobbies that are full
|
||
|
// to add more filter, the filter calls below need to be call before each and every RequestLobbyList() call
|
||
|
// use the CCallResult<> object in steam_api.h to match the SteamAPICall_t call result to a function in an object, e.g.
|
||
|
/*
|
||
|
class CMyLobbyListManager
|
||
|
{
|
||
|
CCallResult<CMyLobbyListManager, LobbyMatchList_t> m_CallResultLobbyMatchList;
|
||
|
void FindLobbies()
|
||
|
{
|
||
|
// SteamMatchmaking()->AddRequestLobbyListFilter*() functions would be called here, before RequestLobbyList()
|
||
|
SteamAPICall_t hSteamAPICall = SteamMatchmaking()->RequestLobbyList();
|
||
|
m_CallResultLobbyMatchList.Set( hSteamAPICall, this, &CMyLobbyListManager::OnLobbyMatchList );
|
||
|
}
|
||
|
|
||
|
void OnLobbyMatchList( LobbyMatchList_t *pLobbyMatchList, bool bIOFailure )
|
||
|
{
|
||
|
// lobby list has be retrieved from Steam back-end, use results
|
||
|
}
|
||
|
}
|
||
|
*/
|
||
|
//
|
||
|
virtual SteamAPICall_t RequestLobbyList() = 0;
|
||
|
// filters for lobbies
|
||
|
// this needs to be called before RequestLobbyList() to take effect
|
||
|
// these are cleared on each call to RequestLobbyList()
|
||
|
virtual void AddRequestLobbyListStringFilter( const char *pchKeyToMatch, const char *pchValueToMatch, ELobbyComparison eComparisonType ) = 0;
|
||
|
// numerical comparison
|
||
|
virtual void AddRequestLobbyListNumericalFilter( const char *pchKeyToMatch, int nValueToMatch, ELobbyComparison eComparisonType ) = 0;
|
||
|
// returns results closest to the specified value. Multiple near filters can be added, with early filters taking precedence
|
||
|
virtual void AddRequestLobbyListNearValueFilter( const char *pchKeyToMatch, int nValueToBeCloseTo ) = 0;
|
||
|
// returns only lobbies with the specified number of slots available
|
||
|
virtual void AddRequestLobbyListFilterSlotsAvailable( int nSlotsAvailable ) = 0;
|
||
|
|
||
|
// returns the CSteamID of a lobby, as retrieved by a RequestLobbyList call
|
||
|
// should only be called after a LobbyMatchList_t callback is received
|
||
|
// iLobby is of the range [0, LobbyMatchList_t::m_nLobbiesMatching)
|
||
|
// the returned CSteamID::IsValid() will be false if iLobby is out of range
|
||
|
STEAMWORKS_STRUCT_RETURN_1(CSteamID, GetLobbyByIndex, int, iLobby) /*virtual CSteamID GetLobbyByIndex( int iLobby ) = 0;*/
|
||
|
|
||
|
// Create a lobby on the Steam servers.
|
||
|
// If private, then the lobby will not be returned by any RequestLobbyList() call; the CSteamID
|
||
|
// of the lobby will need to be communicated via game channels or via InviteUserToLobby()
|
||
|
// this is an asynchronous request
|
||
|
// results will be returned by LobbyCreated_t callback and call result; lobby is joined & ready to use at this pointer
|
||
|
// a LobbyEnter_t callback will also be received (since the local user is joining their own lobby)
|
||
|
virtual SteamAPICall_t CreateLobby( ELobbyType eLobbyType, int cMaxMembers ) = 0;
|
||
|
|
||
|
// Joins an existing lobby
|
||
|
// this is an asynchronous request
|
||
|
// results will be returned by LobbyEnter_t callback & call result, check m_EChatRoomEnterResponse to see if was successful
|
||
|
// lobby metadata is available to use immediately on this call completing
|
||
|
virtual SteamAPICall_t JoinLobby( CSteamID steamIDLobby ) = 0;
|
||
|
|
||
|
// Leave a lobby; this will take effect immediately on the client side
|
||
|
// other users in the lobby will be notified by a LobbyChatUpdate_t callback
|
||
|
virtual void LeaveLobby( CSteamID steamIDLobby ) = 0;
|
||
|
|
||
|
// Invite another user to the lobby
|
||
|
// the target user will receive a LobbyInvite_t callback
|
||
|
// will return true if the invite is successfully sent, whether or not the target responds
|
||
|
// returns false if the local user is not connected to the Steam servers
|
||
|
// if the other user clicks the join link, a GameLobbyJoinRequested_t will be posted if the user is in-game,
|
||
|
// or if the game isn't running yet the game will be launched with the parameter +connect_lobby <64-bit lobby id>
|
||
|
virtual bool InviteUserToLobby( CSteamID steamIDLobby, CSteamID steamIDInvitee ) = 0;
|
||
|
|
||
|
// Lobby iteration, for viewing details of users in a lobby
|
||
|
// only accessible if the lobby user is a member of the specified lobby
|
||
|
// persona information for other lobby members (name, avatar, etc.) will be asynchronously received
|
||
|
// and accessible via ISteamFriends interface
|
||
|
|
||
|
// returns the number of users in the specified lobby
|
||
|
virtual int GetNumLobbyMembers( CSteamID steamIDLobby ) = 0;
|
||
|
// returns the CSteamID of a user in the lobby
|
||
|
// iMember is of range [0,GetNumLobbyMembers())
|
||
|
STEAMWORKS_STRUCT_RETURN_2(CSteamID, GetLobbyMemberByIndex, CSteamID, steamIDLobby, int, iMember) /*virtual CSteamID GetLobbyMemberByIndex( CSteamID steamIDLobby, int iMember ) = 0;*/
|
||
|
|
||
|
// Get data associated with this lobby
|
||
|
// takes a simple key, and returns the string associated with it
|
||
|
// "" will be returned if no value is set, or if steamIDLobby is invalid
|
||
|
virtual const char *GetLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0;
|
||
|
// Sets a key/value pair in the lobby metadata
|
||
|
// each user in the lobby will be broadcast this new value, and any new users joining will receive any existing data
|
||
|
// this can be used to set lobby names, map, etc.
|
||
|
// to reset a key, just set it to ""
|
||
|
// other users in the lobby will receive notification of the lobby data change via a LobbyDataUpdate_t callback
|
||
|
virtual bool SetLobbyData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0;
|
||
|
|
||
|
// returns the number of metadata keys set on the specified lobby
|
||
|
virtual int GetLobbyDataCount( CSteamID steamIDLobby ) = 0;
|
||
|
|
||
|
// returns a lobby metadata key/values pair by index, of range [0, GetLobbyDataCount())
|
||
|
virtual bool GetLobbyDataByIndex( CSteamID steamIDLobby, int iLobbyData, char *pchKey, int cchKeyBufferSize, char *pchValue, int cchValueBufferSize ) = 0;
|
||
|
|
||
|
// removes a metadata key from the lobby
|
||
|
virtual bool DeleteLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0;
|
||
|
|
||
|
// Gets per-user metadata for someone in this lobby
|
||
|
virtual const char *GetLobbyMemberData( CSteamID steamIDLobby, CSteamID steamIDUser, const char *pchKey ) = 0;
|
||
|
// Sets per-user metadata (for the local user implicitly)
|
||
|
virtual void SetLobbyMemberData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0;
|
||
|
|
||
|
// Broadcasts a chat message to the all the users in the lobby
|
||
|
// users in the lobby (including the local user) will receive a LobbyChatMsg_t callback
|
||
|
// returns true if the message is successfully sent
|
||
|
// pvMsgBody can be binary or text data, up to 4k
|
||
|
// if pvMsgBody is text, cubMsgBody should be strlen( text ) + 1, to include the null terminator
|
||
|
virtual bool SendLobbyChatMsg( CSteamID steamIDLobby, const void *pvMsgBody, int cubMsgBody ) = 0;
|
||
|
// Get a chat message as specified in a LobbyChatMsg_t callback
|
||
|
// iChatID is the LobbyChatMsg_t::m_iChatID value in the callback
|
||
|
// *pSteamIDUser is filled in with the CSteamID of the member
|
||
|
// *pvData is filled in with the message itself
|
||
|
// return value is the number of bytes written into the buffer
|
||
|
virtual int GetLobbyChatEntry( CSteamID steamIDLobby, int iChatID, CSteamID *pSteamIDUser, void *pvData, int cubData, EChatEntryType *peChatEntryType ) = 0;
|
||
|
|
||
|
// Refreshes metadata for a lobby you're not necessarily in right now
|
||
|
// you never do this for lobbies you're a member of, only if your
|
||
|
// this will send down all the metadata associated with a lobby
|
||
|
// this is an asynchronous call
|
||
|
// returns false if the local user is not connected to the Steam servers
|
||
|
// restart are returned by a LobbyDataUpdate_t callback
|
||
|
virtual bool RequestLobbyData( CSteamID steamIDLobby ) = 0;
|
||
|
|
||
|
// sets the game server associated with the lobby
|
||
|
// usually at this point, the users will join the specified game server
|
||
|
// either the IP/Port or the steamID of the game server has to be valid, depending on how you want the clients to be able to connect
|
||
|
virtual void SetLobbyGameServer( CSteamID steamIDLobby, uint32 unGameServerIP, uint16 unGameServerPort, CSteamID steamIDGameServer ) = 0;
|
||
|
// returns the details of a game server set in a lobby - returns false if there is no game server set, or that lobby doesn't exist
|
||
|
virtual bool GetLobbyGameServer( CSteamID steamIDLobby, uint32 *punGameServerIP, uint16 *punGameServerPort, CSteamID *psteamIDGameServer ) = 0;
|
||
|
|
||
|
// set the limit on the # of users who can join the lobby
|
||
|
virtual bool SetLobbyMemberLimit( CSteamID steamIDLobby, int cMaxMembers ) = 0;
|
||
|
// returns the current limit on the # of users who can join the lobby; returns 0 if no limit is defined
|
||
|
virtual int GetLobbyMemberLimit( CSteamID steamIDLobby ) = 0;
|
||
|
|
||
|
// updates which type of lobby it is
|
||
|
// only lobbies that are k_ELobbyTypePublic or k_ELobbyTypeInvisible, and are set to joinable, will be returned by RequestLobbyList() calls
|
||
|
virtual bool SetLobbyType( CSteamID steamIDLobby, ELobbyType eLobbyType ) = 0;
|
||
|
|
||
|
// sets whether or not a lobby is joinable - defaults to true for a new lobby
|
||
|
// if set to false, no user can join, even if they are a friend or have been invited
|
||
|
virtual bool SetLobbyJoinable( CSteamID steamIDLobby, bool bLobbyJoinable ) = 0;
|
||
|
|
||
|
// returns the current lobby owner
|
||
|
// you must be a member of the lobby to access this
|
||
|
// there always one lobby owner - if the current owner leaves, another user will become the owner
|
||
|
// it is possible (bur rare) to join a lobby just as the owner is leaving, thus entering a lobby with self as the owner
|
||
|
STEAMWORKS_STRUCT_RETURN_1(CSteamID, GetLobbyOwner, CSteamID, steamIDLobby) /*virtual CSteamID GetLobbyOwner( CSteamID steamIDLobby ) = 0;*/
|
||
|
|
||
|
// changes who the lobby owner is
|
||
|
// you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby
|
||
|
// after completion, the local user will no longer be the owner
|
||
|
virtual bool SetLobbyOwner( CSteamID steamIDLobby, CSteamID steamIDNewOwner ) = 0;
|
||
|
};
|
||
|
|
||
|
#endif // ISTEAMMATCHMAKING007_H
|