From 3c2eeb7f2fcca3c1609452beedf627de6ef43861 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Sat, 17 Aug 2019 11:52:56 +0100 Subject: [PATCH] Throw exceptions if trying to use client interfaces with no client --- Facepunch.Steamworks/SteamClient.cs | 9 +++++++++ Facepunch.Steamworks/SteamFriends.cs | 2 ++ Facepunch.Steamworks/SteamInput.cs | 2 ++ Facepunch.Steamworks/SteamMatchmaking.cs | 2 ++ Facepunch.Steamworks/SteamMusic.cs | 2 ++ Facepunch.Steamworks/SteamParental.cs | 2 ++ Facepunch.Steamworks/SteamScreenshots.cs | 2 ++ Facepunch.Steamworks/SteamUser.cs | 2 ++ Facepunch.Steamworks/SteamUserStats.cs | 2 ++ Facepunch.Steamworks/SteamVideo.cs | 2 ++ 10 files changed, 27 insertions(+) diff --git a/Facepunch.Steamworks/SteamClient.cs b/Facepunch.Steamworks/SteamClient.cs index 32dfe08..c628488 100644 --- a/Facepunch.Steamworks/SteamClient.cs +++ b/Facepunch.Steamworks/SteamClient.cs @@ -200,5 +200,14 @@ namespace Steamworks return SteamAPI.RestartAppIfNecessary( appid ); } + /// + /// Called in interfaces that rely on this being initialized + /// + internal static void ValidCheck() + { + if ( !IsValid ) + throw new System.Exception( "SteamClient isn't initialized" ); + } + } } \ No newline at end of file diff --git a/Facepunch.Steamworks/SteamFriends.cs b/Facepunch.Steamworks/SteamFriends.cs index 62580b0..5acefbb 100644 --- a/Facepunch.Steamworks/SteamFriends.cs +++ b/Facepunch.Steamworks/SteamFriends.cs @@ -17,6 +17,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamFriends(); diff --git a/Facepunch.Steamworks/SteamInput.cs b/Facepunch.Steamworks/SteamInput.cs index af3c485..baba1c1 100644 --- a/Facepunch.Steamworks/SteamInput.cs +++ b/Facepunch.Steamworks/SteamInput.cs @@ -12,6 +12,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamInput(); diff --git a/Facepunch.Steamworks/SteamMatchmaking.cs b/Facepunch.Steamworks/SteamMatchmaking.cs index 2f3a4d6..71c2c22 100644 --- a/Facepunch.Steamworks/SteamMatchmaking.cs +++ b/Facepunch.Steamworks/SteamMatchmaking.cs @@ -24,6 +24,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamMatchmaking(); diff --git a/Facepunch.Steamworks/SteamMusic.cs b/Facepunch.Steamworks/SteamMusic.cs index 825d179..ac45724 100644 --- a/Facepunch.Steamworks/SteamMusic.cs +++ b/Facepunch.Steamworks/SteamMusic.cs @@ -20,6 +20,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamMusic(); diff --git a/Facepunch.Steamworks/SteamParental.cs b/Facepunch.Steamworks/SteamParental.cs index b2c6e18..4be1016 100644 --- a/Facepunch.Steamworks/SteamParental.cs +++ b/Facepunch.Steamworks/SteamParental.cs @@ -17,6 +17,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamParentalSettings(); diff --git a/Facepunch.Steamworks/SteamScreenshots.cs b/Facepunch.Steamworks/SteamScreenshots.cs index f4ad5bd..6b83fe5 100644 --- a/Facepunch.Steamworks/SteamScreenshots.cs +++ b/Facepunch.Steamworks/SteamScreenshots.cs @@ -17,6 +17,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamScreenshots(); diff --git a/Facepunch.Steamworks/SteamUser.cs b/Facepunch.Steamworks/SteamUser.cs index 7079025..0f0d06a 100644 --- a/Facepunch.Steamworks/SteamUser.cs +++ b/Facepunch.Steamworks/SteamUser.cs @@ -20,6 +20,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamUser(); diff --git a/Facepunch.Steamworks/SteamUserStats.cs b/Facepunch.Steamworks/SteamUserStats.cs index 0b9dc9f..241ff42 100644 --- a/Facepunch.Steamworks/SteamUserStats.cs +++ b/Facepunch.Steamworks/SteamUserStats.cs @@ -14,6 +14,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamUserStats(); diff --git a/Facepunch.Steamworks/SteamVideo.cs b/Facepunch.Steamworks/SteamVideo.cs index 66c6c3f..2d2a632 100644 --- a/Facepunch.Steamworks/SteamVideo.cs +++ b/Facepunch.Steamworks/SteamVideo.cs @@ -17,6 +17,8 @@ namespace Steamworks { get { + SteamClient.ValidCheck(); + if ( _internal == null ) { _internal = new ISteamVideo();