mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Fix incorrect fallback logic
Regressed when attempting to share implementation of binary search.
This commit is contained in:
parent
26860a903e
commit
5c13c443ff
@ -207,7 +207,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
||||
/// </summary>
|
||||
/// <param name="list">The list to search.</param>
|
||||
/// <param name="time">The time to find the control point at.</param>
|
||||
/// <returns>The active control point at <paramref name="time"/>.</returns>
|
||||
/// <returns>The active control point at <paramref name="time"/>. Will return <c>null</c> if there are no control points, or if the time is before the first control point.</returns>
|
||||
public static T BinarySearch<T>(IReadOnlyList<T> list, double time)
|
||||
where T : class, IControlPoint
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user