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