mirror of
https://github.com/ppy/osu.git
synced 2026-06-04 21:39:30 +08:00
Fix track not looping if specified preview point exceeds duration of track
By falling back to the default of 40% of track duration in such cases. Also added a safety for the restart point exceeding acceptable bounds in case of a non-zero offset. Closes https://github.com/ppy/osu/issues/33308.
This commit is contained in:
@@ -124,18 +124,16 @@ namespace osu.Game.Beatmaps
|
||||
Track.Looping = looping;
|
||||
Track.RestartPoint = Metadata.PreviewTime;
|
||||
|
||||
if (Track.RestartPoint == -1)
|
||||
if (!Track.IsLoaded)
|
||||
{
|
||||
if (!Track.IsLoaded)
|
||||
{
|
||||
// force length to be populated (https://github.com/ppy/osu-framework/issues/4202)
|
||||
Track.Seek(Track.CurrentTime);
|
||||
}
|
||||
|
||||
Track.RestartPoint = 0.4f * Track.Length;
|
||||
// force length to be populated (https://github.com/ppy/osu-framework/issues/4202)
|
||||
Track.Seek(Track.CurrentTime);
|
||||
}
|
||||
|
||||
Track.RestartPoint += offsetFromPreviewPoint;
|
||||
if (Track.RestartPoint < 0 || Track.RestartPoint > Track.Length)
|
||||
Track.RestartPoint = 0.4f * Track.Length;
|
||||
|
||||
Track.RestartPoint = Math.Clamp(Track.RestartPoint + offsetFromPreviewPoint, 0, Track.Length);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user