1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:43:01 +08:00

Fix clocks getting added a second time

This commit is contained in:
smoogipoo 2021-06-29 17:29:25 +09:00
parent 8e04d73b67
commit bfdbe3c3fe
2 changed files with 14 additions and 10 deletions

View File

@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -54,7 +55,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
MasterClock = master;
}
public void AddPlayerClock(ISpectatorPlayerClock clock) => playerClocks.Add(clock);
public void AddPlayerClock(ISpectatorPlayerClock clock)
{
Debug.Assert(!playerClocks.Contains(clock));
playerClocks.Add(clock);
}
public void RemovePlayerClock(ISpectatorPlayerClock clock) => playerClocks.Remove(clock);

View File

@ -101,7 +101,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
Expanded = { Value = true },
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
}, leaderboardContainer.Add);
}, l =>
{
foreach (var instance in instances)
leaderboard.AddClock(instance.UserId, instance.GameplayClock);
leaderboardContainer.Add(leaderboard);
});
syncManager.ReadyToStart += onReadyToStart;
syncManager.MasterState.BindValueChanged(onMasterStateChanged, true);
@ -166,14 +172,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
}
protected override void StartGameplay(int userId, GameplayState gameplayState)
{
var instance = instances.Single(i => i.UserId == userId);
instance.LoadScore(gameplayState.Score);
syncManager.AddPlayerClock(instance.GameplayClock);
leaderboard.AddClock(instance.UserId, instance.GameplayClock);
}
=> instances.Single(i => i.UserId == userId).LoadScore(gameplayState.Score);
protected override void EndGameplay(int userId)
{