1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:07:38 +08:00

Collect and sort points from nested objects before extracting

This commit is contained in:
Bartłomiej Dach 2021-09-16 18:04:26 +02:00
parent 8026968939
commit 76ccdd1340
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -182,11 +182,8 @@ namespace osu.Game.Beatmaps.Formats
bool isOsuRuleset = beatmap.BeatmapInfo.RulesetID == 0; bool isOsuRuleset = beatmap.BeatmapInfo.RulesetID == 0;
// iterate over hitobjects and pull out all required sample and difficulty changes // iterate over hitobjects and pull out all required sample and difficulty changes
foreach (var h in beatmap.HitObjects) extractDifficultyControlPoints(beatmap.HitObjects);
{ extractSampleControlPoints(beatmap.HitObjects);
extractDifficultyControlPoints(h);
extractSampleControlPoints(h);
}
// handle scroll speed, which is stored as "slider velocity" in legacy formats. // handle scroll speed, which is stored as "slider velocity" in legacy formats.
// this is relevant for scrolling ruleset beatmaps. // this is relevant for scrolling ruleset beatmaps.
@ -239,32 +236,47 @@ namespace osu.Game.Beatmaps.Formats
writer.WriteLine(); writer.WriteLine();
} }
void extractDifficultyControlPoints(HitObject hitObject) IEnumerable<DifficultyControlPoint> collectDifficultyControlPoints(IEnumerable<HitObject> hitObjects)
{ {
if (!isOsuRuleset) if (!isOsuRuleset)
return; yield break;
var hDifficultyPoint = hitObject.DifficultyControlPoint; foreach (var hitObject in hitObjects)
{
yield return hitObject.DifficultyControlPoint;
foreach (var nested in collectDifficultyControlPoints(hitObject.NestedHitObjects))
yield return nested;
}
}
void extractDifficultyControlPoints(IEnumerable<HitObject> hitObjects)
{
foreach (var hDifficultyPoint in collectDifficultyControlPoints(hitObjects).OrderBy(dp => dp.Time))
{
if (!hDifficultyPoint.IsRedundant(lastRelevantDifficultyPoint)) if (!hDifficultyPoint.IsRedundant(lastRelevantDifficultyPoint))
{ {
legacyControlPoints.Add(hDifficultyPoint.Time, hDifficultyPoint); legacyControlPoints.Add(hDifficultyPoint.Time, hDifficultyPoint);
lastRelevantDifficultyPoint = hDifficultyPoint; lastRelevantDifficultyPoint = hDifficultyPoint;
} }
}
foreach (var nested in hitObject.NestedHitObjects)
extractDifficultyControlPoints(nested);
} }
void extractSampleControlPoints(HitObject hitObject) IEnumerable<SampleControlPoint> collectSampleControlPoints(IEnumerable<HitObject> hitObjects)
{ {
// process nested objects first as these use EndTime for legacy storage. foreach (var hitObject in hitObjects)
{
yield return hitObject.SampleControlPoint;
foreach (var nested in hitObject.NestedHitObjects) foreach (var nested in collectSampleControlPoints(hitObject.NestedHitObjects))
extractSampleControlPoints(nested); yield return nested;
}
var hSamplePoint = hitObject.SampleControlPoint; }
void extractSampleControlPoints(IEnumerable<HitObject> hitObject)
{
foreach (var hSamplePoint in collectSampleControlPoints(hitObject).OrderBy(sp => sp.Time))
{
if (!hSamplePoint.IsRedundant(lastRelevantSamplePoint)) if (!hSamplePoint.IsRedundant(lastRelevantSamplePoint))
{ {
legacyControlPoints.Add(hSamplePoint.Time, hSamplePoint); legacyControlPoints.Add(hSamplePoint.Time, hSamplePoint);
@ -272,6 +284,7 @@ namespace osu.Game.Beatmaps.Formats
} }
} }
} }
}
private void handleColours(TextWriter writer) private void handleColours(TextWriter writer)
{ {