From 447fd07b4ed4b7bf7f71862946ad975d8c07526f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 11 Sep 2020 01:13:55 +0900 Subject: [PATCH] Fix maps with only bonus score having NaN scores --- .../Gameplay/TestSceneScoreProcessor.cs | 26 +++++++++++++++++++ osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 8 +++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs b/osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs index b0baf0385e..c9ab4fa489 100644 --- a/osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs +++ b/osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs @@ -28,6 +28,20 @@ public void TestNoScoreIncreaseFromMiss() Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(0.0)); } + [Test] + public void TestOnlyBonusScore() + { + var beatmap = new Beatmap { HitObjects = { new TestBonusHitObject() } }; + + var scoreProcessor = new ScoreProcessor(); + scoreProcessor.ApplyBeatmap(beatmap); + + // Apply a judgement + scoreProcessor.ApplyResult(new JudgementResult(new TestBonusHitObject(), new TestBonusJudgement()) { Type = HitResult.Perfect }); + + Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(100)); + } + private class TestHitObject : HitObject { public override Judgement CreateJudgement() => new TestJudgement(); @@ -37,5 +51,17 @@ private class TestJudgement : Judgement { protected override int NumericResultFor(HitResult result) => 100; } + + private class TestBonusHitObject : HitObject + { + public override Judgement CreateJudgement() => new TestBonusJudgement(); + } + + private class TestBonusJudgement : Judgement + { + public override bool AffectsCombo => false; + + protected override int NumericResultFor(HitResult result) => 100; + } } } diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 983f9a3abf..6fa5a87c8e 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -202,7 +202,13 @@ private void updateScore() TotalScore.Value = getScore(Mode.Value); } - private double getScore(ScoringMode mode) => GetScore(mode, maxHighestCombo, baseScore / maxBaseScore, (double)HighestCombo.Value / maxHighestCombo, bonusScore); + private double getScore(ScoringMode mode) + { + return GetScore(mode, maxHighestCombo, + maxBaseScore > 0 ? baseScore / maxBaseScore : 0, + maxHighestCombo > 0 ? (double)HighestCombo.Value / maxHighestCombo : 0, + bonusScore); + } /// /// Computes the total score.