1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 22:12:53 +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>(); 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"/>. /// The time from which the clock should start. Will be seeked to on calling <see cref="Reset"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// If not set, a value of zero will be used. /// By default, a value of zero will be used.
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified. /// Importantly, the value will be inferred from the current beatmap in <see cref="MasterGameplayClockContainer"/> by default.
/// </remarks> /// </remarks>
public double? StartTime { get; set; } public double StartTime { get; set; } = 0;
public virtual IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>(); public virtual IEnumerable<double> NonGameplayAdjustments => Enumerable.Empty<double>();
@ -130,7 +130,7 @@ namespace osu.Game.Screens.Play
Start(); Start();
ensureSourceClockSet(); ensureSourceClockSet();
Seek(StartTime ?? 0); Seek(StartTime);
} }
/// <summary> /// <summary>

View File

@ -82,7 +82,7 @@ namespace osu.Game.Screens.Play.HUD
if (isInIntro) if (isInIntro)
{ {
double introStartTime = GameplayClock.StartTime ?? 0; double introStartTime = GameplayClock.StartTime;
double introOffsetCurrent = currentTime - introStartTime; double introOffsetCurrent = currentTime - introStartTime;
double introDuration = FirstHitTime - 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"/>. /// The time from which the clock should start. Will be seeked to on calling <see cref="GameplayClockContainer.Reset"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// If not set, a value of zero will be used. /// By default, a value of zero will be used.
/// Importantly, the value will be inferred from the current ruleset in <see cref="MasterGameplayClockContainer"/> unless specified. /// Importantly, the value will be inferred from the current beatmap in <see cref="MasterGameplayClockContainer"/> by default.
/// </remarks> /// </remarks>
double? StartTime { get; } double StartTime { get; }
/// <summary> /// <summary>
/// All adjustments applied to this clock which don't come from gameplay or mods. /// 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.beatmap = beatmap;
this.skipTargetTime = skipTargetTime; this.skipTargetTime = skipTargetTime;
}
protected override void LoadComplete() StartTime = findEarliestStartTime();
{
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);
} }
private double findEarliestStartTime() private double findEarliestStartTime()