diff --git a/dll/dll.cpp b/dll/dll.cpp index be5587a..1385b92 100644 --- a/dll/dll.cpp +++ b/dll/dll.cpp @@ -136,7 +136,7 @@ Steam_Client *get_steam_clientserver_old() static bool steamclient_has_ipv6_functions_flag; bool steamclient_has_ipv6_functions() { - return steamclient_has_ipv6_functions_flag; + return steamclient_has_ipv6_functions_flag || get_steam_client()->gameserver_has_ipv6_functions; } static void *create_client_interface(const char *ver) diff --git a/dll/flat.cpp b/dll/flat.cpp index d7da4ca..534e4a5 100644 --- a/dll/flat.cpp +++ b/dll/flat.cpp @@ -5843,13 +5843,14 @@ STEAMAPI_API SteamAPICall_t SteamAPI_ISteamGameServer_GetServerReputation( IStea return self->GetServerReputation(); } -STEAMAPI_API uint32 SteamAPI_ISteamGameServer_GetPublicIP( intptr_t instancePtr, void *instancePtr_possible ) +STEAMAPI_API void *SteamAPI_ISteamGameServer_GetPublicIP( intptr_t instancePtr, void *instancePtr_possible ) { - //TODO: check if this actually works (ret value changed from uint32 to struct) + //abuse call convention rules to get this working. if (steamclient_has_ipv6_functions()) { - return ((ISteamGameServer012 *)instancePtr_possible)->GetPublicIP_old(); + get_steam_client()->steam_gameserver->GetPublicIP_fix((SteamIPAddress_t *)instancePtr); + return (void *)instancePtr; } else { - return ((ISteamGameServer012 *)instancePtr)->GetPublicIP_old(); + return (void *)((ISteamGameServer012 *)instancePtr)->GetPublicIP_old(); } } diff --git a/dll/steam_client.cpp b/dll/steam_client.cpp index 0ce6324..27757f0 100644 --- a/dll/steam_client.cpp +++ b/dll/steam_client.cpp @@ -109,6 +109,8 @@ Steam_Client::Steam_Client() steam_gameserver_game_coordinator = new Steam_Game_Coordinator(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); steam_masterserver_updater = new Steam_Masterserver_Updater(settings_server, network, callback_results_server, callbacks_server, run_every_runcb); + gameserver_has_ipv6_functions = false; + last_cb_run = 0; PRINT_DEBUG("client init end\n"); } @@ -303,8 +305,10 @@ ISteamGameServer *Steam_Client::GetISteamGameServer( HSteamUser hSteamUser, HSte } else if (strcmp(pchVersion, "SteamGameServer012") == 0) { return (ISteamGameServer *)(void *)(ISteamGameServer012 *)steam_gameserver; } else if (strcmp(pchVersion, STEAMGAMESERVER_INTERFACE_VERSION) == 0) { + gameserver_has_ipv6_functions = true; return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver; } else { + gameserver_has_ipv6_functions = true; return (ISteamGameServer *)(void *)(ISteamGameServer *)steam_gameserver; } diff --git a/dll/steam_client.h b/dll/steam_client.h index b46285e..d00cb6a 100644 --- a/dll/steam_client.h +++ b/dll/steam_client.h @@ -139,6 +139,8 @@ public: unsigned steam_pipe_counter = 1; std::map steam_pipes; + bool gameserver_has_ipv6_functions; + Steam_Client(); ~Steam_Client(); // Creates a communication pipe to the Steam client. diff --git a/dll/steam_gameserver.cpp b/dll/steam_gameserver.cpp index 6735456..584f369 100644 --- a/dll/steam_gameserver.cpp +++ b/dll/steam_gameserver.cpp @@ -559,6 +559,12 @@ SteamIPAddress_t Steam_GameServer::GetPublicIP() return ip; } +void Steam_GameServer::GetPublicIP_fix(SteamIPAddress_t *out) +{ + PRINT_DEBUG("GetPublicIP_fix\n"); + if (out) *out = GetPublicIP(); +} + // These are in GameSocketShare mode, where instead of ISteamGameServer creating its own // socket to talk to the master server on, it lets the game use its socket to forward messages // back and forth. This prevents us from requiring server ops to open up yet another port diff --git a/dll/steam_gameserver.h b/dll/steam_gameserver.h index cc11682..e66f3b9 100644 --- a/dll/steam_gameserver.h +++ b/dll/steam_gameserver.h @@ -278,6 +278,7 @@ public: // connect to uint32 GetPublicIP_old(); SteamIPAddress_t GetPublicIP(); + void GetPublicIP_fix(SteamIPAddress_t *out); // These are in GameSocketShare mode, where instead of ISteamGameServer creating its own // socket to talk to the master server on, it lets the game use its socket to forward messages