From 48209872bfd73d347a7fa6f35958d77a659a6fbc Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Wed, 4 Oct 2023 13:53:33 +0900 Subject: [PATCH] Fix spinner requirements being susceptible to FP precision --- osu.Game.Rulesets.Osu/Objects/Spinner.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Spinner.cs b/osu.Game.Rulesets.Osu/Objects/Spinner.cs index aca55c6bd9..e3dfe8e69a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Spinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Spinner.cs @@ -70,8 +70,11 @@ protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, I double secondsDuration = Duration / 1000; - SpinsRequired = (int)(minRps * secondsDuration); - MaximumBonusSpins = Math.Max(0, (int)(maxRps * secondsDuration) - SpinsRequired - bonus_spins_gap); + // Allow a 0.1ms floating point precision error in the calculation of the duration. + const double duration_error = 0.0001; + + SpinsRequired = (int)(minRps * secondsDuration + duration_error); + MaximumBonusSpins = Math.Max(0, (int)(maxRps * secondsDuration + duration_error) - SpinsRequired - bonus_spins_gap); } protected override void CreateNestedHitObjects(CancellationToken cancellationToken)