1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 19:27:31 +08:00

Fix crashing if selected ruleset doesn't have an autoplay mod.

This commit is contained in:
Lucas A 2020-06-01 17:41:04 +02:00
parent efbc02b521
commit e9b09373e7
2 changed files with 15 additions and 9 deletions

View File

@ -100,7 +100,7 @@ namespace osu.Game.Rulesets
return value;
}
public ModAutoplay GetAutoplayMod() => GetAllMods().OfType<ModAutoplay>().First();
public ModAutoplay GetAutoplayMod() => GetAllMods().OfType<ModAutoplay>().FirstOrDefault();
public virtual ISkin CreateLegacySkinProvider(ISkinSource source, IBeatmap beatmap) => null;

View File

@ -49,8 +49,11 @@ namespace osu.Game.Screens.Select
if (removeAutoModOnResume)
{
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod().GetType();
var autoType = Ruleset.Value.CreateInstance().GetAutoplayMod()?.GetType();
if (autoType != null)
ModSelect.DeselectTypes(new[] { autoType }, true);
removeAutoModOnResume = false;
}
}
@ -78,8 +81,10 @@ namespace osu.Game.Screens.Select
if (GetContainingInputManager().CurrentState?.Keyboard.ControlPressed == true)
{
var auto = Ruleset.Value.CreateInstance().GetAutoplayMod();
var autoType = auto.GetType();
var autoType = auto?.GetType();
if (autoType != null)
{
var mods = Mods.Value;
if (mods.All(m => m.GetType() != autoType))
@ -88,6 +93,7 @@ namespace osu.Game.Screens.Select
removeAutoModOnResume = true;
}
}
}
SampleConfirm?.Play();