mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-27 15:15:51 +03:00
Handle steam shutdown nicer
This commit is contained in:
parent
38b1ed5f88
commit
c6c73a36e9
@ -79,13 +79,23 @@ internal static async void RunCallbacksAsync()
|
|||||||
|
|
||||||
public static void Shutdown()
|
public static void Shutdown()
|
||||||
{
|
{
|
||||||
Event.DisposeAllClient();
|
if ( !IsValid ) return;
|
||||||
|
|
||||||
initialized = false;
|
|
||||||
|
|
||||||
SteamInput.Shutdown();
|
SteamInput.Shutdown();
|
||||||
|
|
||||||
|
Cleanup();
|
||||||
|
|
||||||
|
SteamAPI.Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void Cleanup()
|
||||||
|
{
|
||||||
|
initialized = false;
|
||||||
|
|
||||||
|
Event.DisposeAllClient();
|
||||||
ShutdownInterfaces();
|
ShutdownInterfaces();
|
||||||
|
|
||||||
|
SteamInput.Shutdown();
|
||||||
SteamApps.Shutdown();
|
SteamApps.Shutdown();
|
||||||
SteamUtils.Shutdown();
|
SteamUtils.Shutdown();
|
||||||
SteamParental.Shutdown();
|
SteamParental.Shutdown();
|
||||||
@ -101,10 +111,7 @@ public static void Shutdown()
|
|||||||
SteamParties.Shutdown();
|
SteamParties.Shutdown();
|
||||||
SteamNetworkingUtils.Shutdown();
|
SteamNetworkingUtils.Shutdown();
|
||||||
SteamNetworkingSockets.Shutdown();
|
SteamNetworkingSockets.Shutdown();
|
||||||
|
|
||||||
ServerList.Base.Shutdown();
|
ServerList.Base.Shutdown();
|
||||||
|
|
||||||
SteamAPI.Shutdown();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void RegisterCallback( IntPtr intPtr, int callbackId )
|
internal static void RegisterCallback( IntPtr intPtr, int callbackId )
|
||||||
@ -114,6 +121,8 @@ internal static void RegisterCallback( IntPtr intPtr, int callbackId )
|
|||||||
|
|
||||||
public static void RunCallbacks()
|
public static void RunCallbacks()
|
||||||
{
|
{
|
||||||
|
if ( !IsValid ) return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SteamAPI.RunCallbacks();
|
SteamAPI.RunCallbacks();
|
||||||
|
@ -24,7 +24,11 @@ internal static ISteamInput Internal
|
|||||||
|
|
||||||
internal static void Shutdown()
|
internal static void Shutdown()
|
||||||
{
|
{
|
||||||
_internal?.DoShutdown();
|
if ( _internal != null && _internal.IsValid )
|
||||||
|
{
|
||||||
|
_internal.DoShutdown();
|
||||||
|
}
|
||||||
|
|
||||||
_internal = null;
|
_internal = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +36,17 @@ internal static void InstallEvents()
|
|||||||
{
|
{
|
||||||
IPCountry_t.Install( x => OnIpCountryChanged?.Invoke() );
|
IPCountry_t.Install( x => OnIpCountryChanged?.Invoke() );
|
||||||
LowBatteryPower_t.Install( x => OnLowBatteryPower?.Invoke( x.MinutesBatteryLeft ) );
|
LowBatteryPower_t.Install( x => OnLowBatteryPower?.Invoke( x.MinutesBatteryLeft ) );
|
||||||
SteamShutdown_t.Install( x => OnSteamShutdown?.Invoke() );
|
SteamShutdown_t.Install( x => SteamClosed() );
|
||||||
GamepadTextInputDismissed_t.Install( x => OnGamepadTextInputDismissed?.Invoke( x.Submitted ) );
|
GamepadTextInputDismissed_t.Install( x => OnGamepadTextInputDismissed?.Invoke( x.Submitted ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void SteamClosed()
|
||||||
|
{
|
||||||
|
SteamClient.Cleanup();
|
||||||
|
|
||||||
|
OnSteamShutdown?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The country of the user changed
|
/// The country of the user changed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -34,7 +34,7 @@ internal static class Platform
|
|||||||
|
|
||||||
public static int MemoryOffset( int memLocation )
|
public static int MemoryOffset( int memLocation )
|
||||||
{
|
{
|
||||||
#if PLATFORM_WIN64 || PLATFORM_POSIX64
|
#if PLATFORM_64
|
||||||
return memLocation;
|
return memLocation;
|
||||||
#else
|
#else
|
||||||
return memLocation / 2;
|
return memLocation / 2;
|
||||||
|
@ -15,6 +15,7 @@ internal abstract class SteamInterface
|
|||||||
public IntPtr VTable;
|
public IntPtr VTable;
|
||||||
|
|
||||||
public virtual string InterfaceName => null;
|
public virtual string InterfaceName => null;
|
||||||
|
public bool IsValid => Self != IntPtr.Zero && VTable != IntPtr.Zero;
|
||||||
|
|
||||||
public void Init()
|
public void Init()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user