mirror of
https://github.com/osukey/osukey.git
synced 2025-08-06 16:13:57 +09:00
Merge pull request #18321 from smoogipoo/legacy-catmull
Fix compatibility issues with legacy Catmull sliders
This commit is contained in:
@ -863,5 +863,40 @@ namespace osu.Game.Tests.Beatmaps.Formats
|
|||||||
Assert.That(decoded.Difficulty.OverallDifficulty, Is.EqualTo(1));
|
Assert.That(decoded.Difficulty.OverallDifficulty, Is.EqualTo(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLegacyAdjacentImplicitCatmullSegmentsAreMerged()
|
||||||
|
{
|
||||||
|
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("adjacent-catmull-segments.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(6));
|
||||||
|
Assert.That(controlPoints.Single(c => c.Type != null).Type, Is.EqualTo(PathType.Catmull));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNonLegacyAdjacentImplicitCatmullSegmentsAreNotMerged()
|
||||||
|
{
|
||||||
|
var decoder = new LegacyBeatmapDecoder(LegacyBeatmapEncoder.FIRST_LAZER_VERSION) { ApplyOffsets = false };
|
||||||
|
|
||||||
|
using (var resStream = TestResources.OpenResource("adjacent-catmull-segments.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[1].Type, Is.EqualTo(PathType.Catmull));
|
||||||
|
Assert.That(controlPoints[2].Type, Is.EqualTo(PathType.Catmull));
|
||||||
|
Assert.That(controlPoints[3].Type, Is.Null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
osu.Game.Tests/Resources/adjacent-catmull-segments.osu
Normal file
2
osu.Game.Tests/Resources/adjacent-catmull-segments.osu
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[HitObjects]
|
||||||
|
200,304,23875,6,0,C|288:304|288:304|288:208|288:208|352:208,1,260,8|0
|
@ -22,7 +22,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
{
|
{
|
||||||
public class LegacyBeatmapEncoder
|
public class LegacyBeatmapEncoder
|
||||||
{
|
{
|
||||||
public const int LATEST_VERSION = 128;
|
public const int FIRST_LAZER_VERSION = 128;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// osu! is generally slower than taiko, so a factor is added to increase
|
/// osu! is generally slower than taiko, so a factor is added to increase
|
||||||
@ -55,7 +55,7 @@ namespace osu.Game.Beatmaps.Formats
|
|||||||
|
|
||||||
public void Encode(TextWriter writer)
|
public void Encode(TextWriter writer)
|
||||||
{
|
{
|
||||||
writer.WriteLine($"osu file format v{LATEST_VERSION}");
|
writer.WriteLine($"osu file format v{FIRST_LAZER_VERSION}");
|
||||||
|
|
||||||
writer.WriteLine();
|
writer.WriteLine();
|
||||||
handleGeneral(writer);
|
handleGeneral(writer);
|
||||||
|
@ -336,10 +336,14 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
|
|
||||||
while (++endIndex < vertices.Length - endPointLength)
|
while (++endIndex < vertices.Length - endPointLength)
|
||||||
{
|
{
|
||||||
// Keep incrementing while an implicit segment doesn't need to be started
|
// Keep incrementing while an implicit segment doesn't need to be started.
|
||||||
if (vertices[endIndex].Position != vertices[endIndex - 1].Position)
|
if (vertices[endIndex].Position != vertices[endIndex - 1].Position)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Adjacent legacy Catmull segments should be treated as a single segment.
|
||||||
|
if (FormatVersion < LegacyBeatmapEncoder.FIRST_LAZER_VERSION && type == PathType.Catmull)
|
||||||
|
continue;
|
||||||
|
|
||||||
// The last control point of each segment is not allowed to start a new implicit segment.
|
// The last control point of each segment is not allowed to start a new implicit segment.
|
||||||
if (endIndex == vertices.Length - endPointLength - 1)
|
if (endIndex == vertices.Length - endPointLength - 1)
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user