From 59a1915451e43e4619c68719ae770974f45bead3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 20 Oct 2023 10:25:28 +0200 Subject: [PATCH 1/2] Add failing test case for insufficient sample query leniency --- .../Beatmaps/Formats/LegacyBeatmapDecoderTest.cs | 13 +++++++++++++ osu.Game.Tests/Resources/sample-point-leniency.osu | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 osu.Game.Tests/Resources/sample-point-leniency.osu diff --git a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs index fec7f86eb2..66151a51e6 100644 --- a/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/LegacyBeatmapDecoderTest.cs @@ -1080,5 +1080,18 @@ namespace osu.Game.Tests.Beatmaps.Formats Assert.That(controlPoints.DifficultyPointAt(3000).GenerateTicks, Is.True); } } + + [Test] + public void TestSamplePointLeniency() + { + var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false }; + + using (var resStream = TestResources.OpenResource("sample-point-leniency.osu")) + using (var stream = new LineBufferedReader(resStream)) + { + var hitObject = decoder.Decode(stream).HitObjects.Single(); + Assert.That(hitObject.Samples.Select(s => s.Volume), Has.All.EqualTo(70)); + } + } } } diff --git a/osu.Game.Tests/Resources/sample-point-leniency.osu b/osu.Game.Tests/Resources/sample-point-leniency.osu new file mode 100644 index 0000000000..a44838007c --- /dev/null +++ b/osu.Game.Tests/Resources/sample-point-leniency.osu @@ -0,0 +1,10 @@ +osu file format v14 + +# extracted from https://osu.ppy.sh/beatmapsets/1859679#osu/3823636 + +[TimingPoints] +39166,-117.647058823529,4,2,1,5,0,0 +39262,-117.647058823529,4,2,1,70,0,0 + +[HitObjects] +440,70,39260,1,10,0:2:0:0: From c89081589ccbaabef181530a203300116dd3ea00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 20 Oct 2023 10:26:16 +0200 Subject: [PATCH 2/2] Fix insufficient leniency when querying sample points --- osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs index 8559ecfe69..8c5e4971d5 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs @@ -28,9 +28,12 @@ namespace osu.Game.Beatmaps.Formats public const int EARLY_VERSION_TIMING_OFFSET = 24; /// - /// A small adjustment to the start time of control points to account for rounding/precision errors. + /// A small adjustment to the start time of sample control points to account for rounding/precision errors. /// - private const double control_point_leniency = 1; + /// + /// Compare: https://github.com/peppy/osu-stable-reference/blob/master/osu!/GameplayElements/HitObjects/HitObject.cs#L319 + /// + private const double control_point_leniency = 5; internal static RulesetStore? RulesetStore;