From 3bfc441355be2752020218b08e0479722a33cab7 Mon Sep 17 00:00:00 2001 From: Garry Newman Date: Mon, 10 Feb 2020 20:32:32 +0000 Subject: [PATCH] Name fixes --- .../Generated/Interfaces/ISteamUserStats.cs | 8 ++--- Facepunch.Steamworks/SteamServer.cs | 30 ++++++------------- Facepunch.Steamworks/SteamUserStats.cs | 8 ++--- Facepunch.Steamworks/Structs/Stat.cs | 24 +++++++-------- Facepunch.Steamworks/Structs/UgcQuery.cs | 4 +-- Generator/steam_sdk/steam_api.json | 2 +- 6 files changed, 32 insertions(+), 44 deletions(-) diff --git a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs index fabae7b..4d4d8ec 100644 --- a/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs +++ b/Facepunch.Steamworks/Generated/Interfaces/ISteamUserStats.cs @@ -60,14 +60,14 @@ internal bool SetStat( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef } #region FunctionMeta - [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamUserStats_SetStat")] + [DllImport( Platform.LibraryName, EntryPoint = "SteamAPI_ISteamUserStats_SetStat0")] [return: MarshalAs( UnmanagedType.I1 )] - private static extern bool _SetStat( IntPtr self, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchName, float fData ); + private static extern bool _SetStat0( IntPtr self, [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchName, float fData ); #endregion - internal bool SetStat( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchName, float fData ) + internal bool SetStat0( [MarshalAs( UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof( Utf8StringToNative ) )] string pchName, float fData ) { - var returnValue = _SetStat( Self, pchName, fData ); + var returnValue = _SetStat0( Self, pchName, fData ); return returnValue; } diff --git a/Facepunch.Steamworks/SteamServer.cs b/Facepunch.Steamworks/SteamServer.cs index cbe61b6..5746735 100644 --- a/Facepunch.Steamworks/SteamServer.cs +++ b/Facepunch.Steamworks/SteamServer.cs @@ -10,26 +10,18 @@ namespace Steamworks /// /// Provides the core of the Steam Game Servers API /// - public static partial class SteamServer + public partial class SteamServer : SteamClass { - static bool initialized; + internal static ISteamGameServer Internal; + internal override SteamInterface Interface => Internal; - static ISteamGameServer _internal; - internal static ISteamGameServer Internal + internal override void InitializeInterface() { - get - { - if ( _internal == null ) - { - _internal = new ISteamGameServer( ); - _internal.InitServer(); - } - - return _internal; - } + Internal = new ISteamGameServer(); + InstallEvents(); } - public static bool IsValid => initialized; + public static bool IsValid => Internal != null && Internal.IsValid; public static Action OnCallbackException; @@ -93,8 +85,6 @@ public static void Init( AppId appid, SteamServerInit init, bool asyncCallbacks throw new System.Exception( $"InitGameServer returned false ({ipaddress},{init.SteamPort},{init.GamePort},{init.QueryPort},{secure},\"{init.VersionString}\")" ); } - initialized = true; - // // Initial settings // @@ -129,7 +119,7 @@ internal static void ShutdownInterfaces() { foreach ( var e in openIterfaces ) { - e.Shutdown(); + e.ShutdownInterface(); } openIterfaces.Clear(); @@ -139,9 +129,7 @@ public static void Shutdown() { Event.DisposeAllServer(); - initialized = false; - - _internal = null; + Internal = null; ShutdownInterfaces(); SteamGameServer.Shutdown(); diff --git a/Facepunch.Steamworks/SteamUserStats.cs b/Facepunch.Steamworks/SteamUserStats.cs index 10d2ad5..7cd869e 100644 --- a/Facepunch.Steamworks/SteamUserStats.cs +++ b/Facepunch.Steamworks/SteamUserStats.cs @@ -197,7 +197,7 @@ public static bool AddStat( string name, float amount = 1.0f ) /// public static bool SetStat( string name, int value ) { - return Internal.SetStat1( name, value ); + return Internal.SetStat( name, value ); } /// @@ -206,7 +206,7 @@ public static bool SetStat( string name, int value ) /// public static bool SetStat( string name, float value ) { - return Internal.SetStat2( name, value ); + return Internal.SetStat0( name, value ); } /// @@ -215,7 +215,7 @@ public static bool SetStat( string name, float value ) public static int GetStatInt( string name ) { int data = 0; - Internal.GetStat1( name, ref data ); + Internal.GetStat( name, ref data ); return data; } @@ -225,7 +225,7 @@ public static int GetStatInt( string name ) public static float GetStatFloat( string name ) { float data = 0; - Internal.GetStat2( name, ref data ); + Internal.GetStat0( name, ref data ); return data; } diff --git a/Facepunch.Steamworks/Structs/Stat.cs b/Facepunch.Steamworks/Structs/Stat.cs index 1a17861..889de0d 100644 --- a/Facepunch.Steamworks/Structs/Stat.cs +++ b/Facepunch.Steamworks/Structs/Stat.cs @@ -36,7 +36,7 @@ public double GetGlobalFloat() { double val = 0.0; - if ( SteamUserStats.Internal.GetGlobalStat2( Name, ref val ) ) + if ( SteamUserStats.Internal.GetGlobalStat0( Name, ref val ) ) return val; return 0; @@ -45,18 +45,18 @@ public double GetGlobalFloat() public long GetGlobalInt() { long val = 0; - SteamUserStats.Internal.GetGlobalStat1( Name, ref val ); + SteamUserStats.Internal.GetGlobalStat( Name, ref val ); return val; } public async Task GetGlobalIntDaysAsync( int days ) { - var result = await SteamUserStats.Internal.RequestGlobalStats( days ); + var result = await SteamUserStats.Internal.RequestGlobalStats( days ).GetAsync(); if ( result?.Result != Result.OK ) return null; var r = new long[days]; - var rows = SteamUserStats.Internal.GetGlobalStatHistory1( Name, r, (uint) r.Length * sizeof(long) ); + var rows = SteamUserStats.Internal.GetGlobalStatHistory( Name, r, (uint) r.Length * sizeof(long) ); if ( days != rows ) r = r.Take( rows ).ToArray(); @@ -66,12 +66,12 @@ public async Task GetGlobalIntDaysAsync( int days ) public async Task GetGlobalFloatDays( int days ) { - var result = await SteamUserStats.Internal.RequestGlobalStats( days ); + var result = await SteamUserStats.Internal.RequestGlobalStats( days ).GetAsync(); if ( result?.Result != Result.OK ) return null; var r = new double[days]; - var rows = SteamUserStats.Internal.GetGlobalStatHistory2( Name, r, (uint)r.Length * sizeof( double ) ); + var rows = SteamUserStats.Internal.GetGlobalStatHistory0( Name, r, (uint)r.Length * sizeof( double ) ); if ( days != rows ) r = r.Take( rows ).ToArray(); @@ -85,11 +85,11 @@ public float GetFloat() if ( UserId > 0 ) { - SteamUserStats.Internal.GetUserStat2( UserId, Name, ref val ); + SteamUserStats.Internal.GetUserStat0( UserId, Name, ref val ); } else { - SteamUserStats.Internal.GetStat2( Name, ref val ); + SteamUserStats.Internal.GetStat0( Name, ref val ); } return 0; @@ -101,11 +101,11 @@ public int GetInt() if ( UserId > 0 ) { - SteamUserStats.Internal.GetUserStat1( UserId, Name, ref val ); + SteamUserStats.Internal.GetUserStat( UserId, Name, ref val ); } else { - SteamUserStats.Internal.GetStat1( Name, ref val ); + SteamUserStats.Internal.GetStat( Name, ref val ); } return val; @@ -114,13 +114,13 @@ public int GetInt() public bool Set( int val ) { LocalUserOnly(); - return SteamUserStats.Internal.SetStat1( Name, val ); + return SteamUserStats.Internal.SetStat( Name, val ); } public bool Set( float val ) { LocalUserOnly(); - return SteamUserStats.Internal.SetStat2( Name, val ); + return SteamUserStats.Internal.SetStat0( Name, val ); } public bool Add( int val ) diff --git a/Facepunch.Steamworks/Structs/UgcQuery.cs b/Facepunch.Steamworks/Structs/UgcQuery.cs index 986bdcd..e450b1d 100644 --- a/Facepunch.Steamworks/Structs/UgcQuery.cs +++ b/Facepunch.Steamworks/Structs/UgcQuery.cs @@ -124,7 +124,7 @@ public Query WithFileId( params PublishedFileId[] files ) } else { - handle = SteamUGC.Internal.CreateQueryAllUGCRequest1( queryType, matchingType, creatorApp.Value, consumerApp.Value, (uint)page ); + handle = SteamUGC.Internal.CreateQueryAllUGCRequest( queryType, matchingType, creatorApp.Value, consumerApp.Value, (uint)page ); } ApplyReturns(handle); @@ -136,7 +136,7 @@ public Query WithFileId( params PublishedFileId[] files ) ApplyConstraints( handle ); - var result = await SteamUGC.Internal.SendQueryUGCRequest( handle ); + var result = await SteamUGC.Internal.SendQueryUGCRequest( handle ).GetAsync(); if ( !result.HasValue ) return null; diff --git a/Generator/steam_sdk/steam_api.json b/Generator/steam_sdk/steam_api.json index 47c3c55..e4f8ce6 100644 --- a/Generator/steam_sdk/steam_api.json +++ b/Generator/steam_sdk/steam_api.json @@ -5346,7 +5346,7 @@ } ,{ "classname": "ISteamUserStats", - "methodname": "SetStat", + "methodname": "SetStat0", "returntype": "bool", "params": [ { "paramname": "pchName" ,"paramtype": "const char *"},