Warn if trying to init steam client AFTER steam server

This commit is contained in:
Garry Newman 2017-12-06 13:23:36 +00:00
parent d60ebf5fdd
commit 1ccea72a13

View File

@ -29,11 +29,11 @@ namespace Facepunch.Steamworks.Interop
private bool isServer;
private HSteamUser hUser;
private HSteamPipe hPipe;
internal bool InitClient( BaseSteamworks steamworks )
{
if ( Steamworks.Server.Instance != null )
throw new System.Exception("Steam client should be initialized before steam server - or there's big trouble.");
isServer = false;
api = new SteamNative.SteamApi();
@ -44,8 +44,8 @@ namespace Facepunch.Steamworks.Interop
return false;
}
hUser = api.SteamAPI_GetHSteamUser();
hPipe = api.SteamAPI_GetHSteamPipe();
var hUser = api.SteamAPI_GetHSteamUser();
var hPipe = api.SteamAPI_GetHSteamPipe();
if ( hPipe == 0 )
{
Console.Error.WriteLine( "InitClient: hPipe == 0" );
@ -83,8 +83,8 @@ namespace Facepunch.Steamworks.Interop
return false;
}
hUser = api.SteamGameServer_GetHSteamUser();
hPipe = api.SteamGameServer_GetHSteamPipe();
var hUser = api.SteamGameServer_GetHSteamUser();
var hPipe = api.SteamGameServer_GetHSteamPipe();
if ( hPipe == 0 )
{
Console.Error.WriteLine( "InitServer: hPipe == 0" );
@ -216,6 +216,12 @@ namespace Facepunch.Steamworks.Interop
remoteStorage = null;
}
if ( matchmaking != null )
{
matchmaking.Dispose();
matchmaking = null;
}
if ( applist != null )
{
applist.Dispose();
@ -242,9 +248,6 @@ namespace Facepunch.Steamworks.Interop
// pointers we stored are not invalid.
//
hPipe = 0;
hUser = 0;
api.Dispose();
api = null;
}