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:
commit
61c8c963e9
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
osu.Game.Tests/Resources/duplicate-last-position-slider.osu
Normal file
19
osu.Game.Tests/Resources/duplicate-last-position-slider.osu
Normal 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:
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user