1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Revert "Update mod instantiaton utility method to no longer check for validity"

This reverts commit 1a04260807.
This commit is contained in:
Salman Ahmed 2022-03-17 06:24:55 +03:00
parent 1a04260807
commit 83189d1f07

View File

@ -153,17 +153,31 @@ namespace osu.Game.Utils
}
/// <summary>
/// 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 <see cref="Mod"/>s for further processing.
/// </summary>
/// <param name="ruleset">The ruleset to instantiate mods.</param>
/// <param name="ruleset">The ruleset to verify mods against.</param>
/// <param name="proposedMods">The proposed mods.</param>
/// <param name="mods">Mods instantiated from <paramref name="proposedMods"/> on the given <paramref name="ruleset"/>.</param>
public static void InstantiateModsForRuleset(Ruleset ruleset, IEnumerable<APIMod> proposedMods, out List<Mod> mods)
/// <param name="valid">Mods instantiated from <paramref name="proposedMods"/> which were valid for the given <paramref name="ruleset"/>.</param>
/// <returns>Whether all <paramref name="proposedMods"/> were valid for the given <paramref name="ruleset"/>.</returns>
public static bool InstantiateValidModsForRuleset(Ruleset ruleset, IEnumerable<APIMod> proposedMods, out List<Mod> valid)
{
mods = new List<Mod>();
valid = new List<Mod>();
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;
}
}
}