From 8a395b525bf1a77551bb5fdb30c56ab4e42176f4 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 3 Jul 2022 19:07:52 +0200 Subject: [PATCH] More dedi progress --- .../steam/interfaces/matchmaking_servers.cpp | 62 +++++++++++-------- .../steam/interfaces/matchmaking_servers.hpp | 28 ++++++--- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/client/steam/interfaces/matchmaking_servers.cpp b/src/client/steam/interfaces/matchmaking_servers.cpp index e00109f1..ef3cd68e 100644 --- a/src/client/steam/interfaces/matchmaking_servers.cpp +++ b/src/client/steam/interfaces/matchmaking_servers.cpp @@ -3,6 +3,37 @@ namespace steam { + namespace + { + gameserveritem_t* get_server_item() + { + static gameserveritem_t server{}; + server.m_NetAdr.m_usConnectionPort = 27017; + server.m_NetAdr.m_usQueryPort = 27017; + server.m_NetAdr.m_unIP = 0x7F000001; + server.m_nPing = 10; + server.m_bHadSuccessfulResponse = true; + server.m_bDoNotRefresh = false; + strcpy_s(server.m_szGameDir, "usermaps"); + strcpy_s(server.m_szMap, "mp_nuketown_x"); + strcpy_s(server.m_szGameDescription, "Example BO^3I^5I^6I ^7Server"); + server.m_nAppID = 311210; + server.m_nPlayers = 0; + server.m_nMaxPlayers = 18; + server.m_nBotPlayers = 0; + server.m_bPassword = false; + server.m_bSecure = true; + server.m_ulTimeLastPlayed = 0; + server.m_nServerVersion = 1000; + strcpy_s(server.m_szServerName, "BO^3I^5I^6I ^7Server"); + strcpy_s(server.m_szGameTags, + R"(\gametype\gun\dedicated\true\ranked\true\hardcore\false\zombies\false\modName\usermaps\playerCount\0)"); + server.m_steamID = steam_id(); + + return &server; + } + } + void* matchmaking_servers::RequestInternetServerList(unsigned int iApp, void** ppchFilters, unsigned int nFilters, matchmaking_server_list_response* pRequestServersResponse) { @@ -47,30 +78,7 @@ namespace steam gameserveritem_t* matchmaking_servers::GetServerDetails(void* hRequest, int iServer) { - static gameserveritem_t server{}; - server.m_NetAdr.m_usConnectionPort = 27017; - server.m_NetAdr.m_usQueryPort = 27017; - server.m_NetAdr.m_unIP = 0x7F000001; - server.m_nPing = 10; - server.m_bHadSuccessfulResponse = true; - server.m_bDoNotRefresh = false; - strcpy_s(server.m_szGameDir, "usermaps"); - strcpy_s(server.m_szMap, "mp_nuketown_x"); - strcpy_s(server.m_szGameDescription, "Example BO^3I^5I^6I ^7Server"); - server.m_nAppID = 311210; - server.m_nPlayers = 0; - server.m_nMaxPlayers = 18; - server.m_nBotPlayers = 0; - server.m_bPassword = false; - server.m_bSecure = true; - server.m_ulTimeLastPlayed = 0; - server.m_nServerVersion = 1000; - strcpy_s(server.m_szServerName, "BO^3I^5I^6I ^7Server"); - strcpy_s(server.m_szGameTags, - R"(\gametype\gun\dedicated\true\ranked\true\hardcore\false\zombies\false\modName\usermaps\playerCount\0)"); - server.m_steamID = steam_id(); - - return &server; + return get_server_item(); } void matchmaking_servers::CancelQuery(void* hRequest) @@ -95,9 +103,11 @@ namespace steam { } - int matchmaking_servers::PingServer(unsigned int unIP, unsigned short usPort, void* pRequestServersResponse) + void* matchmaking_servers::PingServer(unsigned int unIP, unsigned short usPort, + matchmaking_ping_response* pRequestServersResponse) { - return 0; + pRequestServersResponse->ServerResponded(*get_server_item()); + return reinterpret_cast(7); } int matchmaking_servers::PlayerDetails(unsigned int unIP, unsigned short usPort, void* pRequestServersResponse) diff --git a/src/client/steam/interfaces/matchmaking_servers.hpp b/src/client/steam/interfaces/matchmaking_servers.hpp index abad0466..bcd76ae4 100644 --- a/src/client/steam/interfaces/matchmaking_servers.hpp +++ b/src/client/steam/interfaces/matchmaking_servers.hpp @@ -9,14 +9,6 @@ namespace steam eNoServersListedOnMasterServer } matchmaking_server_response; - class matchmaking_server_list_response - { - public: - virtual void ServerResponded(void* hRequest, int iServer) = 0; - virtual void ServerFailedToRespond(void* hRequest, int iServer) = 0; - virtual void RefreshComplete(void* hRequest, matchmaking_server_response response) = 0; - }; - class servernetadr_t { public: @@ -48,6 +40,21 @@ namespace steam steam_id m_steamID; }; + class matchmaking_ping_response + { + public: + virtual void ServerResponded(gameserveritem_t& server) = 0; + virtual void ServerFailedToRespond() = 0; + }; + + class matchmaking_server_list_response + { + public: + virtual void ServerResponded(void* hRequest, int iServer) = 0; + virtual void ServerFailedToRespond(void* hRequest, int iServer) = 0; + virtual void RefreshComplete(void* hRequest, matchmaking_server_response response) = 0; + }; + class matchmaking_servers { public: @@ -55,7 +62,8 @@ namespace steam virtual void* RequestInternetServerList(unsigned int iApp, void** ppchFilters, unsigned int nFilters, matchmaking_server_list_response* pRequestServersResponse); - virtual void* RequestLANServerList(unsigned int iApp, matchmaking_server_list_response* pRequestServersResponse); + virtual void* RequestLANServerList(unsigned int iApp, + matchmaking_server_list_response* pRequestServersResponse); virtual void* RequestFriendsServerList(unsigned int iApp, void** ppchFilters, unsigned int nFilters, matchmaking_server_list_response* pRequestServersResponse); virtual void* RequestFavoritesServerList(unsigned int iApp, void** ppchFilters, unsigned int nFilters, @@ -71,7 +79,7 @@ namespace steam virtual bool IsRefreshing(void* hRequest); virtual int GetServerCount(void* hRequest); virtual void RefreshServer(void* hRequest, int iServer); - virtual int PingServer(unsigned int unIP, unsigned short usPort, void* pRequestServersResponse); + virtual void* PingServer(unsigned int unIP, unsigned short usPort, matchmaking_ping_response* pRequestServersResponse); virtual int PlayerDetails(unsigned int unIP, unsigned short usPort, void* pRequestServersResponse); virtual int ServerRules(unsigned int unIP, unsigned short usPort, void* pRequestServersResponse); virtual void CancelServerQuery(int hServerQuery);