mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 13:22:55 +08:00
Add sanity check to prevent TimeshiftPlayer from starting with incorrect beatmap/ruleset/mods
This commit is contained in:
parent
a3f71d69a9
commit
c59d84fd21
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using osu.Framework.Allocation;
|
||||
@ -11,6 +12,8 @@ using osu.Framework.Screens;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Multi.Ranking;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -30,6 +33,12 @@ namespace osu.Game.Screens.Multi.Play
|
||||
[Resolved]
|
||||
private APIAccess api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected Bindable<IEnumerable<Mod>> CurrentMods { get; private set; }
|
||||
|
||||
public TimeshiftPlayer(PlaylistItem playlistItem)
|
||||
{
|
||||
this.playlistItem = playlistItem;
|
||||
@ -44,6 +53,16 @@ namespace osu.Game.Screens.Multi.Play
|
||||
|
||||
bool failed = false;
|
||||
|
||||
// Sanity checks to ensure that TimeshiftPlayer matches the settings for the current PlaylistItem
|
||||
if (Beatmap.Value.BeatmapInfo.OnlineBeatmapID != playlistItem.Beatmap.OnlineBeatmapID)
|
||||
throw new InvalidOperationException("Current Beatmap does not match PlaylistItem's Beatmap");
|
||||
|
||||
if (ruleset.Value.ID != playlistItem.Ruleset.ID)
|
||||
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
|
||||
|
||||
if (!CurrentMods.Value.Equals(playlistItem.RequiredMods))
|
||||
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
|
||||
|
||||
var req = new CreateRoomScoreRequest(roomId.Value ?? 0, playlistItem.ID);
|
||||
req.Success += r => token = r.ID;
|
||||
req.Failure += e =>
|
||||
|
Loading…
Reference in New Issue
Block a user