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

Throw exception on access before ApplyBeatmap()

This commit is contained in:
Dan Balasescu 2022-06-02 16:34:36 +09:00
parent e551e48697
commit 055845d4f5

View File

@ -93,7 +93,18 @@ namespace osu.Game.Rulesets.Scoring
/// <summary> /// <summary>
/// Scoring values for a perfect play. /// Scoring values for a perfect play.
/// </summary> /// </summary>
public ScoringValues MaximumScoringValues { get; private set; } public ScoringValues MaximumScoringValues
{
get
{
if (!beatmapApplied)
throw new InvalidOperationException($"Cannot access maximum scoring values before calling {nameof(ApplyBeatmap)}.");
return maximumScoringValues;
}
}
private ScoringValues maximumScoringValues;
/// <summary> /// <summary>
/// Scoring values for the current play assuming all perfect hits. /// Scoring values for the current play assuming all perfect hits.
@ -255,7 +266,7 @@ namespace osu.Game.Rulesets.Scoring
private void updateScore() private void updateScore()
{ {
Accuracy.Value = currentMaximumScoringValues.BaseScore > 0 ? currentScoringValues.BaseScore / currentMaximumScoringValues.BaseScore : 1; Accuracy.Value = currentMaximumScoringValues.BaseScore > 0 ? currentScoringValues.BaseScore / currentMaximumScoringValues.BaseScore : 1;
TotalScore.Value = ComputeScore(Mode.Value, currentScoringValues, MaximumScoringValues); TotalScore.Value = ComputeScore(Mode.Value, currentScoringValues, maximumScoringValues);
} }
/// <summary> /// <summary>
@ -406,7 +417,7 @@ namespace osu.Game.Rulesets.Scoring
lastHitObject = null; lastHitObject = null;
if (storeResults) if (storeResults)
MaximumScoringValues = currentScoringValues; maximumScoringValues = currentScoringValues;
currentScoringValues = default; currentScoringValues = default;
currentMaximumScoringValues = default; currentMaximumScoringValues = default;