Fix potential mod nullref in APIUserScoreAggregate's CreateScoreInfo implementation

This commit is contained in:
Dean Herbert 2022-01-13 00:28:16 +09:00
parent b2d09b7b10
commit 4c79145c11
2 changed files with 5 additions and 4 deletions

View File

@ -1,7 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using Newtonsoft.Json;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
namespace osu.Game.Online.API.Requests.Responses
@ -42,7 +44,8 @@ namespace osu.Game.Online.API.Requests.Responses
PP = PP,
TotalScore = TotalScore,
User = User,
Position = Position
Position = Position,
Mods = Array.Empty<Mod>()
};
}
}

View File

@ -186,14 +186,12 @@ namespace osu.Game.Scoring
{
get
{
var rulesetInstance = Ruleset.CreateInstance();
Mod[] scoreMods = Array.Empty<Mod>();
if (mods != null)
scoreMods = mods;
else if (localAPIMods != null)
scoreMods = APIMods.Select(m => m.ToMod(rulesetInstance)).ToArray();
scoreMods = APIMods.Select(m => m.ToMod(Ruleset.CreateInstance())).ToArray();
return scoreMods;
}