diff --git a/SAM.API/CallHandle.cs b/SAM.API/CallHandle.cs new file mode 100644 index 0000000..4c21e64 --- /dev/null +++ b/SAM.API/CallHandle.cs @@ -0,0 +1,29 @@ +/* Copyright (c) 2024 Rick (rick 'at' gibbed 'dot' us) + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would + * be appreciated but is not required. + * + * 2. Altered source versions must be plainly marked as such, and must not + * be misrepresented as being the original software. + * + * 3. This notice may not be removed or altered from any source + * distribution. + */ + +namespace SAM.API +{ + public enum CallHandle : ulong + { + Invalid = 0, + } +} diff --git a/SAM.API/Client.cs b/SAM.API/Client.cs index a4a2a02..b58c1ec 100644 --- a/SAM.API/Client.cs +++ b/SAM.API/Client.cs @@ -142,8 +142,7 @@ public void RunCallbacks(bool server) this._RunningCallbacks = true; Types.CallbackMessage message; - int call; - while (Steam.GetCallback(this._Pipe, out message, out call) == true) + while (Steam.GetCallback(this._Pipe, out message, out _) == true) { var callbackId = message.Id; foreach (ICallback callback in this._Callbacks.Where( @@ -152,7 +151,6 @@ public void RunCallbacks(bool server) { callback.Run(message.ParamPointer); } - Steam.FreeLastCallback(this._Pipe); } diff --git a/SAM.API/Wrappers/SteamUserStats013.cs b/SAM.API/Wrappers/SteamUserStats013.cs index db42723..51b9ebc 100644 --- a/SAM.API/Wrappers/SteamUserStats013.cs +++ b/SAM.API/Wrappers/SteamUserStats013.cs @@ -189,12 +189,11 @@ public string GetAchievementDisplayAttribute(string name, string key) #region RequestUserStats [UnmanagedFunctionPointer(CallingConvention.ThisCall)] - [return: MarshalAs(UnmanagedType.I1)] - private delegate bool NativeRequestUserStats(IntPtr self, ulong steamIdUser); + private delegate CallHandle NativeRequestUserStats(IntPtr self, ulong steamIdUser); - public bool RequestUserStats(ulong steamIdUser) + public CallHandle RequestUserStats(ulong steamIdUser) { - return this.Call(this.Functions.RequestUserStats, this.ObjectAddress, steamIdUser); + return this.Call(this.Functions.RequestUserStats, this.ObjectAddress, steamIdUser); } #endregion diff --git a/SAM.Game/Manager.cs b/SAM.Game/Manager.cs index c016b06..f08763c 100644 --- a/SAM.Game/Manager.cs +++ b/SAM.Game/Manager.cs @@ -403,7 +403,10 @@ private void RefreshStats() var steamId = this._SteamClient.SteamUser.GetSteamId(); - if (this._SteamClient.SteamUserStats.RequestUserStats(steamId) == false) + // This still triggers the UserStatsReceived callback, in addition to the callresult. + // No need to implement callresults for the time being. + var callHandle = this._SteamClient.SteamUserStats.RequestUserStats(steamId); + if (callHandle == API.CallHandle.Invalid) { MessageBox.Show(this, "Failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return;