mirror of https://github.com/ppy/osu
Remove necessity of AutoGenerated flag
This commit is contained in:
parent
e987db37ec
commit
8baf569f59
|
@ -167,9 +167,9 @@ public void TestDecodeBeatmapTimingPoints()
|
|||
var controlPoints = beatmap.ControlPointInfo;
|
||||
|
||||
Assert.AreEqual(4, controlPoints.TimingPoints.Count);
|
||||
Assert.AreEqual(42, controlPoints.DifficultyPoints.Count);
|
||||
Assert.AreEqual(42, controlPoints.SamplePoints.Count);
|
||||
Assert.AreEqual(42, controlPoints.EffectPoints.Count);
|
||||
Assert.AreEqual(5, controlPoints.DifficultyPoints.Count);
|
||||
Assert.AreEqual(34, controlPoints.SamplePoints.Count);
|
||||
Assert.AreEqual(8, controlPoints.EffectPoints.Count);
|
||||
|
||||
var timingPoint = controlPoints.TimingPointAt(0);
|
||||
Assert.AreEqual(956, timingPoint.Time);
|
||||
|
@ -191,7 +191,7 @@ public void TestDecodeBeatmapTimingPoints()
|
|||
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
||||
|
||||
difficultyPoint = controlPoints.DifficultyPointAt(48428);
|
||||
Assert.AreEqual(48428, difficultyPoint.Time);
|
||||
Assert.AreEqual(0, difficultyPoint.Time);
|
||||
Assert.AreEqual(1.0, difficultyPoint.SpeedMultiplier);
|
||||
|
||||
difficultyPoint = controlPoints.DifficultyPointAt(116999);
|
||||
|
@ -224,7 +224,7 @@ public void TestDecodeBeatmapTimingPoints()
|
|||
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
||||
|
||||
effectPoint = controlPoints.EffectPointAt(119637);
|
||||
Assert.AreEqual(119637, effectPoint.Time);
|
||||
Assert.AreEqual(95901, effectPoint.Time);
|
||||
Assert.IsFalse(effectPoint.KiaiMode);
|
||||
Assert.IsFalse(effectPoint.OmitFirstBarLine);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
|
@ -12,11 +12,6 @@ public abstract class ControlPoint : IComparable<ControlPoint>, IEquatable<Contr
|
|||
/// </summary>
|
||||
public double Time => controlPointGroup?.Time ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this timing point was generated internally, as opposed to parsed from the underlying beatmap.
|
||||
/// </summary>
|
||||
internal bool AutoGenerated;
|
||||
|
||||
private ControlPointGroup controlPointGroup;
|
||||
|
||||
public void AttachGroup(ControlPointGroup pointGroup) => this.controlPointGroup = pointGroup;
|
||||
|
|
|
@ -177,7 +177,7 @@ public void Add(double time, ControlPoint newPoint, bool force = false)
|
|||
GroupAt(time, true).Add(newPoint);
|
||||
}
|
||||
|
||||
public ControlPointGroup GroupAt(double time, bool createIfNotExisting)
|
||||
public ControlPointGroup GroupAt(double time, bool createIfNotExisting = false)
|
||||
{
|
||||
var existing = Groups.FirstOrDefault(g => g.Time == time);
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using osu.Framework.IO.File;
|
||||
|
@ -50,6 +51,8 @@ protected override void ParseStreamInto(LineBufferedReader stream, Beatmap beatm
|
|||
|
||||
base.ParseStreamInto(stream, beatmap);
|
||||
|
||||
flushPendingPoints();
|
||||
|
||||
// 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)
|
||||
|
@ -369,34 +372,64 @@ private void handleTimingPoint(string line)
|
|||
if (timingChange)
|
||||
{
|
||||
var controlPoint = CreateTimingControlPoint();
|
||||
|
||||
controlPoint.BeatLength = beatLength;
|
||||
controlPoint.TimeSignature = timeSignature;
|
||||
|
||||
beatmap.ControlPointInfo.Add(time, controlPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
beatmap.ControlPointInfo.Add(time, new DifficultyControlPoint
|
||||
{
|
||||
SpeedMultiplier = speedMultiplier,
|
||||
AutoGenerated = timingChange
|
||||
});
|
||||
addControlPoint(time, controlPoint, true);
|
||||
}
|
||||
|
||||
beatmap.ControlPointInfo.Add(time, new EffectControlPoint
|
||||
addControlPoint(time, new DifficultyControlPoint
|
||||
{
|
||||
SpeedMultiplier = speedMultiplier,
|
||||
}, timingChange);
|
||||
|
||||
addControlPoint(time, new EffectControlPoint
|
||||
{
|
||||
KiaiMode = kiaiMode,
|
||||
OmitFirstBarLine = omitFirstBarSignature,
|
||||
AutoGenerated = timingChange
|
||||
});
|
||||
}, timingChange);
|
||||
|
||||
beatmap.ControlPointInfo.Add(time, new LegacySampleControlPoint
|
||||
addControlPoint(time, new LegacySampleControlPoint
|
||||
{
|
||||
SampleBank = stringSampleSet,
|
||||
SampleVolume = sampleVolume,
|
||||
CustomSampleBank = customSampleBank,
|
||||
AutoGenerated = timingChange
|
||||
});
|
||||
}, timingChange);
|
||||
|
||||
// To handle the scenario where a non-timing line shares the same time value as a subsequent timing line but
|
||||
// appears earlier in the file, we buffer non-timing control points and rewrite them *after* control points from the timing line
|
||||
// with the same time value (allowing them to overwrite as necessary).
|
||||
//
|
||||
// The expected outcome is that we prefer the non-timing line's adjustments over the timing line's adjustments when time is equal.
|
||||
if (timingChange)
|
||||
flushPendingPoints();
|
||||
}
|
||||
|
||||
private readonly List<ControlPoint> pendingControlPoints = new List<ControlPoint>();
|
||||
private double pendingControlPointsTime;
|
||||
|
||||
private void addControlPoint(double time, ControlPoint point, bool timingChange)
|
||||
{
|
||||
if (timingChange)
|
||||
{
|
||||
beatmap.ControlPointInfo.Add(time, point);
|
||||
return;
|
||||
}
|
||||
|
||||
if (time != pendingControlPointsTime)
|
||||
flushPendingPoints();
|
||||
|
||||
pendingControlPoints.Add(point);
|
||||
pendingControlPointsTime = time;
|
||||
}
|
||||
|
||||
private void flushPendingPoints()
|
||||
{
|
||||
foreach (var p in pendingControlPoints)
|
||||
beatmap.ControlPointInfo.Add(pendingControlPointsTime, p);
|
||||
|
||||
pendingControlPoints.Clear();
|
||||
}
|
||||
|
||||
private void handleHitObject(string line)
|
||||
|
|
|
@ -104,12 +104,10 @@ private void load(IBindable<WorkingBeatmap> beatmap)
|
|||
defaultTiming = new TimingControlPoint
|
||||
{
|
||||
BeatLength = default_beat_length,
|
||||
AutoGenerated = true,
|
||||
};
|
||||
|
||||
defaultEffect = new EffectControlPoint
|
||||
{
|
||||
AutoGenerated = true,
|
||||
KiaiMode = false,
|
||||
OmitFirstBarLine = false
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue