From 6fd8b4d8918f9095c9651cf88047c5467c10b06e Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 8 Mar 2022 22:14:58 +0900 Subject: [PATCH] Safeguard method against invalid invocation --- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 3004464df7..5e11d4da72 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -7,6 +7,7 @@ using System.Diagnostics; using System.Linq; using osu.Framework.Bindables; using osu.Framework.Utils; +using osu.Game.Beatmaps; using osu.Game.Extensions; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mods; @@ -100,6 +101,7 @@ namespace osu.Game.Rulesets.Scoring private double rollingMaxBaseScore; private double baseScore; private int basicHitObjects; + private bool beatmapApplied; private readonly Dictionary scoreResultCounts = new Dictionary(); private readonly List hitEvents = new List(); @@ -135,6 +137,12 @@ namespace osu.Game.Rulesets.Scoring }; } + public override void ApplyBeatmap(IBeatmap beatmap) + { + base.ApplyBeatmap(beatmap); + beatmapApplied = true; + } + protected sealed override void ApplyResultInternal(JudgementResult result) { result.ComboAtJudgement = Combo.Value; @@ -264,6 +272,9 @@ namespace osu.Game.Rulesets.Scoring /// The total score in the given . public double ComputePartialScore(ScoringMode mode, ScoreInfo scoreInfo) { + if (!beatmapApplied) + throw new InvalidOperationException($"Cannot compute partial score without calling {nameof(ApplyBeatmap)}."); + extractFromStatistics(scoreInfo.Ruleset.CreateInstance(), scoreInfo.Statistics, out double extractedBaseScore,