From 5f634f2812b42c6e6d404b19c2dc015db80b3575 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 21 Sep 2023 18:45:34 +0900 Subject: [PATCH] Remove unnecessary encapsulation workaround The new implementation of `DecouplingClock` will not mutate the underlying clock in any way (unless attempting to start it when approaching from a negative time value). This should be quite safe as a result. --- osu.Game/Beatmaps/FramedBeatmapClock.cs | 5 +---- osu.Game/OsuGameBase.cs | 11 +---------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/osu.Game/Beatmaps/FramedBeatmapClock.cs b/osu.Game/Beatmaps/FramedBeatmapClock.cs index 7a12528453..cd349e6c29 100644 --- a/osu.Game/Beatmaps/FramedBeatmapClock.cs +++ b/osu.Game/Beatmaps/FramedBeatmapClock.cs @@ -142,10 +142,7 @@ namespace osu.Game.Beatmaps #region Delegation of IAdjustableClock / ISourceChangeableClock to decoupled clock. - public void ChangeSource(IClock? source) - { - decoupledTrack.ChangeSource(source as Track ?? new TrackVirtual(60000)); - } + public void ChangeSource(IClock? source) => decoupledTrack.ChangeSource(source); public IClock Source => decoupledTrack.Source; diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 75b46a0a4d..c946362124 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -441,16 +441,7 @@ namespace osu.Game } } - private void onTrackChanged(WorkingBeatmap beatmap, TrackChangeDirection direction) - { - // FramedBeatmapClock uses a decoupled clock internally which will mutate the source if it is an `IAdjustableClock`. - // We don't want this for now, as the intention of beatmapClock is to be a read-only source for beat sync components. - // - // Encapsulating in a FramedClock will avoid any mutations. - var framedClock = new FramedClock(beatmap.Track); - - beatmapClock.ChangeSource(framedClock); - } + private void onTrackChanged(WorkingBeatmap beatmap, TrackChangeDirection direction) => beatmapClock.ChangeSource(beatmap.Track); protected virtual void InitialiseFonts() {