Fix osu! stacking not matching stable in very specific edge case

Closes https://github.com/ppy/osu/issues/36052.

Not much more to say here. Until now the `PreEmpt` typing discrepancy
has likely gone unnoticed since it's usually only used in visual usages.
This commit is contained in:
Dean Herbert
2025-12-18 20:08:56 +09:00
parent 1de97712f1
commit 44f535dcef
2 changed files with 63 additions and 19 deletions

View File

@@ -4,7 +4,6 @@
using System;
using System.IO;
using System.Linq;
using System.Text;
using NUnit.Framework;
using osu.Game.Beatmaps;
using osu.Game.IO;
@@ -19,23 +18,9 @@ namespace osu.Game.Rulesets.Osu.Tests
public class StackingTest
{
[Test]
public void TestStacking()
public void TestStackingEdgeCaseOne()
{
using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(beatmap_data)))
using (var reader = new LineBufferedReader(stream))
{
var beatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
var converted = new TestWorkingBeatmap(beatmap).GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>());
var objects = converted.HitObjects.ToList();
// The last hitobject triggers the stacking
for (int i = 0; i < objects.Count - 1; i++)
Assert.AreEqual(0, ((OsuHitObject)objects[i]).StackHeight);
}
}
private const string beatmap_data = @"
using (var stream = new MemoryStream(@"
osu file format v14
[General]
@@ -62,6 +47,65 @@ SliderTickRate:0.5
311,185,218471,2,0,L|325:209,1,25
311,185,218671,2,0,L|304:212,1,25
311,185,240271,5,0,0:0:0:0:
";
"u8.ToArray()))
using (var reader = new LineBufferedReader(stream))
{
var beatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
var converted = new TestWorkingBeatmap(beatmap).GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>());
var objects = converted.HitObjects.ToList();
// The last hitobject triggers the stacking
for (int i = 0; i < objects.Count - 1; i++)
Assert.AreEqual(0, ((OsuHitObject)objects[i]).StackHeight);
}
}
[Test]
public void TestStackingEdgeCaseTwo()
{
using (var stream = new MemoryStream(@"
osu file format v14
// extracted from https://osu.ppy.sh/beatmapsets/365006#osu/801165
[General]
StackLeniency: 0.2
[Difficulty]
HPDrainRate:6
CircleSize:4
OverallDifficulty:8
ApproachRate:9.3
SliderMultiplier:2
SliderTickRate:1
[TimingPoints]
5338,444.444444444444,4,2,0,50,1,0
82893,-76.9230769230769,4,2,8,50,0,0
85115,-76.9230769230769,4,2,0,50,0,0
85337,-100,4,2,8,60,0,0
85893,-100,4,2,7,60,0,0
86226,-100,4,2,8,60,0,0
88893,-58.8235294117647,4,1,8,70,0,1
[HitObjects]
427,124,84226,1,0,3:0:0:0:
427,124,84337,1,0,3:0:0:0:
427,124,84449,1,8,0:0:0:0:
"u8.ToArray()))
using (var reader = new LineBufferedReader(stream))
{
var beatmap = Decoder.GetDecoder<Beatmap>(reader).Decode(reader);
var converted = new TestWorkingBeatmap(beatmap).GetPlayableBeatmap(new OsuRuleset().RulesetInfo, Array.Empty<Mod>());
var objects = converted.HitObjects.ToList();
Assert.That(objects, Has.Count.EqualTo(3));
// The last hitobject triggers the stacking
for (int i = 0; i < objects.Count - 1; i++)
Assert.AreEqual(0, ((OsuHitObject)objects[i]).StackHeight);
}
}
}
}

View File

@@ -171,7 +171,7 @@ namespace osu.Game.Rulesets.Osu.Objects
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
TimePreempt = (float)IBeatmapDifficultyInfo.DifficultyRange(difficulty.ApproachRate, PREEMPT_RANGE);
TimePreempt = (int)IBeatmapDifficultyInfo.DifficultyRange(difficulty.ApproachRate, PREEMPT_RANGE);
// Preempt time can go below 450ms. Normally, this is achieved via the DT mod which uniformly speeds up all animations game wide regardless of AR.
// This uniform speedup is hard to match 1:1, however we can at least make AR>10 (via mods) feel good by extending the upper linear function above.