Fix control points with same timestamp potentially being parsed incorrectly

This commit is contained in:
Dean Herbert
2019-05-08 18:13:07 +09:00
parent 6559869880
commit 66ebdbbe4c
2 changed files with 16 additions and 3 deletions

View File

@ -12,6 +12,11 @@ namespace osu.Game.Beatmaps.ControlPoints
/// </summary> /// </summary>
public double Time; public double Time;
/// <summary>
/// Whether this timing point was generated internally, as opposed to parsed from the underlying beatmap.
/// </summary>
internal bool AutoGenerated;
public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time); public int CompareTo(ControlPoint other) => Time.CompareTo(other.Time);
/// <summary> /// <summary>

View File

@ -374,14 +374,16 @@ namespace osu.Game.Beatmaps.Formats
handleDifficultyControlPoint(new DifficultyControlPoint handleDifficultyControlPoint(new DifficultyControlPoint
{ {
Time = time, Time = time,
SpeedMultiplier = speedMultiplier SpeedMultiplier = speedMultiplier,
AutoGenerated = timingChange
}); });
handleEffectControlPoint(new EffectControlPoint handleEffectControlPoint(new EffectControlPoint
{ {
Time = time, Time = time,
KiaiMode = kiaiMode, KiaiMode = kiaiMode,
OmitFirstBarLine = omitFirstBarSignature OmitFirstBarLine = omitFirstBarSignature,
AutoGenerated = timingChange
}); });
handleSampleControlPoint(new LegacySampleControlPoint handleSampleControlPoint(new LegacySampleControlPoint
@ -389,7 +391,8 @@ namespace osu.Game.Beatmaps.Formats
Time = time, Time = time,
SampleBank = stringSampleSet, SampleBank = stringSampleSet,
SampleVolume = sampleVolume, SampleVolume = sampleVolume,
CustomSampleBank = customSampleBank CustomSampleBank = customSampleBank,
AutoGenerated = timingChange
}); });
} }
catch (FormatException) catch (FormatException)
@ -419,6 +422,11 @@ namespace osu.Game.Beatmaps.Formats
if (newPoint.EquivalentTo(existing)) if (newPoint.EquivalentTo(existing))
return; return;
// autogenerated points should not replace non-autogenerated.
// this allows for incorrectly ordered timing points to still be correctly handled.
if (newPoint.AutoGenerated && !existing.AutoGenerated)
return;
if (existing.Time == newPoint.Time) if (existing.Time == newPoint.Time)
beatmap.ControlPointInfo.DifficultyPoints.Remove(existing); beatmap.ControlPointInfo.DifficultyPoints.Remove(existing);