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

Merge pull request #15303 from peppy/fix-slider-path-extension-incorrectness

Fix slider paths being extended even when the last two points are equal
This commit is contained in:
Dan Balasescu 2021-10-26 19:16:12 +09:00 committed by GitHub
commit 61c8c963e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 1 deletions

View File

@ -775,5 +775,22 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.That(seventh.ControlPoints[4].Type == null);
}
}
[Test]
public void TestSliderLengthExtensionEdgeCase()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("duplicate-last-position-slider.osu"))
using (var stream = new LineBufferedReader(resStream))
{
var decoded = decoder.Decode(stream);
var path = ((IHasPath)decoded.HitObjects[0]).Path;
Assert.That(path.ExpectedDistance.Value, Is.EqualTo(2));
Assert.That(path.Distance, Is.EqualTo(1));
}
}
}
}

View File

@ -0,0 +1,19 @@
osu file format v14
[Difficulty]
HPDrainRate:7
CircleSize:10
OverallDifficulty:9
ApproachRate:10
SliderMultiplier:0.4
SliderTickRate:1
[TimingPoints]
382,923.076923076923,3,2,1,75,1,0
382,-1000,3,2,1,75,0,0
[HitObjects]
// Importantly, the last position is specified twice.
// In this case, osu-stable doesn't extend the slider length even when the "expected" length is higher than the actual.
261,171,25305,6,0,B|262:171|262:171|262:171,1,2,8|0,0:0|0:0,0:0:0:0:

View File

@ -460,7 +460,7 @@ namespace osu.Game.Beatmaps.Formats
var curveData = pathData as IHasPathWithRepeats;
writer.Write(FormattableString.Invariant($"{(curveData?.RepeatCount ?? 0) + 1},"));
writer.Write(FormattableString.Invariant($"{pathData.Path.Distance},"));
writer.Write(FormattableString.Invariant($"{pathData.Path.ExpectedDistance.Value ?? pathData.Path.Distance},"));
if (curveData != null)
{

View File

@ -280,6 +280,13 @@ namespace osu.Game.Rulesets.Objects
if (ExpectedDistance.Value is double expectedDistance && calculatedLength != expectedDistance)
{
// In osu-stable, if the last two control points of a slider are equal, extension is not performed.
if (ControlPoints.Count >= 2 && ControlPoints[^1].Position == ControlPoints[^2].Position && expectedDistance > calculatedLength)
{
cumulativeLength.Add(calculatedLength);
return;
}
// The last length is always incorrect
cumulativeLength.RemoveAt(cumulativeLength.Count - 1);