From 83d71d78a4b8e482b30706c078bb205c1c816d41 Mon Sep 17 00:00:00 2001 From: paperjack Date: Thu, 24 May 2018 00:41:14 +0300 Subject: [PATCH] Added FetchUsersScores to Leaderboard.cs --- Facepunch.Steamworks/Client/Leaderboard.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Facepunch.Steamworks/Client/Leaderboard.cs b/Facepunch.Steamworks/Client/Leaderboard.cs index dcd9f39..d95bece 100644 --- a/Facepunch.Steamworks/Client/Leaderboard.cs +++ b/Facepunch.Steamworks/Client/Leaderboard.cs @@ -321,6 +321,34 @@ public bool FetchScores( RequestType RequestType, int start, int end, FetchScore return true; } + public unsafe bool FetchUsersScores( RequestType RequestType, UInt64[] steamIds, FetchScoresCallback onSuccess, FailureCallback onFailure = null ) + { + + if ( IsError ) return false; + if ( !IsValid ) return DeferOnCreated( () => FetchUsersScores( RequestType, steamIds, onSuccess, onFailure ), onFailure ); + + fixed(ulong* pointer = steamIds){ + + client.native.userstats.DownloadLeaderboardEntriesForUsers(BoardId, (IntPtr)pointer, steamIds.Length, (result, error) => + { + if (error) + { + onFailure?.Invoke(Callbacks.Result.IOFailure); + } + else + { + if (_sEntryBuffer == null) _sEntryBuffer = new List(); + else _sEntryBuffer.Clear(); + + ReadScores(result, _sEntryBuffer); + onSuccess(_sEntryBuffer.ToArray()); + } + }); + } + + return true; + } + private void OnScores( LeaderboardScoresDownloaded_t result, bool error ) { IsQuerying = false;