diff --git a/osu.Game/Utils/ModUtils.cs b/osu.Game/Utils/ModUtils.cs index bccb706842..d5ea74c404 100644 --- a/osu.Game/Utils/ModUtils.cs +++ b/osu.Game/Utils/ModUtils.cs @@ -153,17 +153,31 @@ namespace osu.Game.Utils } /// - /// Returns an instantiated list of all proposed mods on a given ruleset. + /// Verifies all proposed mods are valid for a given ruleset and returns instantiated s for further processing. /// - /// The ruleset to instantiate mods. + /// The ruleset to verify mods against. /// The proposed mods. - /// Mods instantiated from on the given . - public static void InstantiateModsForRuleset(Ruleset ruleset, IEnumerable proposedMods, out List mods) + /// Mods instantiated from which were valid for the given . + /// Whether all were valid for the given . + public static bool InstantiateValidModsForRuleset(Ruleset ruleset, IEnumerable proposedMods, out List valid) { - mods = new List(); + valid = new List(); + bool proposedWereValid = true; foreach (var apiMod in proposedMods) - mods.Add(apiMod.ToMod(ruleset)); + { + try + { + // will throw if invalid + valid.Add(apiMod.ToMod(ruleset)); + } + catch + { + proposedWereValid = false; + } + } + + return proposedWereValid; } } }