mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 03:22:54 +08:00
Merge pull request #11275 from peppy/safer-user-ids
Send multiplayer user IDs via ctor for better thread safety
This commit is contained in:
commit
15cef44351
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
@ -199,7 +200,14 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
||||
|
||||
private void onPlaylistChanged(object sender, NotifyCollectionChangedEventArgs e) => SelectedItem.Value = Playlist.FirstOrDefault();
|
||||
|
||||
private void onLoadRequested() => multiplayer?.Push(new PlayerLoader(() => new RealtimePlayer(SelectedItem.Value)));
|
||||
private void onLoadRequested()
|
||||
{
|
||||
Debug.Assert(client.Room != null);
|
||||
|
||||
int[] userIds = client.Room.Users.Where(u => u.State >= MultiplayerUserState.WaitingForLoad).Select(u => u.UserID).ToArray();
|
||||
|
||||
multiplayer?.Push(new PlayerLoader(() => new RealtimePlayer(SelectedItem.Value, userIds)));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
@ -39,9 +38,17 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
||||
[CanBeNull]
|
||||
private MultiplayerGameplayLeaderboard leaderboard;
|
||||
|
||||
public RealtimePlayer(PlaylistItem playlistItem)
|
||||
private readonly int[] userIds;
|
||||
|
||||
/// <summary>
|
||||
/// Construct a multiplayer player.
|
||||
/// </summary>
|
||||
/// <param name="playlistItem">The playlist item to be played.</param>
|
||||
/// <param name="userIds">The users which are participating in this game.</param>
|
||||
public RealtimePlayer(PlaylistItem playlistItem, int[] userIds)
|
||||
: base(playlistItem, false)
|
||||
{
|
||||
this.userIds = userIds;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -74,8 +81,6 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
||||
|
||||
Debug.Assert(client.Room != null);
|
||||
|
||||
int[] userIds = client.Room.Users.Where(u => u.State >= MultiplayerUserState.WaitingForLoad).Select(u => u.UserID).ToArray();
|
||||
|
||||
// todo: this should be implemented via a custom HUD implementation, and correctly masked to the main content area.
|
||||
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(ScoreProcessor, userIds), HUDOverlay.Add);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user