From e0e790fa9412368ff7b414791348476f05e28f2f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 26 Apr 2024 14:44:44 +0800 Subject: [PATCH 1/3] Fix a couple of xmldoc typos --- osu.Game/OsuGameBase.cs | 2 +- .../OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index fb7a238c46..0122afb239 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -94,7 +94,7 @@ namespace osu.Game public const int SAMPLE_DEBOUNCE_TIME = 20; /// - /// The maximum volume at which audio tracks should playback. This can be set lower than 1 to create some head-room for sound effects. + /// The maximum volume at which audio tracks should play back at. This can be set lower than 1 to create some head-room for sound effects. /// private const double global_track_volume_adjust = 0.8; diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs index fd61b60fe4..5ff52be8bc 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs @@ -130,7 +130,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate } /// - /// Updates the catchup states of all player clocks clocks. + /// Updates the catchup states of all player clocks. /// private void updatePlayerCatchup() { From 21d65568651a2760891dd3b2c5c6d55c1c99a688 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 26 Apr 2024 15:29:59 +0800 Subject: [PATCH 2/3] Remove managed clocks from `SpectatorSyncManager` on gameplay completion / abort --- .../Multiplayer/Spectate/MultiSpectatorScreen.cs | 13 +++++++++++-- .../Multiplayer/Spectate/SpectatorSyncManager.cs | 1 + osu.Game/Screens/Spectate/SpectatorScreen.cs | 7 +++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs index e2159f0e3b..cb00763e6b 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/MultiSpectatorScreen.cs @@ -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(() => { diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs index 5ff52be8bc..9eb448d9d0 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs @@ -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; } diff --git a/osu.Game/Screens/Spectate/SpectatorScreen.cs b/osu.Game/Screens/Spectate/SpectatorScreen.cs index c4aef3c878..ddc638b7c5 100644 --- a/osu.Game/Screens/Spectate/SpectatorScreen.cs +++ b/osu.Game/Screens/Spectate/SpectatorScreen.cs @@ -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 /// The gameplay state. protected abstract void StartGameplay(int userId, SpectatorGameplayState spectatorGameplayState); + /// + /// Fired when a user passes gameplay. + /// + /// The user which passed. + protected virtual void PassGameplay(int userId) { } + /// /// Quits gameplay for a user. /// Thread safety is not guaranteed – should be scheduled as required. From fb2d28f7e03aba53ae905b906fcea30da9a9c4ad Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 26 Apr 2024 15:30:26 +0800 Subject: [PATCH 3/3] Fix audio being paused in a spectator session when all players finish playing --- .../OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs index 9eb448d9d0..1638102089 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Spectate/SpectatorSyncManager.cs @@ -177,7 +177,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate /// private void updateMasterState() { - MasterClockState newState = playerClocks.Any(s => !s.IsCatchingUp) ? MasterClockState.Synchronised : MasterClockState.TooFarAhead; + // Clocks are removed as players complete the beatmap. + // Once there are no clocks we want to make sure the track plays out to the end. + MasterClockState newState = playerClocks.Count == 0 || playerClocks.Any(s => !s.IsCatchingUp) ? MasterClockState.Synchronised : MasterClockState.TooFarAhead; if (masterState == newState) return;