mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 14:45:51 +03:00
Safeguards and tests regarding #248 in GetScoresAroundUserAsync
This commit is contained in:
parent
51ab76893a
commit
38a29c6059
@ -129,15 +129,18 @@ public async Task GetScoresAroundUserAsync()
|
||||
var leaderboard = await SteamUserStats.FindLeaderboard( "Testleaderboard" );
|
||||
Assert.IsTrue( leaderboard.HasValue );
|
||||
|
||||
// Get entries around user
|
||||
var relativeScores = await leaderboard.Value.GetScoresAroundUserAsync( -5, 5 );
|
||||
Assert.IsNotNull( relativeScores );
|
||||
|
||||
Console.WriteLine( $"" );
|
||||
Console.WriteLine( $"Relative Scores:" );
|
||||
foreach ( var e in relativeScores )
|
||||
for ( int i = 1; i < 10; i++ )
|
||||
{
|
||||
Console.WriteLine( $"{e.GlobalRank}: {e.Score} {e.User}" );
|
||||
// Get entries around user
|
||||
var relativeScores = await leaderboard.Value.GetScoresAroundUserAsync( -i, i );
|
||||
Assert.IsNotNull( relativeScores );
|
||||
|
||||
Console.WriteLine( $"" );
|
||||
Console.WriteLine( $"Relative Scores:" );
|
||||
foreach ( var e in relativeScores )
|
||||
{
|
||||
Console.WriteLine( $"{e.GlobalRank}: {e.Score} {e.User}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,13 +102,13 @@ public async Task<LeaderboardEntry[]> GetScoresFromFriends()
|
||||
#region util
|
||||
internal async Task<LeaderboardEntry[]> LeaderboardResultToEntries( LeaderboardScoresDownloaded_t r )
|
||||
{
|
||||
if ( r.CEntryCount == 0 )
|
||||
if ( r.CEntryCount <= 0 )
|
||||
return null;
|
||||
|
||||
var output = new LeaderboardEntry[r.CEntryCount];
|
||||
var e = default( LeaderboardEntry_t );
|
||||
|
||||
for ( int i = 0; i < r.CEntryCount; i++ )
|
||||
for ( int i = 0; i < output.Length; i++ )
|
||||
{
|
||||
if ( SteamUserStats.Internal.GetDownloadedLeaderboardEntry( r.SteamLeaderboardEntries, i, ref e, detailsBuffer, detailsBuffer.Length ) )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user