From 83189d1f07dc21af413f74f48e38c52082d6d005 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 17 Mar 2022 06:24:55 +0300 Subject: [PATCH] Revert "Update mod instantiaton utility method to no longer check for validity" This reverts commit 1a04260807bfaf54675e753b4a0b7561d7349fad. --- osu.Game/Utils/ModUtils.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) 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; } } }