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 @@ public class ControlPoint : IComparable<ControlPoint>, IEquatable<ControlPoint>
/// </summary>
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);
/// <summary>

View File

@ -374,14 +374,16 @@ private void handleTimingPoint(string line)
handleDifficultyControlPoint(new DifficultyControlPoint
{
Time = time,
SpeedMultiplier = speedMultiplier
SpeedMultiplier = speedMultiplier,
AutoGenerated = timingChange
});
handleEffectControlPoint(new EffectControlPoint
{
Time = time,
KiaiMode = kiaiMode,
OmitFirstBarLine = omitFirstBarSignature
OmitFirstBarLine = omitFirstBarSignature,
AutoGenerated = timingChange
});
handleSampleControlPoint(new LegacySampleControlPoint
@ -389,7 +391,8 @@ private void handleTimingPoint(string line)
Time = time,
SampleBank = stringSampleSet,
SampleVolume = sampleVolume,
CustomSampleBank = customSampleBank
CustomSampleBank = customSampleBank,
AutoGenerated = timingChange
});
}
catch (FormatException)
@ -419,6 +422,11 @@ private void handleDifficultyControlPoint(DifficultyControlPoint newPoint)
if (newPoint.EquivalentTo(existing))
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)
beatmap.ControlPointInfo.DifficultyPoints.Remove(existing);