mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-25 14:15:47 +03:00
Handle Steam not running better (#566)
* Handle Steam not running better * Make Steamworks.SteamClient.IsValid is correct without Steam Make sure Steamworks.SteamClient.IsValid is correct without Steam running
This commit is contained in:
parent
aab6d0d081
commit
814488652b
@ -15,9 +15,12 @@ public class SteamApps : SteamSharedClass<SteamApps>
|
||||
{
|
||||
internal static ISteamApps Internal => Interface as ISteamApps;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamApps( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents()
|
||||
|
@ -60,6 +60,8 @@ public static void Init( uint appid, bool asyncCallbacks = true )
|
||||
AddInterface<SteamVideo>();
|
||||
AddInterface<SteamRemotePlay>();
|
||||
|
||||
initialized = openInterfaces.Count > 0;
|
||||
|
||||
if ( asyncCallbacks )
|
||||
{
|
||||
//
|
||||
@ -73,9 +75,16 @@ public static void Init( uint appid, bool asyncCallbacks = true )
|
||||
internal static void AddInterface<T>() where T : SteamClass, new()
|
||||
{
|
||||
var t = new T();
|
||||
t.InitializeInterface( false );
|
||||
bool valid = t.InitializeInterface( false );
|
||||
if ( valid )
|
||||
{
|
||||
openInterfaces.Add( t );
|
||||
}
|
||||
else
|
||||
{
|
||||
t.DestroyInterface( false );
|
||||
}
|
||||
}
|
||||
|
||||
static readonly List<SteamClass> openInterfaces = new List<SteamClass>();
|
||||
|
||||
|
@ -14,13 +14,16 @@ public class SteamFriends : SteamClientClass<SteamFriends>
|
||||
{
|
||||
internal static ISteamFriends Internal => Interface as ISteamFriends;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamFriends( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
richPresence = new Dictionary<string, string>();
|
||||
|
||||
InstallEvents();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static Dictionary<string, string> richPresence;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using Steamworks.Data;
|
||||
using System;
|
||||
using Steamworks.Data;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Steamworks
|
||||
@ -10,9 +11,12 @@ public class SteamInput : SteamClientClass<SteamInput>
|
||||
{
|
||||
internal static ISteamInput Internal => Interface as ISteamInput;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamInput( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal const int STEAM_CONTROLLER_MAX_COUNT = 16;
|
||||
|
@ -16,11 +16,14 @@ public class SteamInventory : SteamSharedClass<SteamInventory>
|
||||
{
|
||||
internal static ISteamInventory Internal => Interface as ISteamInventory;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamInventory( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents( bool server )
|
||||
|
@ -14,11 +14,14 @@ public class SteamMatchmaking : SteamClientClass<SteamMatchmaking>
|
||||
{
|
||||
internal static ISteamMatchmaking Internal => Interface as ISteamMatchmaking;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamMatchmaking( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -14,9 +14,12 @@ internal class SteamMatchmakingServers : SteamClientClass<SteamMatchmakingServer
|
||||
{
|
||||
internal static ISteamMatchmakingServers Internal => Interface as ISteamMatchmakingServers;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamMatchmakingServers( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,13 @@ public class SteamMusic : SteamClientClass<SteamMusic>
|
||||
{
|
||||
internal static ISteamMusic Internal => Interface as ISteamMusic;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamMusic( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents();
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents()
|
||||
|
@ -15,11 +15,14 @@ public class SteamNetworking : SteamSharedClass<SteamNetworking>
|
||||
{
|
||||
internal static ISteamNetworking Internal => Interface as ISteamNetworking;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamNetworking( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents( bool server )
|
||||
|
@ -31,10 +31,13 @@ public static NetIdentity Identity
|
||||
}
|
||||
}
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamNetworkingSockets( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
return true;
|
||||
}
|
||||
|
||||
#region SocketInterface
|
||||
|
@ -14,10 +14,14 @@ public class SteamNetworkingUtils : SteamSharedClass<SteamNetworkingUtils>
|
||||
{
|
||||
internal static ISteamNetworkingUtils Internal => Interface as ISteamNetworkingUtils;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamNetworkingUtils( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallCallbacks( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void InstallCallbacks( bool server )
|
||||
|
@ -14,10 +14,14 @@ public class SteamParental : SteamSharedClass<SteamParental>
|
||||
{
|
||||
internal static ISteamParentalSettings Internal => Interface as ISteamParentalSettings;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamParentalSettings( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents( bool server )
|
||||
|
@ -17,10 +17,14 @@ public class SteamParties : SteamClientClass<SteamParties>
|
||||
{
|
||||
internal static ISteamParties Internal => Interface as ISteamParties;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamParties( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void InstallEvents( bool server )
|
||||
|
@ -14,11 +14,14 @@ public class SteamRemotePlay : SteamClientClass<SteamRemotePlay>
|
||||
{
|
||||
internal static ISteamRemotePlay Internal => Interface as ISteamRemotePlay;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamRemotePlay( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void InstallEvents( bool server )
|
||||
|
@ -14,9 +14,12 @@ public class SteamRemoteStorage : SteamClientClass<SteamRemoteStorage>
|
||||
{
|
||||
internal static ISteamRemoteStorage Internal => Interface as ISteamRemoteStorage;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamRemoteStorage( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,10 +14,14 @@ public class SteamScreenshots : SteamClientClass<SteamScreenshots>
|
||||
{
|
||||
internal static ISteamScreenshots Internal => Interface as ISteamScreenshots;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamScreenshots( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents()
|
||||
|
@ -14,10 +14,14 @@ public partial class SteamServer : SteamServerClass<SteamServer>
|
||||
{
|
||||
internal static ISteamGameServer Internal => Interface as ISteamGameServer;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamGameServer( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool IsValid => Internal != null && Internal.IsValid;
|
||||
|
@ -11,9 +11,12 @@ public class SteamServerStats : SteamServerClass<SteamServerStats>
|
||||
{
|
||||
internal static ISteamGameServerStats Internal => Interface as ISteamGameServerStats;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamGameServerStats( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,10 +17,14 @@ public class SteamUGC : SteamSharedClass<SteamUGC>
|
||||
{
|
||||
internal static ISteamUGC Internal => Interface as ISteamUGC;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamUGC( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents( bool server )
|
||||
|
@ -17,13 +17,17 @@ public class SteamUser : SteamClientClass<SteamUser>
|
||||
{
|
||||
internal static ISteamUser Internal => Interface as ISteamUser;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamUser( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents();
|
||||
|
||||
richPresence = new Dictionary<string, string>();
|
||||
SampleRate = OptimalSampleRate;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static Dictionary<string, string> richPresence;
|
||||
|
@ -11,11 +11,15 @@ public class SteamUserStats : SteamClientClass<SteamUserStats>
|
||||
{
|
||||
internal static ISteamUserStats Internal => Interface as ISteamUserStats;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamUserStats( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents();
|
||||
RequestCurrentStats();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool StatsRecieved { get; internal set; }
|
||||
|
@ -14,10 +14,14 @@ public class SteamUtils : SteamSharedClass<SteamUtils>
|
||||
{
|
||||
internal static ISteamUtils Internal => Interface as ISteamUtils;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamUtils( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents( server );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents( bool server )
|
||||
|
@ -14,10 +14,14 @@ public class SteamVideo : SteamClientClass<SteamVideo>
|
||||
{
|
||||
internal static ISteamVideo Internal => Interface as ISteamVideo;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
SetInterface( server, new ISteamVideo( server ) );
|
||||
if ( Interface.Self == IntPtr.Zero ) return false;
|
||||
|
||||
InstallEvents();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
internal static void InstallEvents()
|
||||
|
@ -55,7 +55,7 @@ internal void ShutdownInterface()
|
||||
|
||||
public abstract class SteamClass
|
||||
{
|
||||
internal abstract void InitializeInterface( bool server );
|
||||
internal abstract bool InitializeInterface( bool server );
|
||||
internal abstract void DestroyInterface( bool server );
|
||||
}
|
||||
|
||||
@ -65,9 +65,9 @@ public class SteamSharedClass<T> : SteamClass
|
||||
internal static SteamInterface InterfaceClient;
|
||||
internal static SteamInterface InterfaceServer;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal virtual void SetInterface( bool server, SteamInterface iface )
|
||||
@ -101,9 +101,9 @@ public class SteamClientClass<T> : SteamClass
|
||||
{
|
||||
internal static SteamInterface Interface;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal virtual void SetInterface( bool server, SteamInterface iface )
|
||||
@ -124,9 +124,9 @@ public class SteamServerClass<T> : SteamClass
|
||||
{
|
||||
internal static SteamInterface Interface;
|
||||
|
||||
internal override void InitializeInterface( bool server )
|
||||
internal override bool InitializeInterface( bool server )
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
internal virtual void SetInterface( bool server, SteamInterface iface )
|
||||
|
Loading…
Reference in New Issue
Block a user