From 459847cb80b3e34ca4d4bf35dabd7d1d081b94d5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 21 Jan 2025 19:51:13 +0900 Subject: [PATCH] Perform client side validation that the selected beatmap and ruleset have valid online IDs This is local to playlists, since in multiplayer the validation is already provided by `osu-server-spectator`. --- osu.Game/Screens/OnlinePlay/OnlinePlayStyleSelect.cs | 1 + .../OnlinePlay/Playlists/PlaylistsRoomStyleSelect.cs | 7 +++++++ osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs | 3 +++ osu.Game/Screens/Select/FilterCriteria.cs | 2 ++ 4 files changed, 13 insertions(+) diff --git a/osu.Game/Screens/OnlinePlay/OnlinePlayStyleSelect.cs b/osu.Game/Screens/OnlinePlay/OnlinePlayStyleSelect.cs index 22290f8fed..4d34000d3c 100644 --- a/osu.Game/Screens/OnlinePlay/OnlinePlayStyleSelect.cs +++ b/osu.Game/Screens/OnlinePlay/OnlinePlayStyleSelect.cs @@ -89,6 +89,7 @@ namespace osu.Game.Screens.OnlinePlay // Must be from the same set as the playlist item. criteria.BeatmapSetId = beatmapSetId; + criteria.HasOnlineID = true; // Must be within 30s of the playlist item. criteria.Length.Min = itemLength - 30000; diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomStyleSelect.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomStyleSelect.cs index f3d868b0de..912496ba34 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomStyleSelect.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsRoomStyleSelect.cs @@ -21,6 +21,13 @@ namespace osu.Game.Screens.OnlinePlay.Playlists protected override bool OnStart() { + // Beatmaps without a valid online ID are filtered away; this is just a final safety. + if (base.Beatmap.Value.BeatmapInfo.OnlineID < 0) + return false; + + if (base.Ruleset.Value.OnlineID < 0) + return false; + Beatmap.Value = base.Beatmap.Value.BeatmapInfo; Ruleset.Value = base.Ruleset.Value; this.Exit(); diff --git a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs index 95186e98d8..dc77b0101e 100644 --- a/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs +++ b/osu.Game/Screens/Select/Carousel/CarouselBeatmap.cs @@ -90,6 +90,9 @@ namespace osu.Game.Screens.Select.Carousel if (match && criteria.RulesetCriteria != null) match &= criteria.RulesetCriteria.Matches(BeatmapInfo, criteria); + if (match && criteria.HasOnlineID == true) + match &= BeatmapInfo.OnlineID >= 0; + if (match && criteria.BeatmapSetId != null) match &= criteria.BeatmapSetId == BeatmapInfo.BeatmapSet?.OnlineID; diff --git a/osu.Game/Screens/Select/FilterCriteria.cs b/osu.Game/Screens/Select/FilterCriteria.cs index 63dbdfbed3..15cb3c5104 100644 --- a/osu.Game/Screens/Select/FilterCriteria.cs +++ b/osu.Game/Screens/Select/FilterCriteria.cs @@ -58,6 +58,8 @@ namespace osu.Game.Screens.Select public bool AllowConvertedBeatmaps; public int? BeatmapSetId; + public bool? HasOnlineID; + private string searchText = string.Empty; ///