1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Fix Catmull slider parsing with duplicate initial point

This commit is contained in:
Dan Balasescu 2022-05-24 11:47:42 +09:00
parent 41b3fb0df0
commit 9259aa94f1
3 changed files with 25 additions and 2 deletions

View File

@ -898,5 +898,24 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.That(controlPoints[3].Type, Is.Null);
}
}
[Test]
public void TestLegacyDuplicateInitialCatmullPointIsMerged()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("catmull-duplicate-initial-controlpoint.osu"))
using (var stream = new LineBufferedReader(resStream))
{
var decoded = decoder.Decode(stream);
var controlPoints = ((IHasPath)decoded.HitObjects[0]).Path.ControlPoints;
Assert.That(controlPoints.Count, Is.EqualTo(4));
Assert.That(controlPoints[0].Type, Is.EqualTo(PathType.Catmull));
Assert.That(controlPoints[0].Position, Is.EqualTo(Vector2.Zero));
Assert.That(controlPoints[1].Type, Is.Null);
Assert.That(controlPoints[1].Position, Is.Not.EqualTo(Vector2.Zero));
}
}
}
}

View File

@ -0,0 +1,2 @@
[HitObjects]
200,304,23875,6,0,C|200:304|288:304|288:208|352:208,1,260,8|0

View File

@ -340,8 +340,10 @@ namespace osu.Game.Rulesets.Objects.Legacy
if (vertices[endIndex].Position != vertices[endIndex - 1].Position)
continue;
// Adjacent legacy Catmull segments should be treated as a single segment.
if (FormatVersion < LegacyBeatmapEncoder.FIRST_LAZER_VERSION && type == PathType.Catmull)
// Legacy Catmull sliders don't support multiple segments, so adjacent Catmull segments should be treated as a single one.
// Importantly, this is not applied to the first control point, which may duplicate the slider path's position
// resulting in a duplicate (0,0) control point in the resultant list.
if (type == PathType.Catmull && endIndex > 1 && FormatVersion < LegacyBeatmapEncoder.FIRST_LAZER_VERSION)
continue;
// The last control point of each segment is not allowed to start a new implicit segment.