From a7f0ae09bbad5a2677fbfe4f631de250f7d80cea Mon Sep 17 00:00:00 2001 From: Hivie Date: Mon, 4 Aug 2025 15:21:43 +0100 Subject: [PATCH] apply review - improve timing tolerance const name and documentation - simplify matching logic in `FindMatchingTimingPoint` --- .../Edit/Checks/CheckInconsistentTimingControlPoints.cs | 2 +- .../Rulesets/Edit/Checks/Components/TimingCheckUtils.cs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game/Rulesets/Edit/Checks/CheckInconsistentTimingControlPoints.cs b/osu.Game/Rulesets/Edit/Checks/CheckInconsistentTimingControlPoints.cs index bbed49d7ee..8ed802e618 100644 --- a/osu.Game/Rulesets/Edit/Checks/CheckInconsistentTimingControlPoints.cs +++ b/osu.Game/Rulesets/Edit/Checks/CheckInconsistentTimingControlPoints.cs @@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Edit.Checks } // Check for BPM inconsistency - if (Math.Abs(referencePoint.BeatLength - matchingPoint.BeatLength) > TimingCheckUtils.TIMING_TOLERANCE) + if (Math.Abs(referencePoint.BeatLength - matchingPoint.BeatLength) > TimingCheckUtils.TIME_OFFSET_TOLERANCE_MS) { yield return new IssueTemplateInconsistentBPM(this).Create(referencePoint.Time, beatmap.BeatmapInfo.DifficultyName); } diff --git a/osu.Game/Rulesets/Edit/Checks/Components/TimingCheckUtils.cs b/osu.Game/Rulesets/Edit/Checks/Components/TimingCheckUtils.cs index 1ddbeb31d6..f56f27813d 100644 --- a/osu.Game/Rulesets/Edit/Checks/Components/TimingCheckUtils.cs +++ b/osu.Game/Rulesets/Edit/Checks/Components/TimingCheckUtils.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using System; using System.Collections.Generic; using System.Linq; using osu.Framework.Utils; @@ -11,8 +10,8 @@ namespace osu.Game.Rulesets.Edit.Checks.Components { public static class TimingCheckUtils { - // Small tolerance for floating point comparison - public const double TIMING_TOLERANCE = 0.01; + // Tolerance for exact time offset matching (in milliseconds) + public const double TIME_OFFSET_TOLERANCE_MS = 0.01; /// /// Finds a timing control point that starts at approximately the same time (within 1ms after rounding). @@ -22,7 +21,7 @@ namespace osu.Game.Rulesets.Edit.Checks.Components /// The matching timing control point, or null if none found. public static TimingControlPoint? FindMatchingTimingPoint(IEnumerable timingPoints, double time) { - return timingPoints.FirstOrDefault(tp => Precision.AlmostEquals(tp.Time, Math.Round(time), 1.0)); + return timingPoints.FirstOrDefault(tp => (int)tp.Time == (int)time); } /// @@ -33,7 +32,7 @@ namespace osu.Game.Rulesets.Edit.Checks.Components /// The exact matching timing control point, or null if none found. public static TimingControlPoint? FindExactMatchingTimingPoint(IEnumerable timingPoints, double time) { - return timingPoints.FirstOrDefault(tp => Precision.AlmostEquals(tp.Time, time, TIMING_TOLERANCE)); + return timingPoints.FirstOrDefault(tp => Precision.AlmostEquals(tp.Time, time, TIME_OFFSET_TOLERANCE_MS)); } } }