diff --git a/Facepunch.Steamworks/Interop/Native.cs b/Facepunch.Steamworks/Interop/Native.cs index f79b74b..879febd 100644 --- a/Facepunch.Steamworks/Interop/Native.cs +++ b/Facepunch.Steamworks/Interop/Native.cs @@ -116,27 +116,6 @@ public void FillInterfaces( BaseSteamworks steamworks, int hpipe, int huser ) public void Dispose() { - if ( client != null ) - { - if ( hPipe != 0 ) - { - if ( hUser != 0 ) - { - client.ReleaseUser( hPipe, hUser ); - hUser = 0; - } - - client.BReleaseSteamPipe( hPipe ); - hPipe = 0; - } - - if ( !client.BShutdownIfAllPipesClosed() ) - Console.WriteLine( "BShutdownIfAllPipesClosed returned false" ); - - client.Dispose(); - client = null; - } - if ( user != null ) { user.Dispose(); @@ -186,12 +165,7 @@ public void Dispose() } if ( gameServer != null ) - { - // - // Calling this can cause the process to hang - // - //gameServer.LogOff(); - + { gameServer.Dispose(); gameServer = null; } @@ -232,6 +206,12 @@ public void Dispose() applist = null; } + if ( client != null ) + { + client.Dispose(); + client = null; + } + if ( api != null ) { if ( isServer ) @@ -239,6 +219,16 @@ public void Dispose() else api.SteamAPI_Shutdown(); + // + // The functions above destroy the pipeline handles + // and all of the classes. Trying to call a steam function + // at this point will result in a crash - because any + // pointers we stored are not invalid. + // + + hPipe = 0; + hUser = 0; + api.Dispose(); api = null; }