mirror of
https://github.com/ppy/osu.git
synced 2025-02-28 03:15:08 +08:00
Send multiplayer user IDs via ctor for better thread safety
This commit is contained in:
parent
60be1bedc9
commit
d6dadd12fa
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -188,7 +189,14 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
|
|
||||||
private void onPlaylistChanged(object sender, NotifyCollectionChangedEventArgs e) => SelectedItem.Value = Playlist.FirstOrDefault();
|
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)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@ -37,9 +36,17 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
private MultiplayerGameplayLeaderboard leaderboard;
|
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)
|
: base(playlistItem, false)
|
||||||
{
|
{
|
||||||
|
this.userIds = userIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -65,8 +72,6 @@ namespace osu.Game.Screens.Multi.RealtimeMultiplayer
|
|||||||
|
|
||||||
Debug.Assert(client.Room != null);
|
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.
|
// 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);
|
LoadComponentAsync(leaderboard = new MultiplayerGameplayLeaderboard(ScoreProcessor, userIds), HUDOverlay.Add);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user