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.

751 lines
38 KiB

  1. //====== Copyright © 1996-2008, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: interface to steam managing game server/client match making
  4. //
  5. //=============================================================================
  6. #ifndef ISTEAMMATCHMAKING
  7. #define ISTEAMMATCHMAKING
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "steamtypes.h"
  12. #include "steamclientpublic.h"
  13. #include "matchmakingtypes.h"
  14. #include "isteamclient.h"
  15. #include "isteamfriends.h"
  16. // lobby type description
  17. enum ELobbyType
  18. {
  19. k_ELobbyTypePrivate = 0, // only way to join the lobby is to invite to someone else
  20. k_ELobbyTypeFriendsOnly = 1, // shows for friends or invitees, but not in lobby list
  21. k_ELobbyTypePublic = 2, // visible for friends and in lobby list
  22. k_ELobbyTypeInvisible = 3, // returned by search, but not visible to other friends
  23. // useful if you want a user in two lobbies, for example matching groups together
  24. // a user can be in only one regular lobby, and up to two invisible lobbies
  25. };
  26. // lobby search filter tools
  27. enum ELobbyComparison
  28. {
  29. k_ELobbyComparisonEqualToOrLessThan = -2,
  30. k_ELobbyComparisonLessThan = -1,
  31. k_ELobbyComparisonEqual = 0,
  32. k_ELobbyComparisonGreaterThan = 1,
  33. k_ELobbyComparisonEqualToOrGreaterThan = 2,
  34. k_ELobbyComparisonNotEqual = 3,
  35. };
  36. // lobby search distance. Lobby results are sorted from closest to farthest.
  37. enum ELobbyDistanceFilter
  38. {
  39. k_ELobbyDistanceFilterClose, // only lobbies in the same immediate region will be returned
  40. k_ELobbyDistanceFilterDefault, // only lobbies in the same region or near by regions
  41. k_ELobbyDistanceFilterFar, // for games that don't have many latency requirements, will return lobbies about half-way around the globe
  42. k_ELobbyDistanceFilterWorldwide, // no filtering, will match lobbies as far as India to NY (not recommended, expect multiple seconds of latency between the clients)
  43. };
  44. // maximum number of characters a lobby metadata key can be
  45. #define k_nMaxLobbyKeyLength 255
  46. //-----------------------------------------------------------------------------
  47. // Purpose: Functions for match making services for clients to get to favorites
  48. // and to operate on game lobbies.
  49. //-----------------------------------------------------------------------------
  50. class ISteamMatchmaking
  51. {
  52. public:
  53. // game server favorites storage
  54. // saves basic details about a multiplayer game server locally
  55. // returns the number of favorites servers the user has stored
  56. virtual int GetFavoriteGameCount() = 0;
  57. // returns the details of the game server
  58. // iGame is of range [0,GetFavoriteGameCount())
  59. // *pnIP, *pnConnPort are filled in the with IP:port of the game server
  60. // *punFlags specify whether the game server was stored as an explicit favorite or in the history of connections
  61. // *pRTime32LastPlayedOnServer is filled in the with the Unix time the favorite was added
  62. virtual bool GetFavoriteGame( int iGame, AppId_t *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint16 *pnQueryPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ) = 0;
  63. // adds the game server to the local list; updates the time played of the server if it already exists in the list
  64. virtual int AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) = 0;
  65. // removes the game server from the local storage; returns true if one was removed
  66. virtual bool RemoveFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags ) = 0;
  67. ///////
  68. // Game lobby functions
  69. // Get a list of relevant lobbies
  70. // this is an asynchronous request
  71. // results will be returned by LobbyMatchList_t callback & call result, with the number of lobbies found
  72. // this will never return lobbies that are full
  73. // to add more filter, the filter calls below need to be call before each and every RequestLobbyList() call
  74. // use the CCallResult<> object in steam_api.h to match the SteamAPICall_t call result to a function in an object, e.g.
  75. /*
  76. class CMyLobbyListManager
  77. {
  78. CCallResult<CMyLobbyListManager, LobbyMatchList_t> m_CallResultLobbyMatchList;
  79. void FindLobbies()
  80. {
  81. // SteamMatchmaking()->AddRequestLobbyListFilter*() functions would be called here, before RequestLobbyList()
  82. SteamAPICall_t hSteamAPICall = SteamMatchmaking()->RequestLobbyList();
  83. m_CallResultLobbyMatchList.Set( hSteamAPICall, this, &CMyLobbyListManager::OnLobbyMatchList );
  84. }
  85. void OnLobbyMatchList( LobbyMatchList_t *pLobbyMatchList, bool bIOFailure )
  86. {
  87. // lobby list has be retrieved from Steam back-end, use results
  88. }
  89. }
  90. */
  91. //
  92. CALL_RESULT( LobbyMatchList_t )
  93. virtual SteamAPICall_t RequestLobbyList() = 0;
  94. // filters for lobbies
  95. // this needs to be called before RequestLobbyList() to take effect
  96. // these are cleared on each call to RequestLobbyList()
  97. virtual void AddRequestLobbyListStringFilter( const char *pchKeyToMatch, const char *pchValueToMatch, ELobbyComparison eComparisonType ) = 0;
  98. // numerical comparison
  99. virtual void AddRequestLobbyListNumericalFilter( const char *pchKeyToMatch, int nValueToMatch, ELobbyComparison eComparisonType ) = 0;
  100. // returns results closest to the specified value. Multiple near filters can be added, with early filters taking precedence
  101. virtual void AddRequestLobbyListNearValueFilter( const char *pchKeyToMatch, int nValueToBeCloseTo ) = 0;
  102. // returns only lobbies with the specified number of slots available
  103. virtual void AddRequestLobbyListFilterSlotsAvailable( int nSlotsAvailable ) = 0;
  104. // sets the distance for which we should search for lobbies (based on users IP address to location map on the Steam backed)
  105. virtual void AddRequestLobbyListDistanceFilter( ELobbyDistanceFilter eLobbyDistanceFilter ) = 0;
  106. // sets how many results to return, the lower the count the faster it is to download the lobby results & details to the client
  107. virtual void AddRequestLobbyListResultCountFilter( int cMaxResults ) = 0;
  108. virtual void AddRequestLobbyListCompatibleMembersFilter( CSteamID steamIDLobby ) = 0;
  109. // returns the CSteamID of a lobby, as retrieved by a RequestLobbyList call
  110. // should only be called after a LobbyMatchList_t callback is received
  111. // iLobby is of the range [0, LobbyMatchList_t::m_nLobbiesMatching)
  112. // the returned CSteamID::IsValid() will be false if iLobby is out of range
  113. virtual CSteamID GetLobbyByIndex( int iLobby ) = 0;
  114. // Create a lobby on the Steam servers.
  115. // If private, then the lobby will not be returned by any RequestLobbyList() call; the CSteamID
  116. // of the lobby will need to be communicated via game channels or via InviteUserToLobby()
  117. // this is an asynchronous request
  118. // results will be returned by LobbyCreated_t callback and call result; lobby is joined & ready to use at this point
  119. // a LobbyEnter_t callback will also be received (since the local user is joining their own lobby)
  120. CALL_RESULT( LobbyCreated_t )
  121. virtual SteamAPICall_t CreateLobby( ELobbyType eLobbyType, int cMaxMembers ) = 0;
  122. // Joins an existing lobby
  123. // this is an asynchronous request
  124. // results will be returned by LobbyEnter_t callback & call result, check m_EChatRoomEnterResponse to see if was successful
  125. // lobby metadata is available to use immediately on this call completing
  126. CALL_RESULT( LobbyEnter_t )
  127. virtual SteamAPICall_t JoinLobby( CSteamID steamIDLobby ) = 0;
  128. // Leave a lobby; this will take effect immediately on the client side
  129. // other users in the lobby will be notified by a LobbyChatUpdate_t callback
  130. virtual void LeaveLobby( CSteamID steamIDLobby ) = 0;
  131. // Invite another user to the lobby
  132. // the target user will receive a LobbyInvite_t callback
  133. // will return true if the invite is successfully sent, whether or not the target responds
  134. // returns false if the local user is not connected to the Steam servers
  135. // if the other user clicks the join link, a GameLobbyJoinRequested_t will be posted if the user is in-game,
  136. // or if the game isn't running yet the game will be launched with the parameter +connect_lobby <64-bit lobby id>
  137. virtual bool InviteUserToLobby( CSteamID steamIDLobby, CSteamID steamIDInvitee ) = 0;
  138. // Lobby iteration, for viewing details of users in a lobby
  139. // only accessible if the lobby user is a member of the specified lobby
  140. // persona information for other lobby members (name, avatar, etc.) will be asynchronously received
  141. // and accessible via ISteamFriends interface
  142. // returns the number of users in the specified lobby
  143. virtual int GetNumLobbyMembers( CSteamID steamIDLobby ) = 0;
  144. // returns the CSteamID of a user in the lobby
  145. // iMember is of range [0,GetNumLobbyMembers())
  146. // note that the current user must be in a lobby to retrieve CSteamIDs of other users in that lobby
  147. virtual CSteamID GetLobbyMemberByIndex( CSteamID steamIDLobby, int iMember ) = 0;
  148. // Get data associated with this lobby
  149. // takes a simple key, and returns the string associated with it
  150. // "" will be returned if no value is set, or if steamIDLobby is invalid
  151. virtual const char *GetLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0;
  152. // Sets a key/value pair in the lobby metadata
  153. // each user in the lobby will be broadcast this new value, and any new users joining will receive any existing data
  154. // this can be used to set lobby names, map, etc.
  155. // to reset a key, just set it to ""
  156. // other users in the lobby will receive notification of the lobby data change via a LobbyDataUpdate_t callback
  157. virtual bool SetLobbyData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0;
  158. // returns the number of metadata keys set on the specified lobby
  159. virtual int GetLobbyDataCount( CSteamID steamIDLobby ) = 0;
  160. // returns a lobby metadata key/values pair by index, of range [0, GetLobbyDataCount())
  161. virtual bool GetLobbyDataByIndex( CSteamID steamIDLobby, int iLobbyData, char *pchKey, int cchKeyBufferSize, char *pchValue, int cchValueBufferSize ) = 0;
  162. // removes a metadata key from the lobby
  163. virtual bool DeleteLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0;
  164. // Gets per-user metadata for someone in this lobby
  165. virtual const char *GetLobbyMemberData( CSteamID steamIDLobby, CSteamID steamIDUser, const char *pchKey ) = 0;
  166. // Sets per-user metadata (for the local user implicitly)
  167. virtual void SetLobbyMemberData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0;
  168. // Broadcasts a chat message to the all the users in the lobby
  169. // users in the lobby (including the local user) will receive a LobbyChatMsg_t callback
  170. // returns true if the message is successfully sent
  171. // pvMsgBody can be binary or text data, up to 4k
  172. // if pvMsgBody is text, cubMsgBody should be strlen( text ) + 1, to include the null terminator
  173. virtual bool SendLobbyChatMsg( CSteamID steamIDLobby, const void *pvMsgBody, int cubMsgBody ) = 0;
  174. // Get a chat message as specified in a LobbyChatMsg_t callback
  175. // iChatID is the LobbyChatMsg_t::m_iChatID value in the callback
  176. // *pSteamIDUser is filled in with the CSteamID of the member
  177. // *pvData is filled in with the message itself
  178. // return value is the number of bytes written into the buffer
  179. virtual int GetLobbyChatEntry( CSteamID steamIDLobby, int iChatID, OUT_STRUCT() CSteamID *pSteamIDUser, void *pvData, int cubData, EChatEntryType *peChatEntryType ) = 0;
  180. // Refreshes metadata for a lobby you're not necessarily in right now
  181. // you never do this for lobbies you're a member of, only if your
  182. // this will send down all the metadata associated with a lobby
  183. // this is an asynchronous call
  184. // returns false if the local user is not connected to the Steam servers
  185. // results will be returned by a LobbyDataUpdate_t callback
  186. // if the specified lobby doesn't exist, LobbyDataUpdate_t::m_bSuccess will be set to false
  187. virtual bool RequestLobbyData( CSteamID steamIDLobby ) = 0;
  188. // sets the game server associated with the lobby
  189. // usually at this point, the users will join the specified game server
  190. // 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
  191. virtual void SetLobbyGameServer( CSteamID steamIDLobby, uint32 unGameServerIP, uint16 unGameServerPort, CSteamID steamIDGameServer ) = 0;
  192. // 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
  193. virtual bool GetLobbyGameServer( CSteamID steamIDLobby, uint32 *punGameServerIP, uint16 *punGameServerPort, OUT_STRUCT() CSteamID *psteamIDGameServer ) = 0;
  194. // set the limit on the # of users who can join the lobby
  195. virtual bool SetLobbyMemberLimit( CSteamID steamIDLobby, int cMaxMembers ) = 0;
  196. // returns the current limit on the # of users who can join the lobby; returns 0 if no limit is defined
  197. virtual int GetLobbyMemberLimit( CSteamID steamIDLobby ) = 0;
  198. // updates which type of lobby it is
  199. // only lobbies that are k_ELobbyTypePublic or k_ELobbyTypeInvisible, and are set to joinable, will be returned by RequestLobbyList() calls
  200. virtual bool SetLobbyType( CSteamID steamIDLobby, ELobbyType eLobbyType ) = 0;
  201. // sets whether or not a lobby is joinable - defaults to true for a new lobby
  202. // if set to false, no user can join, even if they are a friend or have been invited
  203. virtual bool SetLobbyJoinable( CSteamID steamIDLobby, bool bLobbyJoinable ) = 0;
  204. // returns the current lobby owner
  205. // you must be a member of the lobby to access this
  206. // there always one lobby owner - if the current owner leaves, another user will become the owner
  207. // it is possible (bur rare) to join a lobby just as the owner is leaving, thus entering a lobby with self as the owner
  208. virtual CSteamID GetLobbyOwner( CSteamID steamIDLobby ) = 0;
  209. // changes who the lobby owner is
  210. // you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby
  211. // after completion, the local user will no longer be the owner
  212. virtual bool SetLobbyOwner( CSteamID steamIDLobby, CSteamID steamIDNewOwner ) = 0;
  213. // link two lobbies for the purposes of checking player compatibility
  214. // you must be the lobby owner of both lobbies
  215. virtual bool SetLinkedLobby( CSteamID steamIDLobby, CSteamID steamIDLobbyDependent ) = 0;
  216. #ifdef _PS3
  217. // changes who the lobby owner is
  218. // you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby
  219. // after completion, the local user will no longer be the owner
  220. virtual void CheckForPSNGameBootInvite( unsigned int iGameBootAttributes ) = 0;
  221. #endif
  222. CALL_BACK( LobbyChatUpdate_t );
  223. };
  224. #define STEAMMATCHMAKING_INTERFACE_VERSION "SteamMatchMaking009"
  225. //-----------------------------------------------------------------------------
  226. // Callback interfaces for server list functions (see ISteamMatchmakingServers below)
  227. //
  228. // The idea here is that your game code implements objects that implement these
  229. // interfaces to receive callback notifications after calling asynchronous functions
  230. // inside the ISteamMatchmakingServers() interface below.
  231. //
  232. // This is different than normal Steam callback handling due to the potentially
  233. // large size of server lists.
  234. //-----------------------------------------------------------------------------
  235. //-----------------------------------------------------------------------------
  236. // Typedef for handle type you will receive when requesting server list.
  237. //-----------------------------------------------------------------------------
  238. typedef void* HServerListRequest;
  239. //-----------------------------------------------------------------------------
  240. // Purpose: Callback interface for receiving responses after a server list refresh
  241. // or an individual server update.
  242. //
  243. // Since you get these callbacks after requesting full list refreshes you will
  244. // usually implement this interface inside an object like CServerBrowser. If that
  245. // object is getting destructed you should use ISteamMatchMakingServers()->CancelQuery()
  246. // to cancel any in-progress queries so you don't get a callback into the destructed
  247. // object and crash.
  248. //-----------------------------------------------------------------------------
  249. class ISteamMatchmakingServerListResponse
  250. {
  251. public:
  252. // Server has responded ok with updated data
  253. virtual void ServerResponded( HServerListRequest hRequest, int iServer ) = 0;
  254. // Server has failed to respond
  255. virtual void ServerFailedToRespond( HServerListRequest hRequest, int iServer ) = 0;
  256. // A list refresh you had initiated is now 100% completed
  257. virtual void RefreshComplete( HServerListRequest hRequest, EMatchMakingServerResponse response ) = 0;
  258. };
  259. //-----------------------------------------------------------------------------
  260. // Purpose: Callback interface for receiving responses after pinging an individual server
  261. //
  262. // These callbacks all occur in response to querying an individual server
  263. // via the ISteamMatchmakingServers()->PingServer() call below. If you are
  264. // destructing an object that implements this interface then you should call
  265. // ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query
  266. // which is in progress. Failure to cancel in progress queries when destructing
  267. // a callback handler may result in a crash when a callback later occurs.
  268. //-----------------------------------------------------------------------------
  269. class ISteamMatchmakingPingResponse
  270. {
  271. public:
  272. // Server has responded successfully and has updated data
  273. virtual void ServerResponded( gameserveritem_t &server ) = 0;
  274. // Server failed to respond to the ping request
  275. virtual void ServerFailedToRespond() = 0;
  276. };
  277. //-----------------------------------------------------------------------------
  278. // Purpose: Callback interface for receiving responses after requesting details on
  279. // who is playing on a particular server.
  280. //
  281. // These callbacks all occur in response to querying an individual server
  282. // via the ISteamMatchmakingServers()->PlayerDetails() call below. If you are
  283. // destructing an object that implements this interface then you should call
  284. // ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query
  285. // which is in progress. Failure to cancel in progress queries when destructing
  286. // a callback handler may result in a crash when a callback later occurs.
  287. //-----------------------------------------------------------------------------
  288. class ISteamMatchmakingPlayersResponse
  289. {
  290. public:
  291. // Got data on a new player on the server -- you'll get this callback once per player
  292. // on the server which you have requested player data on.
  293. virtual void AddPlayerToList( const char *pchName, int nScore, float flTimePlayed ) = 0;
  294. // The server failed to respond to the request for player details
  295. virtual void PlayersFailedToRespond() = 0;
  296. // The server has finished responding to the player details request
  297. // (ie, you won't get anymore AddPlayerToList callbacks)
  298. virtual void PlayersRefreshComplete() = 0;
  299. };
  300. //-----------------------------------------------------------------------------
  301. // Purpose: Callback interface for receiving responses after requesting rules
  302. // details on a particular server.
  303. //
  304. // These callbacks all occur in response to querying an individual server
  305. // via the ISteamMatchmakingServers()->ServerRules() call below. If you are
  306. // destructing an object that implements this interface then you should call
  307. // ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query
  308. // which is in progress. Failure to cancel in progress queries when destructing
  309. // a callback handler may result in a crash when a callback later occurs.
  310. //-----------------------------------------------------------------------------
  311. class ISteamMatchmakingRulesResponse
  312. {
  313. public:
  314. // Got data on a rule on the server -- you'll get one of these per rule defined on
  315. // the server you are querying
  316. virtual void RulesResponded( const char *pchRule, const char *pchValue ) = 0;
  317. // The server failed to respond to the request for rule details
  318. virtual void RulesFailedToRespond() = 0;
  319. // The server has finished responding to the rule details request
  320. // (ie, you won't get anymore RulesResponded callbacks)
  321. virtual void RulesRefreshComplete() = 0;
  322. };
  323. //-----------------------------------------------------------------------------
  324. // Typedef for handle type you will receive when querying details on an individual server.
  325. //-----------------------------------------------------------------------------
  326. typedef int HServerQuery;
  327. const int HSERVERQUERY_INVALID = 0xffffffff;
  328. //-----------------------------------------------------------------------------
  329. // Purpose: Functions for match making services for clients to get to game lists and details
  330. //-----------------------------------------------------------------------------
  331. class ISteamMatchmakingServers
  332. {
  333. public:
  334. // Request a new list of servers of a particular type. These calls each correspond to one of the EMatchMakingType values.
  335. // Each call allocates a new asynchronous request object.
  336. // Request object must be released by calling ReleaseRequest( hServerListRequest )
  337. virtual HServerListRequest RequestInternetServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  338. virtual HServerListRequest RequestLANServerList( AppId_t iApp, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  339. virtual HServerListRequest RequestFriendsServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  340. virtual HServerListRequest RequestFavoritesServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  341. virtual HServerListRequest RequestHistoryServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  342. virtual HServerListRequest RequestSpectatorServerList( AppId_t iApp, ARRAY_COUNT(nFilters) MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  343. // Releases the asynchronous request object and cancels any pending query on it if there's a pending query in progress.
  344. // RefreshComplete callback is not posted when request is released.
  345. virtual void ReleaseRequest( HServerListRequest hServerListRequest ) = 0;
  346. /* the filter operation codes that go in the key part of MatchMakingKeyValuePair_t should be one of these:
  347. "map"
  348. - Server passes the filter if the server is playing the specified map.
  349. "gamedataand"
  350. - Server passes the filter if the server's game data (ISteamGameServer::SetGameData) contains all of the
  351. specified strings. The value field is a comma-delimited list of strings to match.
  352. "gamedataor"
  353. - Server passes the filter if the server's game data (ISteamGameServer::SetGameData) contains at least one of the
  354. specified strings. The value field is a comma-delimited list of strings to match.
  355. "gamedatanor"
  356. - Server passes the filter if the server's game data (ISteamGameServer::SetGameData) does not contain any
  357. of the specified strings. The value field is a comma-delimited list of strings to check.
  358. "gametagsand"
  359. - Server passes the filter if the server's game tags (ISteamGameServer::SetGameTags) contains all
  360. of the specified strings. The value field is a comma-delimited list of strings to check.
  361. "gametagsnor"
  362. - Server passes the filter if the server's game tags (ISteamGameServer::SetGameTags) does not contain any
  363. of the specified strings. The value field is a comma-delimited list of strings to check.
  364. "and" (x1 && x2 && ... && xn)
  365. "or" (x1 || x2 || ... || xn)
  366. "nand" !(x1 && x2 && ... && xn)
  367. "nor" !(x1 || x2 || ... || xn)
  368. - Performs Boolean operation on the following filters. The operand to this filter specifies
  369. the "size" of the Boolean inputs to the operation, in Key/value pairs. (The keyvalue
  370. pairs must immediately follow, i.e. this is a prefix logical operator notation.)
  371. In the simplest case where Boolean expressions are not nested, this is simply
  372. the number of operands.
  373. For example, to match servers on a particular map or with a particular tag, would would
  374. use these filters.
  375. ( server.map == "cp_dustbowl" || server.gametags.contains("payload") )
  376. "or", "2"
  377. "map", "cp_dustbowl"
  378. "gametagsand", "payload"
  379. If logical inputs are nested, then the operand specifies the size of the entire
  380. "length" of its operands, not the number of immediate children.
  381. ( server.map == "cp_dustbowl" || ( server.gametags.contains("payload") && !server.gametags.contains("payloadrace") ) )
  382. "or", "4"
  383. "map", "cp_dustbowl"
  384. "and", "2"
  385. "gametagsand", "payload"
  386. "gametagsnor", "payloadrace"
  387. Unary NOT can be achieved using either "nand" or "nor" with a single operand.
  388. "addr"
  389. - Server passes the filter if the server's query address matches the specified IP or IP:port.
  390. "gameaddr"
  391. - Server passes the filter if the server's game address matches the specified IP or IP:port.
  392. The following filter operations ignore the "value" part of MatchMakingKeyValuePair_t
  393. "dedicated"
  394. - Server passes the filter if it passed true to SetDedicatedServer.
  395. "secure"
  396. - Server passes the filter if the server is VAC-enabled.
  397. "notfull"
  398. - Server passes the filter if the player count is less than the reported max player count.
  399. "hasplayers"
  400. - Server passes the filter if the player count is greater than zero.
  401. "noplayers"
  402. - Server passes the filter if it doesn't have any players.
  403. "linux"
  404. - Server passes the filter if it's a linux server
  405. */
  406. // Get details on a given server in the list, you can get the valid range of index
  407. // values by calling GetServerCount(). You will also receive index values in
  408. // ISteamMatchmakingServerListResponse::ServerResponded() callbacks
  409. virtual gameserveritem_t *GetServerDetails( HServerListRequest hRequest, int iServer ) = 0;
  410. // Cancel an request which is operation on the given list type. You should call this to cancel
  411. // any in-progress requests before destructing a callback object that may have been passed
  412. // to one of the above list request calls. Not doing so may result in a crash when a callback
  413. // occurs on the destructed object.
  414. // Canceling a query does not release the allocated request handle.
  415. // The request handle must be released using ReleaseRequest( hRequest )
  416. virtual void CancelQuery( HServerListRequest hRequest ) = 0;
  417. // Ping every server in your list again but don't update the list of servers
  418. // Query callback installed when the server list was requested will be used
  419. // again to post notifications and RefreshComplete, so the callback must remain
  420. // valid until another RefreshComplete is called on it or the request
  421. // is released with ReleaseRequest( hRequest )
  422. virtual void RefreshQuery( HServerListRequest hRequest ) = 0;
  423. // Returns true if the list is currently refreshing its server list
  424. virtual bool IsRefreshing( HServerListRequest hRequest ) = 0;
  425. // How many servers in the given list, GetServerDetails above takes 0... GetServerCount() - 1
  426. virtual int GetServerCount( HServerListRequest hRequest ) = 0;
  427. // Refresh a single server inside of a query (rather than all the servers )
  428. virtual void RefreshServer( HServerListRequest hRequest, int iServer ) = 0;
  429. //-----------------------------------------------------------------------------
  430. // Queries to individual servers directly via IP/Port
  431. //-----------------------------------------------------------------------------
  432. // Request updated ping time and other details from a single server
  433. virtual HServerQuery PingServer( uint32 unIP, uint16 usPort, ISteamMatchmakingPingResponse *pRequestServersResponse ) = 0;
  434. // Request the list of players currently playing on a server
  435. virtual HServerQuery PlayerDetails( uint32 unIP, uint16 usPort, ISteamMatchmakingPlayersResponse *pRequestServersResponse ) = 0;
  436. // Request the list of rules that the server is running (See ISteamGameServer::SetKeyValue() to set the rules server side)
  437. virtual HServerQuery ServerRules( uint32 unIP, uint16 usPort, ISteamMatchmakingRulesResponse *pRequestServersResponse ) = 0;
  438. // Cancel an outstanding Ping/Players/Rules query from above. You should call this to cancel
  439. // any in-progress requests before destructing a callback object that may have been passed
  440. // to one of the above calls to avoid crashing when callbacks occur.
  441. virtual void CancelServerQuery( HServerQuery hServerQuery ) = 0;
  442. };
  443. #define STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION "SteamMatchMakingServers002"
  444. // game server flags
  445. const uint32 k_unFavoriteFlagNone = 0x00;
  446. const uint32 k_unFavoriteFlagFavorite = 0x01; // this game favorite entry is for the favorites list
  447. const uint32 k_unFavoriteFlagHistory = 0x02; // this game favorite entry is for the history list
  448. //-----------------------------------------------------------------------------
  449. // Purpose: Used in ChatInfo messages - fields specific to a chat member - must fit in a uint32
  450. //-----------------------------------------------------------------------------
  451. enum EChatMemberStateChange
  452. {
  453. // Specific to joining / leaving the chatroom
  454. k_EChatMemberStateChangeEntered = 0x0001, // This user has joined or is joining the chat room
  455. k_EChatMemberStateChangeLeft = 0x0002, // This user has left or is leaving the chat room
  456. k_EChatMemberStateChangeDisconnected = 0x0004, // User disconnected without leaving the chat first
  457. k_EChatMemberStateChangeKicked = 0x0008, // User kicked
  458. k_EChatMemberStateChangeBanned = 0x0010, // User kicked and banned
  459. };
  460. // returns true of the flags indicate that a user has been removed from the chat
  461. #define BChatMemberStateChangeRemoved( rgfChatMemberStateChangeFlags ) ( rgfChatMemberStateChangeFlags & ( k_EChatMemberStateChangeDisconnected | k_EChatMemberStateChangeLeft | k_EChatMemberStateChangeKicked | k_EChatMemberStateChangeBanned ) )
  462. //-----------------------------------------------------------------------------
  463. // Callbacks for ISteamMatchmaking (which go through the regular Steam callback registration system)
  464. #if defined( VALVE_CALLBACK_PACK_SMALL )
  465. #pragma pack( push, 4 )
  466. #elif defined( VALVE_CALLBACK_PACK_LARGE )
  467. #pragma pack( push, 8 )
  468. #else
  469. #error isteamclient.h must be included
  470. #endif
  471. //-----------------------------------------------------------------------------
  472. // Purpose: a server was added/removed from the favorites list, you should refresh now
  473. //-----------------------------------------------------------------------------
  474. struct FavoritesListChanged_t
  475. {
  476. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 2 };
  477. uint32 m_nIP; // an IP of 0 means reload the whole list, any other value means just one server
  478. uint32 m_nQueryPort;
  479. uint32 m_nConnPort;
  480. uint32 m_nAppID;
  481. uint32 m_nFlags;
  482. bool m_bAdd; // true if this is adding the entry, otherwise it is a remove
  483. AccountID_t m_unAccountId;
  484. };
  485. //-----------------------------------------------------------------------------
  486. // Purpose: Someone has invited you to join a Lobby
  487. // normally you don't need to do anything with this, since
  488. // the Steam UI will also display a '<user> has invited you to the lobby, join?' dialog
  489. //
  490. // if the user outside a game chooses to join, your game will be launched with the parameter "+connect_lobby <64-bit lobby id>",
  491. // or with the callback GameLobbyJoinRequested_t if they're already in-game
  492. //-----------------------------------------------------------------------------
  493. struct LobbyInvite_t
  494. {
  495. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 3 };
  496. uint64 m_ulSteamIDUser; // Steam ID of the person making the invite
  497. uint64 m_ulSteamIDLobby; // Steam ID of the Lobby
  498. uint64 m_ulGameID; // GameID of the Lobby
  499. };
  500. //-----------------------------------------------------------------------------
  501. // Purpose: Sent on entering a lobby, or on failing to enter
  502. // m_EChatRoomEnterResponse will be set to k_EChatRoomEnterResponseSuccess on success,
  503. // or a higher value on failure (see enum EChatRoomEnterResponse)
  504. //-----------------------------------------------------------------------------
  505. struct LobbyEnter_t
  506. {
  507. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 4 };
  508. uint64 m_ulSteamIDLobby; // SteamID of the Lobby you have entered
  509. uint32 m_rgfChatPermissions; // Permissions of the current user
  510. bool m_bLocked; // If true, then only invited users may join
  511. uint32 m_EChatRoomEnterResponse; // EChatRoomEnterResponse
  512. };
  513. //-----------------------------------------------------------------------------
  514. // Purpose: The lobby metadata has changed
  515. // if m_ulSteamIDMember is the steamID of a lobby member, use GetLobbyMemberData() to access per-user details
  516. // if m_ulSteamIDMember == m_ulSteamIDLobby, use GetLobbyData() to access lobby metadata
  517. //-----------------------------------------------------------------------------
  518. struct LobbyDataUpdate_t
  519. {
  520. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 5 };
  521. uint64 m_ulSteamIDLobby; // steamID of the Lobby
  522. uint64 m_ulSteamIDMember; // steamID of the member whose data changed, or the room itself
  523. uint8 m_bSuccess; // true if we lobby data was successfully changed;
  524. // will only be false if RequestLobbyData() was called on a lobby that no longer exists
  525. };
  526. //-----------------------------------------------------------------------------
  527. // Purpose: The lobby chat room state has changed
  528. // this is usually sent when a user has joined or left the lobby
  529. //-----------------------------------------------------------------------------
  530. struct LobbyChatUpdate_t
  531. {
  532. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 6 };
  533. uint64 m_ulSteamIDLobby; // Lobby ID
  534. uint64 m_ulSteamIDUserChanged; // user who's status in the lobby just changed - can be recipient
  535. uint64 m_ulSteamIDMakingChange; // Chat member who made the change (different from SteamIDUserChange if kicking, muting, etc.)
  536. // for example, if one user kicks another from the lobby, this will be set to the id of the user who initiated the kick
  537. uint32 m_rgfChatMemberStateChange; // bitfield of EChatMemberStateChange values
  538. };
  539. //-----------------------------------------------------------------------------
  540. // Purpose: A chat message for this lobby has been sent
  541. // use GetLobbyChatEntry( m_iChatID ) to retrieve the contents of this message
  542. //-----------------------------------------------------------------------------
  543. struct LobbyChatMsg_t
  544. {
  545. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 7 };
  546. uint64 m_ulSteamIDLobby; // the lobby id this is in
  547. uint64 m_ulSteamIDUser; // steamID of the user who has sent this message
  548. uint8 m_eChatEntryType; // type of message
  549. uint32 m_iChatID; // index of the chat entry to lookup
  550. };
  551. //-----------------------------------------------------------------------------
  552. // Purpose: A game created a game for all the members of the lobby to join,
  553. // as triggered by a SetLobbyGameServer()
  554. // it's up to the individual clients to take action on this; the usual
  555. // game behavior is to leave the lobby and connect to the specified game server
  556. //-----------------------------------------------------------------------------
  557. struct LobbyGameCreated_t
  558. {
  559. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 9 };
  560. uint64 m_ulSteamIDLobby; // the lobby we were in
  561. uint64 m_ulSteamIDGameServer; // the new game server that has been created or found for the lobby members
  562. uint32 m_unIP; // IP & Port of the game server (if any)
  563. uint16 m_usPort;
  564. };
  565. //-----------------------------------------------------------------------------
  566. // Purpose: Number of matching lobbies found
  567. // iterate the returned lobbies with GetLobbyByIndex(), from values 0 to m_nLobbiesMatching-1
  568. //-----------------------------------------------------------------------------
  569. struct LobbyMatchList_t
  570. {
  571. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 10 };
  572. uint32 m_nLobbiesMatching; // Number of lobbies that matched search criteria and we have SteamIDs for
  573. };
  574. //-----------------------------------------------------------------------------
  575. // Purpose: posted if a user is forcefully removed from a lobby
  576. // can occur if a user loses connection to Steam
  577. //-----------------------------------------------------------------------------
  578. struct LobbyKicked_t
  579. {
  580. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 12 };
  581. uint64 m_ulSteamIDLobby; // Lobby
  582. uint64 m_ulSteamIDAdmin; // User who kicked you - possibly the ID of the lobby itself
  583. uint8 m_bKickedDueToDisconnect; // true if you were kicked from the lobby due to the user losing connection to Steam (currently always true)
  584. };
  585. //-----------------------------------------------------------------------------
  586. // Purpose: Result of our request to create a Lobby
  587. // m_eResult == k_EResultOK on success
  588. // at this point, the lobby has been joined and is ready for use
  589. // a LobbyEnter_t callback will also be received (since the local user is joining their own lobby)
  590. //-----------------------------------------------------------------------------
  591. struct LobbyCreated_t
  592. {
  593. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 13 };
  594. EResult m_eResult; // k_EResultOK - the lobby was successfully created
  595. // k_EResultNoConnection - your Steam client doesn't have a connection to the back-end
  596. // k_EResultTimeout - you the message to the Steam servers, but it didn't respond
  597. // k_EResultFail - the server responded, but with an unknown internal error
  598. // k_EResultAccessDenied - your game isn't set to allow lobbies, or your client does haven't rights to play the game
  599. // k_EResultLimitExceeded - your game client has created too many lobbies
  600. uint64 m_ulSteamIDLobby; // chat room, zero if failed
  601. };
  602. // used by now obsolete RequestFriendsLobbiesResponse_t
  603. // enum { k_iCallback = k_iSteamMatchmakingCallbacks + 14 };
  604. //-----------------------------------------------------------------------------
  605. // Purpose: Result of CheckForPSNGameBootInvite
  606. // m_eResult == k_EResultOK on success
  607. // at this point, the local user may not have finishing joining this lobby;
  608. // game code should wait until the subsequent LobbyEnter_t callback is received
  609. //-----------------------------------------------------------------------------
  610. struct PSNGameBootInviteResult_t
  611. {
  612. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 15 };
  613. bool m_bGameBootInviteExists;
  614. CSteamID m_steamIDLobby; // Should be valid if m_bGameBootInviteExists == true
  615. };
  616. //-----------------------------------------------------------------------------
  617. // Purpose: Result of our request to create a Lobby
  618. // m_eResult == k_EResultOK on success
  619. // at this point, the lobby has been joined and is ready for use
  620. // a LobbyEnter_t callback will also be received (since the local user is joining their own lobby)
  621. //-----------------------------------------------------------------------------
  622. struct FavoritesListAccountsUpdated_t
  623. {
  624. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 16 };
  625. EResult m_eResult;
  626. };
  627. #pragma pack( pop )
  628. #endif // ISTEAMMATCHMAKING