Only set g_pSteamClientGameServer in steam gameserver init functions.

This commit is contained in:
Mr_Goldberg 2019-08-04 14:36:28 -04:00
parent 35c59044fd
commit 35860efa3a
No known key found for this signature in database
GPG key ID: 8597D87419DEF278

View file

@ -118,7 +118,6 @@ Steam_Client *get_steam_client()
{ {
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
static Steam_Client *client = new Steam_Client(); static Steam_Client *client = new Steam_Client();
if (!g_pSteamClientGameServer) g_pSteamClientGameServer = client;
return client; return client;
} }
@ -170,7 +169,6 @@ S_API void * S_CALLTYPE SteamInternal_CreateInterface( const char *ver )
steam_client = (ISteamClient *)get_steam_client(); steam_client = (ISteamClient *)get_steam_client();
} }
if (steam_client) g_pSteamClientGameServer = (ISteamClient *)steam_client;
return steam_client; return steam_client;
} else { } else {
return NULL; return NULL;
@ -498,7 +496,7 @@ S_API bool S_CALLTYPE SteamGameServer_InitSafe( uint32 unIP, uint16 usSteamPort,
const char *pchVersionString; const char *pchVersionString;
EServerMode serverMode; EServerMode serverMode;
uint16 usQueryPort; uint16 usQueryPort;
SteamGameServerClient(); load_old_interface_versions();
bool logon_anon = false; bool logon_anon = false;
if (strcmp(old_gameserver, "SteamGameServer010") == 0 || strstr(old_gameserver, "SteamGameServer00") == old_gameserver) { if (strcmp(old_gameserver, "SteamGameServer010") == 0 || strstr(old_gameserver, "SteamGameServer00") == old_gameserver) {
PRINT_DEBUG("Old game server init safe\n"); PRINT_DEBUG("Old game server init safe\n");
@ -523,8 +521,10 @@ S_API bool S_CALLTYPE SteamGameServer_InitSafe( uint32 unIP, uint16 usSteamPort,
S_API bool S_CALLTYPE SteamInternal_GameServer_Init( uint32 unIP, uint16 usPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString ) S_API bool S_CALLTYPE SteamInternal_GameServer_Init( uint32 unIP, uint16 usPort, uint16 usGamePort, uint16 usQueryPort, EServerMode eServerMode, const char *pchVersionString )
{ {
PRINT_DEBUG("SteamInternal_GameServer_Init %u %hu %hu %hu %u %s\n", unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString); PRINT_DEBUG("SteamInternal_GameServer_Init %u %hu %hu %hu %u %s\n", unIP, usPort, usGamePort, usQueryPort, eServerMode, pchVersionString);
SteamGameServerClient(); load_old_interface_versions();
get_steam_client()->serverInit(); get_steam_client()->serverInit();
//g_pSteamClientGameServer is only used in pre 1.37 (where the interface versions are not provided by the game)
g_pSteamClientGameServer = SteamGameServerClient();
return get_steam_client()->steam_gameserver->InitGameServer(unIP, usGamePort, usQueryPort, eServerMode, 0, pchVersionString); return get_steam_client()->steam_gameserver->InitGameServer(unIP, usGamePort, usQueryPort, eServerMode, 0, pchVersionString);
} }
@ -539,7 +539,7 @@ S_API bool SteamGameServer_Init( uint32 unIP, uint16 usSteamPort, uint16 usGameP
const char *pchVersionString; const char *pchVersionString;
EServerMode serverMode; EServerMode serverMode;
uint16 usQueryPort; uint16 usQueryPort;
SteamGameServerClient(); load_old_interface_versions();
bool logon_anon = false; bool logon_anon = false;
if (strcmp(old_gameserver, "SteamGameServer010") == 0 || strstr(old_gameserver, "SteamGameServer00") == old_gameserver) { if (strcmp(old_gameserver, "SteamGameServer010") == 0 || strstr(old_gameserver, "SteamGameServer00") == old_gameserver) {
PRINT_DEBUG("Old game server init\n"); PRINT_DEBUG("Old game server init\n");
@ -565,6 +565,7 @@ S_API void SteamGameServer_Shutdown()
{ {
PRINT_DEBUG("SteamGameServer_Shutdown\n"); PRINT_DEBUG("SteamGameServer_Shutdown\n");
get_steam_clientserver_old()->serverShutdown(); get_steam_clientserver_old()->serverShutdown();
g_pSteamClientGameServer = NULL; //TODO: check if this actually gets nulled when SteamGameServer_Shutdown is called
} }
S_API void SteamGameServer_RunCallbacks() S_API void SteamGameServer_RunCallbacks()
@ -587,7 +588,6 @@ S_API uint64 SteamGameServer_GetSteamID()
S_API ISteamClient *SteamGameServerClient() { S_API ISteamClient *SteamGameServerClient() {
PRINT_DEBUG("SteamGameServerClient()\n"); PRINT_DEBUG("SteamGameServerClient()\n");
load_old_interface_versions();
if (!get_steam_clientserver_old()->IsServerInit()) return NULL; if (!get_steam_clientserver_old()->IsServerInit()) return NULL;
return (ISteamClient *)SteamInternal_CreateInterface(old_client); return (ISteamClient *)SteamInternal_CreateInterface(old_client);
} }