mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
Merge pull request #2563 from smoogipoo/fix-hitobject-order
Use a stable sort for hitobjects
This commit is contained in:
commit
7765a1aa3a
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
@ -49,11 +50,9 @@ namespace osu.Game.Rulesets.Mania.Difficulty
|
||||
|
||||
int columnCount = (Beatmap as ManiaBeatmap)?.TotalColumns ?? 7;
|
||||
|
||||
foreach (var hitObject in Beatmap.HitObjects)
|
||||
difficultyHitObjects.Add(new ManiaHitObjectDifficulty((ManiaHitObject)hitObject, columnCount));
|
||||
|
||||
// Sort DifficultyHitObjects by StartTime of the HitObjects - just to make sure.
|
||||
difficultyHitObjects.Sort((a, b) => a.BaseHitObject.StartTime.CompareTo(b.BaseHitObject.StartTime));
|
||||
// Note: Stable sort is done so that the ordering of hitobjects with equal start times doesn't change
|
||||
difficultyHitObjects.AddRange(Beatmap.HitObjects.Select(h => new ManiaHitObjectDifficulty((ManiaHitObject)h, columnCount)).OrderBy(h => h.BaseHitObject.StartTime));
|
||||
|
||||
if (!calculateStrainValues())
|
||||
return 0;
|
||||
|
@ -54,9 +54,11 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
base.ParseStreamInto(stream, beatmap);
|
||||
|
||||
// objects may be out of order *only* if a user has manually edited an .osu file.
|
||||
// unfortunately there are ranked maps in this state (example: https://osu.ppy.sh/s/594828).
|
||||
this.beatmap.HitObjects.Sort((x, y) => x.StartTime.CompareTo(y.StartTime));
|
||||
// Objects may be out of order *only* if a user has manually edited an .osu file.
|
||||
// Unfortunately there are ranked maps in this state (example: https://osu.ppy.sh/s/594828).
|
||||
// OrderBy is used to guarantee that the parsing order of hitobjects with equal start times is maintained (stably-sorted)
|
||||
// The parsing order of hitobjects matters in mania difficulty calculation
|
||||
this.beatmap.HitObjects = this.beatmap.HitObjects.OrderBy(h => h.StartTime).ToList();
|
||||
|
||||
foreach (var hitObject in this.beatmap.HitObjects)
|
||||
hitObject.ApplyDefaults(this.beatmap.ControlPointInfo, this.beatmap.BeatmapInfo.BaseDifficulty);
|
||||
|
Loading…
Reference in New Issue
Block a user