1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-11 01:07:23 +08:00

Fix unable to join multiplayer rooms with many users

This commit is contained in:
Dan Balasescu 2025-03-04 12:34:02 +09:00
parent 963df165df
commit 3024a98658
No known key found for this signature in database
2 changed files with 19 additions and 16 deletions

View File

@ -13,14 +13,14 @@ namespace osu.Game.Online.API.Requests
/// </summary>
public class GetUsersRequest : APIRequest<GetUsersResponse>
{
public readonly int[] UserIds;
public const int MAX_IDS_PER_REQUEST = 50;
private const int max_ids_per_request = 50;
public readonly int[] UserIds;
public GetUsersRequest(int[] userIds)
{
if (userIds.Length > max_ids_per_request)
throw new ArgumentException($"{nameof(GetUsersRequest)} calls only support up to {max_ids_per_request} IDs at once");
if (userIds.Length > MAX_IDS_PER_REQUEST)
throw new ArgumentException($"{nameof(GetUsersRequest)} calls only support up to {MAX_IDS_PER_REQUEST} IDs at once");
UserIds = userIds;
}

View File

@ -815,7 +815,9 @@ namespace osu.Game.Online.Multiplayer
/// <param name="multiplayerUsers">The <see cref="MultiplayerRoomUser"/>s to populate.</param>
protected async Task PopulateUsers(IEnumerable<MultiplayerRoomUser> multiplayerUsers)
{
var request = new GetUsersRequest(multiplayerUsers.Select(u => u.UserID).Distinct().ToArray());
foreach (int[] userChunk in multiplayerUsers.Select(u => u.UserID).Distinct().Chunk(GetUsersRequest.MAX_IDS_PER_REQUEST))
{
var request = new GetUsersRequest(userChunk);
await API.PerformAsync(request).ConfigureAwait(false);
@ -830,6 +832,7 @@ namespace osu.Game.Online.Multiplayer
multiplayerUser.User = user;
}
}
}
/// <summary>
/// Updates the local room settings with the given <see cref="MultiplayerRoomSettings"/>.