From 79f398da0424fbcdedeb8ba5f0ae44e6dbf13793 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Thu, 17 Aug 2017 12:00:29 +0100 Subject: [PATCH] Throw exception if trying to initialize without destroying old instance --- Facepunch.Steamworks/Client.cs | 5 +++++ Facepunch.Steamworks/Server.cs | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Facepunch.Steamworks/Client.cs b/Facepunch.Steamworks/Client.cs index e46e5e4..32419bd 100644 --- a/Facepunch.Steamworks/Client.cs +++ b/Facepunch.Steamworks/Client.cs @@ -65,6 +65,11 @@ public partial class Client : BaseSteamworks public Client( uint appId ) { + if ( Instance != null ) + { + throw new System.Exception( "Only one Facepunch.Steamworks.Client can exist - dispose the old one before trying to create a new one." ); + } + Instance = this; native = new Interop.NativeInterface(); diff --git a/Facepunch.Steamworks/Server.cs b/Facepunch.Steamworks/Server.cs index da274e0..01c21d4 100644 --- a/Facepunch.Steamworks/Server.cs +++ b/Facepunch.Steamworks/Server.cs @@ -26,6 +26,11 @@ public partial class Server : BaseSteamworks /// public Server( uint appId, ServerInit init ) { + if ( Instance != null ) + { + throw new System.Exception( "Only one Facepunch.Steamworks.Server can exist - dispose the old one before trying to create a new one." ); + } + Instance = this; native = new Interop.NativeInterface();