From 1a6b8b2c7353a5d3a988db49db138900ac271761 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 6 Jul 2021 14:53:31 +0900 Subject: [PATCH] Populate `UserScores` as early as possible to avoid weird ordering requirements --- .../HUD/MultiplayerGameplayLeaderboard.cs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/osu.Game/Screens/Play/HUD/MultiplayerGameplayLeaderboard.cs b/osu.Game/Screens/Play/HUD/MultiplayerGameplayLeaderboard.cs index 4783ce2f40..a10c16fcd5 100644 --- a/osu.Game/Screens/Play/HUD/MultiplayerGameplayLeaderboard.cs +++ b/osu.Game/Screens/Play/HUD/MultiplayerGameplayLeaderboard.cs @@ -53,6 +53,13 @@ namespace osu.Game.Screens.Play.HUD { scoringMode = config.GetBindable(OsuSetting.ScoreDisplayMode); + foreach (var userId in playingUsers) + { + var trackedUser = CreateUserData(userId, scoreProcessor); + trackedUser.ScoringMode.BindTo(scoringMode); + UserScores[userId] = trackedUser; + } + userLookupCache.GetUsersAsync(playingUsers.ToArray()).ContinueWith(users => Schedule(() => { foreach (var user in users.Result) @@ -60,16 +67,13 @@ namespace osu.Game.Screens.Play.HUD if (user == null) continue; - var trackedUser = CreateUserData(user.Id, scoreProcessor); - trackedUser.ScoringMode.BindTo(scoringMode); + var trackedUser = UserScores[user.Id]; var leaderboardScore = AddPlayer(user, user.Id == api.LocalUser.Value.Id); leaderboardScore.Accuracy.BindTo(trackedUser.Accuracy); leaderboardScore.TotalScore.BindTo(trackedUser.Score); leaderboardScore.Combo.BindTo(trackedUser.CurrentCombo); leaderboardScore.HasQuit.BindTo(trackedUser.UserQuit); - - UserScores[user.Id] = trackedUser; } })); } @@ -78,14 +82,6 @@ namespace osu.Game.Screens.Play.HUD { base.LoadComplete(); - // this is *required* to be here due to the spectator leaderboard not correctly populating clocks if done later. - // note that running this here is probably not 100% correct (if a user quits before user population occurs for instance, - // an incorrect state will be reached). - prepareDataStreams(); - } - - private void prepareDataStreams() - { // BindableList handles binding in a really bad way (Clear then AddRange) so we need to do this manually.. foreach (int userId in playingUsers) { @@ -95,6 +91,8 @@ namespace osu.Game.Screens.Play.HUD usersChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, new[] { userId })); } + // bind here is to support players leaving the match. + // new players are not supported. playingUsers.BindTo(multiplayerClient.CurrentMatchPlayingUserIds); playingUsers.BindCollectionChanged(usersChanged);