diff --git a/Facepunch.Steamworks/SteamClient.cs b/Facepunch.Steamworks/SteamClient.cs index f24e711..d520225 100644 --- a/Facepunch.Steamworks/SteamClient.cs +++ b/Facepunch.Steamworks/SteamClient.cs @@ -58,23 +58,17 @@ public static void Init( uint appid, bool asyncCallbacks = true ) internal static void AddInterface() where T : SteamClass, new() { var t = new T(); + t.InitializeInterface(); + openInterfaces.Add( t ); } - static List openInterfaces = new List(); - - internal static void WatchInterface( SteamInterface steamInterface ) - { - if ( openInterfaces.Contains( steamInterface ) ) - throw new System.Exception( "openIterfaces already contains interface!" ); - - openInterfaces.Add( steamInterface ); - } + static List openInterfaces = new List(); internal static void ShutdownInterfaces() { foreach ( var e in openInterfaces ) { - e.ShutdownInterface(); + e.DestroyInterface(); } openInterfaces.Clear(); diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs index 75e4c6e..0f572cb 100644 --- a/Facepunch.Steamworks/SteamServer.cs +++ b/Facepunch.Steamworks/SteamServer.cs @@ -85,7 +85,7 @@ public static void Init( AppId appid, SteamServerInit init, bool asyncCallbacks throw new System.Exception( $"InitGameServer returned false ({ipaddress},{init.SteamPort},{init.GamePort},{init.QueryPort},{secure},\"{init.VersionString}\")" ); } - Install + AddInterface(); // // Initial settings @@ -107,24 +107,23 @@ public static void Init( AppId appid, SteamServerInit init, bool asyncCallbacks } } - static List openIterfaces = new List(); - - internal static void WatchInterface( SteamInterface steamInterface ) + internal static void AddInterface() where T : SteamClass, new() { - if ( openIterfaces.Contains( steamInterface ) ) - throw new System.Exception( "openIterfaces already contains interface!" ); - - openIterfaces.Add( steamInterface ); + var t = new T(); + t.InitializeInterface(); + openInterfaces.Add( t ); } + static List openInterfaces = new List(); + internal static void ShutdownInterfaces() { - foreach ( var e in openIterfaces ) + foreach ( var e in openInterfaces ) { - e.ShutdownInterface(); + e.DestroyInterface(); } - openIterfaces.Clear(); + openInterfaces.Clear(); } public static void Shutdown() diff --git a/Facepunch.Steamworks/Utility/SteamInterface.cs b/Facepunch.Steamworks/Utility/SteamInterface.cs index 9806e88..e4866c4 100644 --- a/Facepunch.Steamworks/Utility/SteamInterface.cs +++ b/Facepunch.Steamworks/Utility/SteamInterface.cs @@ -31,7 +31,7 @@ internal void ShutdownInterface() public abstract class SteamClass { internal abstract void InitializeInterface(); - internal void DestroyInterface() + internal virtual void DestroyInterface() { Interface.ShutdownInterface(); }