Skip to content

Commit b3a66df

Browse files
committed
Use RequestUserStats.
- Replace SteamUserStats007 with SteamUserStats013. - Replace deprecated usage of RequestCurrentStats with RequestUserStats. Fixes #378 #389 #397 #398 #401 #411 #413
1 parent c2711eb commit b3a66df

File tree

5 files changed

+39
-27
lines changed

5 files changed

+39
-27
lines changed

SAM.API/Client.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class Client : IDisposable
3131
{
3232
public Wrappers.SteamClient018 SteamClient;
3333
public Wrappers.SteamUser012 SteamUser;
34-
public Wrappers.SteamUserStats007 SteamUserStats;
34+
public Wrappers.SteamUserStats013 SteamUserStats;
3535
public Wrappers.SteamUtils005 SteamUtils;
3636
public Wrappers.SteamApps001 SteamApps001;
3737
public Wrappers.SteamApps008 SteamApps008;
@@ -84,7 +84,7 @@ public void Initialize(long appId)
8484
}
8585

8686
this.SteamUser = this.SteamClient.GetSteamUser012(this._User, this._Pipe);
87-
this.SteamUserStats = this.SteamClient.GetSteamUserStats006(this._User, this._Pipe);
87+
this.SteamUserStats = this.SteamClient.GetSteamUserStats013(this._User, this._Pipe);
8888
this.SteamApps001 = this.SteamClient.GetSteamApps001(this._User, this._Pipe);
8989
this.SteamApps008 = this.SteamClient.GetSteamApps008(this._User, this._Pipe);
9090
}
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626
namespace SAM.API.Interfaces
2727
{
2828
[StructLayout(LayoutKind.Sequential, Pack = 1)]
29-
public class ISteamUserStats007
29+
public class ISteamUserStats013
3030
{
31-
public IntPtr RequestCurrentStats;
3231
public IntPtr GetStatFloat;
3332
public IntPtr GetStatInteger;
3433
public IntPtr SetStatFloat;
@@ -42,6 +41,8 @@ public class ISteamUserStats007
4241
public IntPtr GetAchievementIcon;
4342
public IntPtr GetAchievementDisplayAttribute;
4443
public IntPtr IndicateAchievementProgress;
44+
public IntPtr GetNumAchievements;
45+
public IntPtr GetAchievementName;
4546
public IntPtr RequestUserStats;
4647
public IntPtr GetUserStatFloat;
4748
public IntPtr GetUserStatInt;
@@ -55,8 +56,21 @@ public class ISteamUserStats007
5556
public IntPtr GetLeaderboardSortMethod;
5657
public IntPtr GetLeaderboardDisplayType;
5758
public IntPtr DownloadLeaderboardEntries;
59+
public IntPtr DownloadLeaderboardEntriesForUsers;
5860
public IntPtr GetDownloadedLeaderboardEntry;
5961
public IntPtr UploadLeaderboardScore;
62+
public IntPtr AttachLeaderboardUGC;
6063
public IntPtr GetNumberOfCurrentPlayers;
64+
public IntPtr RequestGlobalAchievementPercentages;
65+
public IntPtr GetMostAchievedAchievementInfo;
66+
public IntPtr GetNextMostAchievedAchievementInfo;
67+
public IntPtr GetAchievementAchievedPercent;
68+
public IntPtr RequestGlobalStats;
69+
public IntPtr GetGlobalStatFloat;
70+
public IntPtr GetGlobalStatInteger;
71+
public IntPtr GetGlobalStatHistoryFloat;
72+
public IntPtr GetGlobalStatHistoryInteger;
73+
public IntPtr GetAchievementProgressLimitsFloat;
74+
public IntPtr GetAchievementProgressLimitsInteger;
6175
}
6276
}

SAM.API/Wrappers/SteamClient018.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ private TClass GetISteamUserStats<TClass>(int user, int pipe, string version)
144144
}
145145
#endregion
146146

147-
#region GetSteamUserStats007
148-
public SteamUserStats007 GetSteamUserStats006(int user, int pipe)
147+
#region GetSteamUserStats013
148+
public SteamUserStats013 GetSteamUserStats013(int user, int pipe)
149149
{
150-
return this.GetISteamUserStats<SteamUserStats007>(user, pipe, "STEAMUSERSTATS_INTERFACE_VERSION007");
150+
return this.GetISteamUserStats<SteamUserStats013>(user, pipe, "STEAMUSERSTATS_INTERFACE_VERSION013");
151151
}
152152
#endregion
153153

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,8 @@
2626

2727
namespace SAM.API.Wrappers
2828
{
29-
public class SteamUserStats007 : NativeWrapper<ISteamUserStats007>
29+
public class SteamUserStats013 : NativeWrapper<ISteamUserStats013>
3030
{
31-
#region RequestCurrentStats
32-
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
33-
[return: MarshalAs(UnmanagedType.I1)]
34-
private delegate bool NativeRequestCurrentStats(IntPtr self);
35-
36-
public bool RequestCurrentStats()
37-
{
38-
return this.Call<bool, NativeRequestCurrentStats>(this.Functions.RequestCurrentStats, this.ObjectAddress);
39-
}
40-
#endregion
41-
4231
#region GetStatValue (int)
4332
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
4433
[return: MarshalAs(UnmanagedType.I1)]
@@ -198,6 +187,17 @@ public string GetAchievementDisplayAttribute(string name, string key)
198187
}
199188
#endregion
200189

190+
#region RequestUserStats
191+
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
192+
[return: MarshalAs(UnmanagedType.I1)]
193+
private delegate bool NativeRequestUserStats(IntPtr self, ulong steamIdUser);
194+
195+
public bool RequestUserStats(ulong steamIdUser)
196+
{
197+
return this.Call<bool, NativeRequestUserStats>(this.Functions.RequestUserStats, this.ObjectAddress, steamIdUser);
198+
}
199+
#endregion
200+
201201
#region ResetAllStats
202202
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
203203
[return: MarshalAs(UnmanagedType.I1)]

SAM.Game/Manager.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,26 +206,22 @@ private static string GetLocalizedString(KeyValue kv, string language, string de
206206
private bool LoadUserGameStatsSchema()
207207
{
208208
string path;
209-
210209
try
211210
{
211+
string fileName = _($"UserGameStatsSchema_{this._GameId}.bin");
212212
path = API.Steam.GetInstallPath();
213-
path = Path.Combine(path, "appcache");
214-
path = Path.Combine(path, "stats");
215-
path = Path.Combine(path, _($"UserGameStatsSchema_{this._GameId}.bin"));
216-
213+
path = Path.Combine(path, "appcache", "stats", fileName);
217214
if (File.Exists(path) == false)
218215
{
219216
return false;
220217
}
221218
}
222-
catch
219+
catch (Exception e)
223220
{
224221
return false;
225222
}
226223

227224
var kv = KeyValue.LoadAsBinary(path);
228-
229225
if (kv == null)
230226
{
231227
return false;
@@ -405,7 +401,9 @@ private void RefreshStats()
405401
this._AchievementListView.Items.Clear();
406402
this._StatisticsDataGridView.Rows.Clear();
407403

408-
if (this._SteamClient.SteamUserStats.RequestCurrentStats() == false)
404+
var steamId = this._SteamClient.SteamUser.GetSteamId();
405+
406+
if (this._SteamClient.SteamUserStats.RequestUserStats(steamId) == false)
409407
{
410408
MessageBox.Show(this, "Failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
411409
return;

0 commit comments

Comments
 (0)