Handle Steam not running better

This commit is contained in:
Rubat 2021-05-20 19:04:12 +03:00
parent 1bae585602
commit 7a04765805
24 changed files with 115 additions and 32 deletions

View File

@ -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()

View File

@ -73,9 +73,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>();

View File

@ -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;

View File

@ -1,4 +1,5 @@
using Steamworks.Data;
using System;
using Steamworks.Data;
using System.Collections.Generic;
namespace Steamworks
@ -7,9 +8,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;

View File

@ -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 )

View File

@ -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>

View File

@ -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;
}
}
}

View File

@ -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()

View File

@ -12,11 +12,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 )

View File

@ -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

View File

@ -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 )

View File

@ -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 )

View File

@ -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 )

View File

@ -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 )

View File

@ -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;
}

View File

@ -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()

View File

@ -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;

View File

@ -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;
}

View File

@ -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 )

View File

@ -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;

View File

@ -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; }

View File

@ -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 )

View File

@ -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()

View File

@ -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 )