diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index d2c27b766c..d76bd163e1 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -364,25 +364,19 @@ public void PresentBeatmap(BeatmapSetInfo beatmap, Predicate diffic // we might even already be at the song if (Beatmap.Value.BeatmapSetInfo.Hash == databasedSet.Hash && (difficultyCriteria?.Invoke(Beatmap.Value.BeatmapInfo) ?? true)) - { return; - } // Find beatmaps that match our predicate. - var beatmaps = databasedSet.Beatmaps.Where(b => difficultyCriteria?.Invoke(b) ?? true); + var beatmaps = databasedSet.Beatmaps.Where(b => difficultyCriteria?.Invoke(b) ?? true).ToList(); // Use all beatmaps if predicate matched nothing - if (!beatmaps.Any()) + if (beatmaps.Count == 0) beatmaps = databasedSet.Beatmaps; - // Try to select recommended beatmap - // This should give us a beatmap from current ruleset if there are any in our matched beatmaps - var selection = DifficultyRecommender.GetRecommendedBeatmap(beatmaps); - // Fallback if a difficulty can't be recommended, maybe we are offline - // First try to find a beatmap in current ruleset - selection ??= beatmaps.FirstOrDefault(b => b.Ruleset.Equals(Ruleset.Value)); - // Otherwise use first beatmap - selection ??= beatmaps.First(); + // Prefer recommended beatmap if recommendations are available, else fallback to a sane selection. + var selection = DifficultyRecommender.GetRecommendedBeatmap(beatmaps) + ?? beatmaps.FirstOrDefault(b => b.Ruleset.Equals(Ruleset.Value)) + ?? beatmaps.First(); Ruleset.Value = selection.Ruleset; Beatmap.Value = BeatmapManager.GetWorkingBeatmap(selection); diff --git a/osu.Game/Screens/Select/DifficultyRecommender.cs b/osu.Game/Screens/Select/DifficultyRecommender.cs index fa48316e9d..3b3fc812e6 100644 --- a/osu.Game/Screens/Select/DifficultyRecommender.cs +++ b/osu.Game/Screens/Select/DifficultyRecommender.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; @@ -47,6 +48,7 @@ private void load() /// /// A collection of beatmaps to select a difficulty from. /// The recommended difficulty, or null if a recommendation could not be provided. + [CanBeNull] public BeatmapInfo GetRecommendedBeatmap(IEnumerable beatmaps) { if (!recommendedStarDifficulty.Any())