From 4eb09ea1a949af14fee1b957fae543ee4898ef84 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 31 Aug 2021 16:34:31 +0900 Subject: [PATCH] Update decoder to also extract `DifficultyControlPoint`s from `HitObject`s --- osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs index 75d9a56f3e..bbc05f7c75 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs @@ -182,11 +182,19 @@ namespace osu.Game.Beatmaps.Formats beatmap.ControlPointInfo = legacyControlPoints; SampleControlPoint lastRelevantSamplePoint = null; + DifficultyControlPoint lastRelevantDifficultyPoint = null; // iterate over hitobjects and pull out all required sample changes foreach (var h in beatmap.HitObjects) { var hSamplePoint = h.SampleControlPoint; + var hDifficultyPoint = h.DifficultyControlPoint; + + if (!hDifficultyPoint.IsRedundant(lastRelevantDifficultyPoint)) + { + legacyControlPoints.Add(hDifficultyPoint.Time, hDifficultyPoint); + lastRelevantDifficultyPoint = hDifficultyPoint; + } if (!hSamplePoint.IsRedundant(lastRelevantSamplePoint)) { @@ -209,7 +217,7 @@ namespace osu.Game.Beatmaps.Formats } // Output any remaining effects as secondary non-timing control point. - var difficultyPoint = beatmap.ControlPointInfo.DifficultyPointAt(group.Time); + var difficultyPoint = ((LegacyControlPointInfo)beatmap.ControlPointInfo).DifficultyPointAt(group.Time); writer.Write(FormattableString.Invariant($"{group.Time},")); writer.Write(FormattableString.Invariant($"{-100 / difficultyPoint.SpeedMultiplier},")); outputControlPointAt(group.Time, false);