From 5c6cd879ddae01fd86b29622d51652847b99a5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 15 Sep 2023 12:21:58 +0200 Subject: [PATCH] Adjust slider calculations to new method API Code originally read Velocity = scoringDistance / beatLength = BASE_SCORING_DISTANCE * SliderMultiplier * GetPrecisionAdjustedSliderVelocityMultiplier() / beatLength Given (mathematically, floats are not generally as forgiving): GetPrecisionAdjustedBeatLength() = beatLength / GetPrecisionAdjustedSliderVelocityMultiplier() it follows that (inverting both sides): 1 / GetPrecisionAdjustedBeatLength() = GetPrecisionAdjustedSliderVelocityMultiplier() / beatLength and therefore Velocity = BASE_SCORING_DISTANCE * SliderMultiplier * GetPrecisionAdjustedSliderVelocityMultiplier() / beatLength = BASE_SCORING_DISTANCE * SliderMultiplier / GetPrecisionAdjustedBeatLength() and to recover `scoringDistance` scoringDistance = Velocity * beatLength --- osu.Game.Rulesets.Osu/Objects/Slider.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index f40c301220..e05dbd8ea6 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -16,6 +16,7 @@ using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Objects.Legacy; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Scoring; @@ -166,9 +167,11 @@ namespace osu.Game.Rulesets.Osu.Objects TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); - double scoringDistance = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier * ((IHasSliderVelocity)this).GetPrecisionAdjustedSliderVelocityMultiplier(OsuRuleset.SHORT_NAME); + Velocity = BASE_SCORING_DISTANCE * difficulty.SliderMultiplier / LegacyRulesetExtensions.GetPrecisionAdjustedBeatLength(this, timingPoint, OsuRuleset.SHORT_NAME); + // WARNING: this is intentionally not computed as `BASE_SCORING_DISTANCE * difficulty.SliderMultiplier` + // for backwards compatibility reasons (intentionally introducing floating point errors to match stable). + double scoringDistance = Velocity * timingPoint.BeatLength; - Velocity = scoringDistance / timingPoint.BeatLength; TickDistance = GenerateTicks ? (scoringDistance / difficulty.SliderTickRate * TickDistanceMultiplier) : double.PositiveInfinity; }