Skip to content

Commit

Permalink
Warn if trying to init steam client AFTER steam server
Browse files Browse the repository at this point in the history
  • Loading branch information
garrynewman committed Dec 6, 2017
1 parent d60ebf5 commit 1ccea72
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Facepunch.Steamworks/Interop/Native.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ internal class NativeInterface : IDisposable

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();
Expand All @@ -44,8 +44,8 @@ internal bool InitClient( BaseSteamworks steamworks )
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" );
Expand Down Expand Up @@ -83,8 +83,8 @@ internal bool InitServer( BaseSteamworks steamworks, uint IpAddress /*uint32*/,
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" );
Expand Down Expand Up @@ -216,6 +216,12 @@ public void Dispose()
remoteStorage = null;
}

if ( matchmaking != null )
{
matchmaking.Dispose();
matchmaking = null;
}

if ( applist != null )
{
applist.Dispose();
Expand All @@ -242,9 +248,6 @@ public void Dispose()
// pointers we stored are not invalid.
//

hPipe = 0;
hUser = 0;

api.Dispose();
api = null;
}
Expand Down

0 comments on commit 1ccea72

Please sign in to comment.