osu/osu.Game/Rulesets/Mods
Dean Herbert 0267aed846 Change ToMod to return an UnknownMod rather than throw if a mod isn't available
As seen by this kind of crash, having the `.ToMod` method throw can be
very problematic and also hidden (as it is used inside of models in
places where exceptions are not expected to occur).

Given there are tens of usages of this method, returning a placeholder
mod seems like a better idea than outright throwing.

```
 An unhandled has occurred.
 System.InvalidOperationException:
There is no mod in the ruleset (osu) matching the acronym AS.
 at osu.Game.Online.API.APIMod.ToMod(Ruleset ruleset) in /Users/dean/Projects/osu/osu.Game/Online/API/APIMod.cs:line 54
 at osu.Game.Scoring.ScoreInfo.<get_Mods>b__117_0(APIMod m) in /Users/dean/Projects/osu/osu.Game/Scoring/ScoreInfo.cs:line 193
 at System.Linq.Enumerable.SelectArrayIterator`2.ToArray()
 at osu.Game.Scoring.ScoreInfo.get_Mods() in /Users/dean/Projects/osu/osu.Game/Scoring/ScoreInfo.cs:line 193
 at osu.Game.Screens.Select.Leaderboards.BeatmapLeaderboard.<>c.<subscribeToLocalScores>b__40_2(ScoreInfo s) in /Users/dean/Projects/osu/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs:line 199
 at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
 at osu.Game.Database.RealmObjectExtensions.Detach[T](IEnumerable`1 items) in /Users/dean/Projects/osu/osu.Game/Database/RealmObjectExtensions.cs:line 180
 at osu.Game.Screens.Select.Leaderboards.BeatmapLeaderboard.<>c__DisplayClass40_0.<subscribeToLocalScores>g__localScoresChanged|1(IRealmCollection`1 sender, ChangeSet changes, Exception exception) in /Users/dean/Projects/osu/osu.Game/Screens/Select/Leaderboards/BeatmapLeaderboard.cs:line
209
 at Realms.RealmCollectionBase`1.Realms.INotifiable<Realms.NotifiableObjectHandleBase.CollectionChangeSet>.NotifyCallbacks(Nullable`1 changes, Nullable`1 exception)
 at Realms.NotifiableObjectHandleBase.NotifyObjectChanged(IntPtr managedHandle, IntPtr changes, IntPtr exception)
```
2022-03-09 17:57:55 +09:00
..
DifficultyAdjustSettingsControl.cs Set keyboard step to 0.1 for difficulty adjust sliders 2022-02-02 17:43:08 +03:00
DifficultyBindable.cs
IApplicableAfterBeatmapConversion.cs
IApplicableFailOverride.cs
IApplicableMod.cs
IApplicableToAudio.cs
IApplicableToBeatmap.cs
IApplicableToBeatmapConverter.cs
IApplicableToBeatmapProcessor.cs
IApplicableToDifficulty.cs
IApplicableToDrawableHitObject.cs
IApplicableToDrawableHitObjects.cs
IApplicableToDrawableRuleset.cs
IApplicableToHealthProcessor.cs
IApplicableToHitObject.cs
IApplicableToHUD.cs
IApplicableToPlayer.cs
IApplicableToRate.cs
IApplicableToSample.cs
IApplicableToScoreProcessor.cs
IApplicableToTrack.cs
ICreateReplay.cs
IHasSeed.cs
IMod.cs
IReadFromConfig.cs
IUpdatableByPlayfield.cs Only call IUpdatableByPlayfield.Update if the playfield isn't nested 2022-03-03 14:37:39 +08:00
Metronome.cs Replace TimeSignatures enum with struct for storage of arbitrary meter 2022-01-22 20:50:31 +01:00
Mod.cs Revert "Merge pull request #16889 from smoogipoo/remove-mod-multiplier" 2022-02-17 13:26:12 +09:00
ModAutoplay.cs
ModBarrelRoll.cs
ModBlockFail.cs
ModCinema.cs
ModClassic.cs
ModDaycore.cs
ModDifficultyAdjust.cs
ModDoubleTime.cs
ModEasy.cs
ModEasyWithExtraLives.cs
ModFailCondition.cs
ModFlashlight.cs Fix flashlight size multiplier printing with too many decimal digits 2022-02-02 20:41:25 +01:00
ModHalfTime.cs
ModHardRock.cs
ModHidden.cs
ModMirror.cs
ModMuted.cs
ModNightcore.cs Replace TimeSignatures enum with struct for storage of arbitrary meter 2022-01-22 20:50:31 +01:00
ModNoFail.cs
ModNoMod.cs
ModNoScope.cs
ModPerfect.cs
ModRandom.cs
ModRateAdjust.cs
ModRelax.cs
ModSuddenDeath.cs
ModTimeRamp.cs
ModType.cs
ModWindDown.cs
ModWindUp.cs
ModWithVisibilityAdjustment.cs
MultiMod.cs
UnknownMod.cs Change ToMod to return an UnknownMod rather than throw if a mod isn't available 2022-03-09 17:57:55 +09:00