Fix incorrect fallback logic

Regressed when attempting to share implementation of binary search.
This commit is contained in:
Dean Herbert
2022-10-20 23:08:18 +09:00
parent 26860a903e
commit 5c13c443ff
2 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,7 @@
#nullable disable
using System;
using System.Linq;
using osu.Framework.Lists;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Timing;
@ -73,6 +74,13 @@ namespace osu.Game.Rulesets.UI.Scrolling.Algorithms
/// </summary>
/// <param name="time">The time which the <see cref="MultiplierControlPoint"/> should affect.</param>
/// <returns>The <see cref="MultiplierControlPoint"/>.</returns>
private MultiplierControlPoint controlPointAt(double time) => ControlPointInfo.BinarySearch(controlPoints, time) ?? new MultiplierControlPoint(double.NegativeInfinity);
private MultiplierControlPoint controlPointAt(double time)
{
return ControlPointInfo.BinarySearch(controlPoints, time)
// The standard binary search will fail if there's no control points, or if the time is before the first.
// For this method, we want to use the first control point in the latter case.
?? controlPoints.FirstOrDefault()
?? new MultiplierControlPoint(double.NegativeInfinity);
}
}
}