1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 11:03:05 +08:00

Fix `GameplayClockContainer potentially resetting external seeks

This commit is contained in:
Dean Herbert 2022-08-18 18:10:20 +09:00
parent 728cd96508
commit 2c6fd1ec6e
5 changed files with 10 additions and 22 deletions

View File

@ -281,7 +281,7 @@ namespace osu.Game.Rulesets.UI
}
}
public double? StartTime => parentGameplayClock?.StartTime;
public double StartTime => parentGameplayClock?.StartTime ?? 0;
public IEnumerable<double> NonGameplayAdjustments => parentGameplayClock?.NonGameplayAdjustments ?? Enumerable.Empty<double>();

View File

@ -40,10 +40,10 @@ namespace osu.Game.Screens.Play
/// The time from which the clock should start. Will be seeked to on calling <see cref="Reset"/>.
/// </summary>
/// <remarks>
/// If not set, a value of zero will be used.
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
/// By default, a value of zero will be used.
/// Importantly, the value will be inferred from the current beatmap in <see cref="MasterGameplayClockContainer"/> by default.
/// </remarks>
public double? StartTime { get; set; }
public double StartTime { get; set; } = 0;
public virtual IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>();
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Play
Start();
ensureSourceClockSet();
Seek(StartTime ?? 0);
Seek(StartTime);
}
/// <summary>

View File

@ -82,7 +82,7 @@ namespace osu.Game.Screens.Play.HUD
if (isInIntro)
{
double introStartTime = GameplayClock.StartTime ?? 0;
double introStartTime = GameplayClock.StartTime;
double introOffsetCurrent = currentTime - introStartTime;
double introDuration = FirstHitTime - introStartTime;

View File

@ -19,10 +19,10 @@ namespace osu.Game.Screens.Play
/// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
/// </summary>
/// <remarks>
/// If not set, a value of zero will be used.
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified.
/// By default, a value of zero will be used.
/// Importantly, the value will be inferred from the current beatmap in <see cref="MasterGameplayClockContainer"/> by default.
/// </remarks>
double? StartTime { get; }
double StartTime { get; }
/// <summary>
/// All adjustments applied to this clock which don't come from gameplay or mods.

View File

@ -57,20 +57,8 @@ namespace osu.Game.Screens.Play
{
this.beatmap = beatmap;
this.skipTargetTime = skipTargetTime;
}
protected override void LoadComplete()
{
base.LoadComplete();
// Reset may have been called externally before LoadComplete.
// If it was, and the clock is in a playing state, we want to ensure that it isn't stopped here.
bool isStarted = !IsPaused.Value;
// If a custom start time was not specified, calculate the best value to use.
StartTime ??= findEarliestStartTime();
Reset(startClock: isStarted);
StartTime = findEarliestStartTime();
}
private double findEarliestStartTime()