Safeguards and tests regarding #248 in GetScoresAroundUserAsync

This commit is contained in:
Garry Newman 2019-05-01 08:45:11 +01:00
parent 51ab76893a
commit 38a29c6059
2 changed files with 13 additions and 10 deletions

View File

@ -129,8 +129,10 @@ public async Task GetScoresAroundUserAsync()
var leaderboard = await SteamUserStats.FindLeaderboard( "Testleaderboard" );
Assert.IsTrue( leaderboard.HasValue );
for ( int i = 1; i < 10; i++ )
{
// Get entries around user
var relativeScores = await leaderboard.Value.GetScoresAroundUserAsync( -5, 5 );
var relativeScores = await leaderboard.Value.GetScoresAroundUserAsync( -i, i );
Assert.IsNotNull( relativeScores );
Console.WriteLine( $"" );
@ -140,6 +142,7 @@ public async Task GetScoresAroundUserAsync()
Console.WriteLine( $"{e.GlobalRank}: {e.Score} {e.User}" );
}
}
}
[TestMethod]
public async Task GetScoresAsync()

View File

@ -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 ) )
{