1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Remove managed clocks from SpectatorSyncManager on gameplay completion / abort

This commit is contained in:
Dean Herbert 2024-04-26 15:29:59 +08:00
parent e0e790fa94
commit 21d6556865
No known key found for this signature in database
3 changed files with 19 additions and 2 deletions

View File

@ -244,10 +244,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
playerArea.LoadScore(spectatorGameplayState.Score);
});
protected override void FailGameplay(int userId)
protected override void FailGameplay(int userId) => Schedule(() =>
{
// We probably want to visualise this in the future.
}
var instance = instances.Single(i => i.UserId == userId);
syncManager.RemoveManagedClock(instance.SpectatorPlayerClock);
});
protected override void PassGameplay(int userId) => Schedule(() =>
{
var instance = instances.Single(i => i.UserId == userId);
syncManager.RemoveManagedClock(instance.SpectatorPlayerClock);
});
protected override void QuitGameplay(int userId) => Schedule(() =>
{

View File

@ -76,6 +76,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
public void RemoveManagedClock(SpectatorPlayerClock clock)
{
playerClocks.Remove(clock);
Logger.Log($"Removing managed clock from {nameof(SpectatorSyncManager)} ({playerClocks.Count} remain)");
clock.IsRunning = false;
}

View File

@ -135,6 +135,7 @@ namespace osu.Game.Screens.Spectate
case SpectatedUserState.Passed:
markReceivedAllFrames(userId);
PassGameplay(userId);
break;
case SpectatedUserState.Failed:
@ -233,6 +234,12 @@ namespace osu.Game.Screens.Spectate
/// <param name="spectatorGameplayState">The gameplay state.</param>
protected abstract void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState);
/// <summary>
/// Fired when a user passes gameplay.
/// </summary>
/// <param name="userId">The user which passed.</param>
protected virtual void PassGameplay(int userId) { }
/// <summary>
/// Quits gameplay for a user.
/// Thread safety is not guaranteed should be scheduled as required.