1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 09:47:24 +08:00

Merge pull request #30620 from peppy/fix-offset-adjust-crash

Fix crash when resetting offset after a play with no hit events
This commit is contained in:
Bartłomiej Dach 2024-11-14 12:43:47 +01:00 committed by GitHub
commit d08c8ae482
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -40,6 +40,13 @@ namespace osu.Game.Tests.Visual.Ranking
AddSliderStep("height", 0.0f, 1000.0f, height.Value, height.Set);
}
[Test]
public void TestZeroEvents()
{
createTest(new List<HitEvent>());
AddStep("update offset", () => graph.UpdateOffset(10));
}
[Test]
public void TestManyDistributedEventsOffset()
{

View File

@ -176,7 +176,7 @@ namespace osu.Game.Screens.Ranking.Statistics
for (int i = 1; i <= axis_points; i++)
{
double axisValue = i * axisValueStep;
float position = (float)(axisValue / maxValue);
float position = maxValue == 0 ? 0 : (float)(axisValue / maxValue);
float alpha = 1f - position * 0.8f;
axisFlow.Add(new OsuSpriteText
@ -348,7 +348,7 @@ namespace osu.Game.Screens.Ranking.Statistics
boxAdjustment.FadeTo(!hasAdjustment ? 0 : 1, duration, Easing.OutQuint);
}
private float offsetForValue(float value) => (1 - minimum_height) * value / maxValue;
private float offsetForValue(float value) => maxValue == 0 ? 0 : (1 - minimum_height) * value / maxValue;
private float heightForValue(float value) => minimum_height + offsetForValue(value);
}