From fa27cf4abc7e477cd9ec69b827a15e6b2e31b518 Mon Sep 17 00:00:00 2001 From: a Date: Fri, 6 Dec 2024 22:24:33 +0200 Subject: [PATCH] old steammatchmaking --- dll/dll/steam_matchmaking.h | 35 +++++++++-- dll/steam_client_interface_getter.cpp | 5 +- dll/steam_matchmaking.cpp | 73 +++++++++++++++++++++++ sdk/steam/isteammatchmaking001.h | 83 +++++++++++++++++++++++++++ sdk/steam/steam_api.h | 1 + 5 files changed, 189 insertions(+), 8 deletions(-) create mode 100644 sdk/steam/isteammatchmaking001.h diff --git a/dll/dll/steam_matchmaking.h b/dll/dll/steam_matchmaking.h index 4b00dc3d..fa5da508 100644 --- a/dll/dll/steam_matchmaking.h +++ b/dll/dll/steam_matchmaking.h @@ -41,11 +41,11 @@ struct Data_Requested { }; struct Filter_Values { - std::string key{}; - std::string value_string{}; - int value_int{}; - bool is_int{}; - ELobbyComparison eComparisonType{}; + std::string key{}; + std::string value_string{}; + int value_int{}; + bool is_int{}; + ELobbyComparison eComparisonType{}; }; struct Chat_Entry { @@ -56,6 +56,7 @@ struct Chat_Entry { class Steam_Matchmaking : +public ISteamMatchmaking001, public ISteamMatchmaking002, public ISteamMatchmaking003, public ISteamMatchmaking004, @@ -383,6 +384,30 @@ public: // you must be the lobby owner of both lobbies bool SetLinkedLobby( CSteamID steamIDLobby, CSteamID steamIDLobbyDependent ); + + // older sdk ------------------------------------------------------------------- + + // 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 + bool GetFavoriteGame( int iGame, uint32 *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ); + + // adds the game server to the local list; updates the time played of the server if it already exists in the list + int AddFavoriteGame( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ); + + // removes the game server from the local storage; returns true if one was removed + bool RemoveFavoriteGame( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint32 unFlags ); + bool GetFavoriteGame2( int iGame, uint32 *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint16 *pnQueryPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ); + int AddFavoriteGame2( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ); + bool RemoveFavoriteGame2( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags ); + void RequestLobbyList( uint64 ulGameID, MatchMakingKeyValuePair_t *pFilters, uint32 nFilters ); + void CreateLobby( uint64 ulGameID, bool bPrivate ); + bool SetLobbyMemberData_OLD( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ); + + // older sdk ------------------------------------------------------------------- + }; #endif // __INCLUDED_STEAM_MATCHMAKING_H__ diff --git a/dll/steam_client_interface_getter.cpp b/dll/steam_client_interface_getter.cpp index 67419289..55b2b098 100644 --- a/dll/steam_client_interface_getter.cpp +++ b/dll/steam_client_interface_getter.cpp @@ -251,9 +251,8 @@ ISteamMatchmaking *Steam_Client::GetISteamMatchmaking( HSteamUser hSteamUser, HS PRINT_DEBUG("%s", pchVersion); if (!steam_pipes.count(hSteamPipe) || !hSteamUser) return NULL; - if (strcmp(pchVersion, "SteamMatchMaking001") == 0) { // SteamMatchMaking001 Not found in public Archive, must be before 1.00 - //TODO - return reinterpret_cast(static_cast(steam_matchmaking)); + if (strcmp(pchVersion, "SteamMatchMaking001") == 0) { // SteamMatchMaking001 Not found in public Archive, from proton src + return reinterpret_cast(static_cast(steam_matchmaking)); } else if (strcmp(pchVersion, "SteamMatchMaking002") == 0) { return reinterpret_cast(static_cast(steam_matchmaking)); } else if (strcmp(pchVersion, "SteamMatchMaking003") == 0) { diff --git a/dll/steam_matchmaking.cpp b/dll/steam_matchmaking.cpp index 45060f97..73724662 100644 --- a/dll/steam_matchmaking.cpp +++ b/dll/steam_matchmaking.cpp @@ -1242,6 +1242,79 @@ bool Steam_Matchmaking::SetLinkedLobby( CSteamID steamIDLobby, CSteamID steamIDL +// older sdk ------------------------------------------------------------------- + +// 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 +bool Steam_Matchmaking::GetFavoriteGame( int iGame, uint32 *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ) +{ + PRINT_DEBUG("old"); + return GetFavoriteGame(iGame, reinterpret_cast(pnAppID), pnIP, pnConnPort, 0, punFlags, pRTime32LastPlayedOnServer ); +} + +// adds the game server to the local list; updates the time played of the server if it already exists in the list +int Steam_Matchmaking::AddFavoriteGame( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) +{ + PRINT_DEBUG("old"); + return AddFavoriteGame( (AppId_t)nAppID, nIP, nConnPort, 0, unFlags, rTime32LastPlayedOnServer ); +} + +// removes the game server from the local storage; returns true if one was removed +bool Steam_Matchmaking::RemoveFavoriteGame( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint32 unFlags ) +{ + PRINT_DEBUG("old"); + return RemoveFavoriteGame( (AppId_t)nAppID, nIP, nConnPort, 0, unFlags ); +} + +bool Steam_Matchmaking::GetFavoriteGame2( int iGame, uint32 *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint16 *pnQueryPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ) +{ + PRINT_DEBUG("old"); + return GetFavoriteGame(iGame, reinterpret_cast(pnAppID), pnIP, pnConnPort, pnQueryPort, punFlags, pRTime32LastPlayedOnServer ); +} + +int Steam_Matchmaking::AddFavoriteGame2( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) +{ + PRINT_DEBUG("old"); + return AddFavoriteGame( (AppId_t)nAppID, nIP, nConnPort, nQueryPort, unFlags, rTime32LastPlayedOnServer ); +} + +bool Steam_Matchmaking::RemoveFavoriteGame2( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags ) +{ + PRINT_DEBUG("old"); + return RemoveFavoriteGame( (AppId_t)nAppID, nIP, nConnPort, nQueryPort, unFlags ); +} + +void Steam_Matchmaking::RequestLobbyList( uint64 ulGameID, MatchMakingKeyValuePair_t *pFilters, uint32 nFilters ) +{ + PRINT_DEBUG("old"); + if (pFilters && nFilters > 0) { + for (size_t fidx = 0; fidx < nFilters; ++fidx) { + auto &kv = pFilters[fidx]; + AddRequestLobbyListFilter(kv.m_szKey, kv.m_szValue); + } + } + RequestLobbyList(); +} + +void Steam_Matchmaking::CreateLobby( uint64 ulGameID, bool bPrivate ) +{ + PRINT_DEBUG("old"); + CreateLobby(bPrivate); +} + +bool Steam_Matchmaking::SetLobbyMemberData_OLD( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) +{ + PRINT_DEBUG("old"); + SetLobbyMemberData(steamIDLobby, pchKey, pchValue); + return true; +} +// older sdk ------------------------------------------------------------------- + + + void Steam_Matchmaking::remove_lobbies() { uint64 current_time = std::chrono::duration_cast>(std::chrono::system_clock::now().time_since_epoch()).count(); diff --git a/sdk/steam/isteammatchmaking001.h b/sdk/steam/isteammatchmaking001.h new file mode 100644 index 00000000..48f70f20 --- /dev/null +++ b/sdk/steam/isteammatchmaking001.h @@ -0,0 +1,83 @@ +#ifndef ISTEAMMATCHMAKING001_H +#define ISTEAMMATCHMAKING001_H +#ifdef STEAM_WIN32 +#pragma once +#endif + +// this interface version is not found in public SDK archives, it is based on proton src: https://github.com/ValveSoftware/Proton/tree/proton_9.0/lsteamclient + +//----------------------------------------------------------------------------- +// Purpose: Functions for match making services for clients to get to favorites +// and to operate on game lobbies. +//----------------------------------------------------------------------------- +class ISteamMatchmaking001 +{ +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, uint32 *pnAppID, uint32 *pnIP, uint16 *pnConnPort, 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( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) = 0; + + // removes the game server from the local storage; returns true if one was removed + virtual bool RemoveFavoriteGame( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint32 unFlags ) = 0; + + virtual bool GetFavoriteGame2( int iGame, uint32 *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint16 *pnQueryPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ) = 0; + virtual int AddFavoriteGame2( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) = 0; + virtual bool RemoveFavoriteGame2( uint32 nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags ) = 0; + + /////// + // Game lobby functions + virtual void RequestLobbyList( uint64 ulGameID, MatchMakingKeyValuePair_t *pFilters, uint32 nFilters ) = 0; + + virtual CSteamID GetLobbyByIndex( int iLobby ) = 0; + virtual void CreateLobby( uint64 ulGameID, bool bPrivate ) = 0; + virtual void JoinLobby_OLD( CSteamID steamIDLobby ) = 0; + virtual void LeaveLobby( CSteamID steamIDLobby ) = 0; + virtual bool InviteUserToLobby( CSteamID steamIDLobby, CSteamID steamIDInvitee ) = 0; + virtual int GetNumLobbyMembers( CSteamID steamIDLobby ) = 0; + virtual CSteamID GetLobbyMemberByIndex( CSteamID steamIDLobby, int iMember ) = 0; + + 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; + + // As above, but gets per-user data 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 bool SetLobbyMemberData_OLD( 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 + 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; + + // Fetch metadata for a lobby you're not necessarily in right now + // 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 + virtual bool RequestLobbyData( CSteamID steamIDLobby ) = 0; +}; + +#endif // ISTEAMMATCHMAKING001_H diff --git a/sdk/steam/steam_api.h b/sdk/steam/steam_api.h index 028710db..18894650 100644 --- a/sdk/steam/steam_api.h +++ b/sdk/steam/steam_api.h @@ -85,6 +85,7 @@ #include "isteamutils008.h" #include "isteamutils009.h" #include "isteammatchmaking.h" +#include "isteammatchmaking001.h" #include "isteammatchmaking002.h" #include "isteammatchmaking003.h" #include "isteammatchmaking004.h"