From 80269689393f5be2f72d03ed85a829a4448140e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sat, 18 Sep 2021 14:24:50 +0200 Subject: [PATCH] Move difficulty -> effect point conversion back to decoder --- .../Beatmaps/ManiaBeatmapConverter.cs | 33 ------------------- .../Beatmaps/Formats/LegacyBeatmapDecoder.cs | 27 ++++++++++----- .../Beatmaps/Formats/LegacyBeatmapEncoder.cs | 2 +- 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index 65dc65b28a..5903e161d0 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -8,8 +8,6 @@ using System.Collections.Generic; using System.Threading; using osu.Game.Audio; using osu.Game.Beatmaps; -using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Beatmaps.Legacy; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Mania.Beatmaps.Patterns; @@ -84,37 +82,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps protected override Beatmap ConvertBeatmap(IBeatmap original, CancellationToken cancellationToken) { BeatmapDifficulty difficulty = original.BeatmapInfo.BaseDifficulty; - - if (IsForCurrentRuleset && original.ControlPointInfo is LegacyControlPointInfo originalLegacyControlPoints) - { - // original is cloned so we're safe to replace control point storage at this point. - original.ControlPointInfo = new LegacyControlPointInfo(); - - // convert all slider velocity adjustments to scroll speed adjustments. - foreach (var controlPoint in originalLegacyControlPoints.AllControlPoints) - { - double time = controlPoint.Time; - - switch (controlPoint) - { - default: - original.ControlPointInfo.Add(time, controlPoint); - break; - - case DifficultyControlPoint difficultyPoint: - var reference = originalLegacyControlPoints.EffectPointAt(time); - - var scrollControlPoint = new EffectControlPoint(); - - scrollControlPoint.CopyFrom(reference); - scrollControlPoint.ScrollSpeed = difficultyPoint.SliderVelocity; - - original.ControlPointInfo.Add(time, scrollControlPoint); - break; - } - } - } - int seed = (int)MathF.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)MathF.Round(difficulty.ApproachRate); Random = new FastRandom(seed); diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs index a9b5793565..68e6a8ac00 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs @@ -376,18 +376,29 @@ namespace osu.Game.Beatmaps.Formats addControlPoint(time, controlPoint, true); } -#pragma warning disable 618 - addControlPoint(time, new LegacyDifficultyControlPoint(beatLength) -#pragma warning restore 618 - { - SliderVelocity = speedMultiplier, - }, timingChange); + bool isOsuRuleset = beatmap.BeatmapInfo.RulesetID == 0; - addControlPoint(time, new EffectControlPoint + if (isOsuRuleset) + { +#pragma warning disable 618 + addControlPoint(time, new LegacyDifficultyControlPoint(beatLength) +#pragma warning restore 618 + { + SliderVelocity = speedMultiplier, + }, timingChange); + } + + var effectPoint = new EffectControlPoint { KiaiMode = kiaiMode, OmitFirstBarLine = omitFirstBarSignature, - }, timingChange); + }; + + // scrolling rulesets use effect points rather than difficulty points for scroll speed adjustments. + if (!isOsuRuleset) + effectPoint.ScrollSpeed = speedMultiplier; + + addControlPoint(time, effectPoint, timingChange); addControlPoint(time, new LegacySampleControlPoint { diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs index ebb326ccc8..d903ab3a6d 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs @@ -189,7 +189,7 @@ namespace osu.Game.Beatmaps.Formats } // handle scroll speed, which is stored as "slider velocity" in legacy formats. - // note that this is only relevant for mania beatmaps. + // this is relevant for scrolling ruleset beatmaps. if (!isOsuRuleset) { foreach (var point in legacyControlPoints.EffectPoints)