From 59eabc1302815fce59930cdb49a7ce28812e4ecd Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Tue, 25 Feb 2020 12:42:09 +0000 Subject: [PATCH] Throw exception if trying to initialize multiple times --- Facepunch.Steamworks/SteamClient.cs | 3 +++ Facepunch.Steamworks/SteamServer.cs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/Facepunch.Steamworks/SteamClient.cs b/Facepunch.Steamworks/SteamClient.cs index 49b923b..cee212e 100644 --- a/Facepunch.Steamworks/SteamClient.cs +++ b/Facepunch.Steamworks/SteamClient.cs @@ -17,6 +17,9 @@ namespace Steamworks /// public static void Init( uint appid, bool asyncCallbacks = true ) { + if ( initialized ) + throw new System.Exception( "Calling SteamClient.Init but is already initialized" ); + System.Environment.SetEnvironmentVariable( "SteamAppId", appid.ToString() ); System.Environment.SetEnvironmentVariable( "SteamGameId", appid.ToString() ); diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs index eca72d8..61a3a80 100644 --- a/Facepunch.Steamworks/SteamServer.cs +++ b/Facepunch.Steamworks/SteamServer.cs @@ -61,6 +61,9 @@ namespace Steamworks /// public static void Init( AppId appid, SteamServerInit init, bool asyncCallbacks = true ) { + if ( IsValid ) + throw new System.Exception( "Calling SteamServer.Init but is already initialized" ); + uint ipaddress = 0; // Any Port if ( init.SteamPort == 0 )