Skip to content

Commit

Permalink
Change GameplayClockContainer.Reset to directly call `GameplayClock…
Browse files Browse the repository at this point in the history
….Stop`

The reasoning is explained in the inline comment, but basically this was
getting blocked by `isPaused` being in an initial `true` state (as it is
on construction), while the source clock was still `IsRunning`.

There's no real guarantee of sync between the source and the `isPaused`
bindable right now. Maybe there should be in the future, but to restore
sanity, let's ensure that a call to `Reset` can at least stop the track
as we expect.
  • Loading branch information
peppy committed Oct 10, 2023
1 parent 100c0cf commit f0bd975
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions osu.Game/Screens/Play/GameplayClockContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,15 @@ public void Stop()
/// Resets this <see cref="GameplayClockContainer"/> and the source to an initial state ready for gameplay.
/// </summary>
/// <param name="time">The time to seek to on resetting. If <c>null</c>, the existing <see cref="StartTime"/> will be used.</param>
/// <param name="startClock">Whether to start the clock immediately, if not already started.</param>
/// <param name="startClock">Whether to start the clock immediately. If <c>false</c>, the clock will remain stopped after this call.</param>
public void Reset(double? time = null, bool startClock = false)
{
bool wasPaused = isPaused.Value;

Stop();
// The intention of the Reset method is to get things into a known sane state.
// As such, we intentionally stop the underlying clock directly here, bypassing Stop/StopGameplayClock.
// This is to avoid any kind of isPaused state checks and frequency ramping (as provided by MasterGameplayClockContainer).
GameplayClock.Stop();

if (time != null)
StartTime = time.Value;
Expand Down

0 comments on commit f0bd975

Please sign in to comment.