1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 15:12:57 +08:00

Merge pull request #16686 from peppy/fix-ar-on-old-maps

Fix approach rate not being transferred from OD on older beatmaps
This commit is contained in:
Dan Balasescu 2022-01-28 20:17:37 +09:00 committed by GitHub
commit 8883505eed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 0 deletions

View File

@ -821,5 +821,47 @@ namespace osu.Game.Tests.Beatmaps.Formats
}); });
} }
} }
[Test]
public void TestUndefinedApproachRateInheritsOverallDifficulty()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("undefined-approach-rate.osu"))
using (var stream = new LineBufferedReader(resStream))
{
var decoded = decoder.Decode(stream);
Assert.That(decoded.Difficulty.ApproachRate, Is.EqualTo(1));
Assert.That(decoded.Difficulty.OverallDifficulty, Is.EqualTo(1));
}
}
[Test]
public void TestApproachRateDefinedBeforeOverallDifficulty()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("approach-rate-before-overall-difficulty.osu"))
using (var stream = new LineBufferedReader(resStream))
{
var decoded = decoder.Decode(stream);
Assert.That(decoded.Difficulty.ApproachRate, Is.EqualTo(9));
Assert.That(decoded.Difficulty.OverallDifficulty, Is.EqualTo(1));
}
}
[Test]
public void TestApproachRateDefinedAfterOverallDifficulty()
{
var decoder = new LegacyBeatmapDecoder { ApplyOffsets = false };
using (var resStream = TestResources.OpenResource("approach-rate-after-overall-difficulty.osu"))
using (var stream = new LineBufferedReader(resStream))
{
var decoded = decoder.Decode(stream);
Assert.That(decoded.Difficulty.ApproachRate, Is.EqualTo(9));
Assert.That(decoded.Difficulty.OverallDifficulty, Is.EqualTo(1));
}
}
} }
} }

View File

@ -0,0 +1,3 @@
[Difficulty]
OverallDifficulty:1
ApproachRate:9

View File

@ -0,0 +1,3 @@
[Difficulty]
ApproachRate:9
OverallDifficulty:1

View File

@ -0,0 +1,2 @@
[Difficulty]
OverallDifficulty:1

View File

@ -311,10 +311,13 @@ namespace osu.Game.Beatmaps.Formats
case @"OverallDifficulty": case @"OverallDifficulty":
difficulty.OverallDifficulty = Parsing.ParseFloat(pair.Value); difficulty.OverallDifficulty = Parsing.ParseFloat(pair.Value);
if (!hasApproachRate)
difficulty.ApproachRate = difficulty.OverallDifficulty;
break; break;
case @"ApproachRate": case @"ApproachRate":
difficulty.ApproachRate = Parsing.ParseFloat(pair.Value); difficulty.ApproachRate = Parsing.ParseFloat(pair.Value);
hasApproachRate = true;
break; break;
case @"SliderMultiplier": case @"SliderMultiplier":
@ -432,6 +435,7 @@ namespace osu.Game.Beatmaps.Formats
private readonly List<ControlPoint> pendingControlPoints = new List<ControlPoint>(); private readonly List<ControlPoint> pendingControlPoints = new List<ControlPoint>();
private readonly HashSet<Type> pendingControlPointTypes = new HashSet<Type>(); private readonly HashSet<Type> pendingControlPointTypes = new HashSet<Type>();
private double pendingControlPointsTime; private double pendingControlPointsTime;
private bool hasApproachRate;
private void addControlPoint(double time, ControlPoint point, bool timingChange) private void addControlPoint(double time, ControlPoint point, bool timingChange)
{ {