1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 22:33:05 +08:00

Fix crash on trying to retrieve mods from unavailable ruleset (#7211)

Fix crash on trying to retrieve mods from unavailable ruleset
This commit is contained in:
Dean Herbert 2019-12-15 03:18:14 +09:00 committed by GitHub
commit 23ea6c1e6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -84,6 +84,11 @@ namespace osu.Game.Tests.Visual.UserInterface
{
public override Ruleset CreateInstance() => new TestCustomisableModRuleset();
public TestRulesetInfo()
{
Available = true;
}
public class TestCustomisableModRuleset : Ruleset
{
public override IEnumerable<Mod> GetModsFor(ModType type)

View File

@ -246,8 +246,11 @@ namespace osu.Game
{
var dict = new Dictionary<ModType, IReadOnlyList<Mod>>();
if (r.NewValue?.Available == true)
{
foreach (ModType type in Enum.GetValues(typeof(ModType)))
dict[type] = r.NewValue?.CreateInstance().GetModsFor(type).ToList();
dict[type] = r.NewValue.CreateInstance().GetModsFor(type).ToList();
}
if (!SelectedMods.Disabled)
SelectedMods.Value = Array.Empty<Mod>();