1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:42:55 +08:00

Move difficulty -> effect point conversion back to decoder

This commit is contained in:
Bartłomiej Dach 2021-09-18 14:24:50 +02:00
parent a7ae3cc03e
commit 8026968939
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
3 changed files with 20 additions and 42 deletions

View File

@ -8,8 +8,6 @@ using System.Collections.Generic;
using System.Threading; using System.Threading;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Legacy;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Mania.Beatmaps.Patterns; using osu.Game.Rulesets.Mania.Beatmaps.Patterns;
@ -84,37 +82,6 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
protected override Beatmap<ManiaHitObject> ConvertBeatmap(IBeatmap original, CancellationToken cancellationToken) protected override Beatmap<ManiaHitObject> ConvertBeatmap(IBeatmap original, CancellationToken cancellationToken)
{ {
BeatmapDifficulty difficulty = original.BeatmapInfo.BaseDifficulty; 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); int seed = (int)MathF.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)MathF.Round(difficulty.ApproachRate);
Random = new FastRandom(seed); Random = new FastRandom(seed);

View File

@ -376,18 +376,29 @@ namespace osu.Game.Beatmaps.Formats
addControlPoint(time, controlPoint, true); addControlPoint(time, controlPoint, true);
} }
bool isOsuRuleset = beatmap.BeatmapInfo.RulesetID == 0;
if (isOsuRuleset)
{
#pragma warning disable 618 #pragma warning disable 618
addControlPoint(time, new LegacyDifficultyControlPoint(beatLength) addControlPoint(time, new LegacyDifficultyControlPoint(beatLength)
#pragma warning restore 618 #pragma warning restore 618
{ {
SliderVelocity = speedMultiplier, SliderVelocity = speedMultiplier,
}, timingChange); }, timingChange);
}
addControlPoint(time, new EffectControlPoint var effectPoint = new EffectControlPoint
{ {
KiaiMode = kiaiMode, KiaiMode = kiaiMode,
OmitFirstBarLine = omitFirstBarSignature, 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 addControlPoint(time, new LegacySampleControlPoint
{ {

View File

@ -189,7 +189,7 @@ namespace osu.Game.Beatmaps.Formats
} }
// handle scroll speed, which is stored as "slider velocity" in legacy 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) if (!isOsuRuleset)
{ {
foreach (var point in legacyControlPoints.EffectPoints) foreach (var point in legacyControlPoints.EffectPoints)