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

Merge pull request #18936 from peppy/fix-nan-diff-calc-result

Guard against `NaN` star difficulty results
This commit is contained in:
Dan Balasescu 2022-06-29 21:51:29 +09:00 committed by GitHub
commit 68d4676ad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -207,7 +207,7 @@ namespace osu.Game.Beatmaps
if (cancellationToken.IsCancellationRequested) if (cancellationToken.IsCancellationRequested)
return; return;
var starDifficulty = task.GetResultSafely(); StarDifficulty? starDifficulty = task.GetResultSafely();
if (starDifficulty != null) if (starDifficulty != null)
bindable.Value = starDifficulty.Value; bindable.Value = starDifficulty.Value;

View File

@ -34,7 +34,7 @@ namespace osu.Game.Beatmaps
/// </summary> /// </summary>
public StarDifficulty([NotNull] DifficultyAttributes attributes) public StarDifficulty([NotNull] DifficultyAttributes attributes)
{ {
Stars = attributes.StarRating; Stars = double.IsFinite(attributes.StarRating) ? attributes.StarRating : 0;
MaxCombo = attributes.MaxCombo; MaxCombo = attributes.MaxCombo;
Attributes = attributes; Attributes = attributes;
// Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...) // Todo: Add more members (BeatmapInfo.DifficultyRating? Attributes? Etc...)
@ -46,7 +46,7 @@ namespace osu.Game.Beatmaps
/// </summary> /// </summary>
public StarDifficulty(double starDifficulty, int maxCombo) public StarDifficulty(double starDifficulty, int maxCombo)
{ {
Stars = starDifficulty; Stars = double.IsFinite(starDifficulty) ? starDifficulty : 0;
MaxCombo = maxCombo; MaxCombo = maxCombo;
Attributes = null; Attributes = null;
} }