From a2f8fec8165812b661f313494b63609689c2dcd0 Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Fri, 17 Jan 2020 11:36:46 -0500 Subject: [PATCH] Try to fix the flat api get public ip function. --- dll/dll.cpp | 8 ++++++++ dll/dll.h | 1 + dll/flat.cpp | 8 ++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dll/dll.cpp b/dll/dll.cpp index 2040a46..950da72 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -134,6 +134,12 @@ Steam_Client *get_steam_clientserver_old() return get_steam_client(); } +static bool steamclient_has_ipv6_functions_flag; +bool steamclient_has_ipv6_functions() +{ + return steamclient_has_ipv6_functions_flag; +} + static void *create_client_interface(const char *ver) { if (strstr(ver, "SteamClient") == ver) { @@ -167,8 +173,10 @@ static void *create_client_interface(const char *ver) steam_client = (ISteamClient019 *)get_steam_client(); } else if (strcmp(ver, STEAMCLIENT_INTERFACE_VERSION) == 0) { steam_client = (ISteamClient *)get_steam_client(); + steamclient_has_ipv6_functions_flag = true; } else { steam_client = (ISteamClient *)get_steam_client(); + steamclient_has_ipv6_functions_flag = true; } return steam_client; diff --git a/dll/dll.h b/dll/dll.h index 256f19d..5053d01 100644 --- a/dll/dll.h +++ b/dll/dll.h @@ -26,3 +26,4 @@ #endif Steam_Client *get_steam_client(); +bool steamclient_has_ipv6_functions(); \ No newline at end of file diff --git a/dll/flat.cpp b/dll/flat.cpp index fb1d30c..6980afe 100644 --- a/dll/flat.cpp +++ b/dll/flat.cpp @@ -4909,10 +4909,14 @@ STEAMAPI_API SteamAPICall_t SteamAPI_ISteamGameServer_GetServerReputation(intptr return ((ISteamGameServer *)instancePtr)->GetServerReputation(); } -STEAMAPI_API struct SteamIPAddress_t SteamAPI_ISteamGameServer_GetPublicIP(intptr_t instancePtr) +STEAMAPI_API uint32 SteamAPI_ISteamGameServer_GetPublicIP(intptr_t instancePtr, void *instancePtr_possible) { //TODO: check if this actually works (ret value changed from uint32 to struct) - return ((ISteamGameServer *)instancePtr)->GetPublicIP(); + if (steamclient_has_ipv6_functions()) { + return ((ISteamGameServer012 *)instancePtr_possible)->GetPublicIP_old(); + } else { + return ((ISteamGameServer012 *)instancePtr)->GetPublicIP_old(); + } } STEAMAPI_API bool SteamAPI_ISteamGameServer_HandleIncomingPacket(intptr_t instancePtr, const void * pData, int cbData, uint32 srcIP, uint16 srcPort)