1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 16:13:34 +08:00

Fix multiplayer potentially selecting mods of wrong ruleset when starting match

This commit is contained in:
Salman Ahmed 2024-01-13 11:17:08 +03:00
parent 4cde8685d3
commit c514550dfa
2 changed files with 7 additions and 6 deletions

View File

@ -75,7 +75,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
private BeatmapManager beatmapManager { get; set; }
[Resolved]
private RulesetStore rulesets { get; set; }
protected RulesetStore Rulesets { get; private set; }
[Resolved]
private IAPIProvider api { get; set; } = null!;
@ -422,7 +422,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
if (selected == null)
return;
var rulesetInstance = rulesets.GetRuleset(SelectedItem.Value.RulesetID)?.CreateInstance();
var rulesetInstance = Rulesets.GetRuleset(SelectedItem.Value.RulesetID)?.CreateInstance();
Debug.Assert(rulesetInstance != null);
var allowedMods = SelectedItem.Value.AllowedMods.Select(m => m.ToMod(rulesetInstance));
@ -463,7 +463,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
if (SelectedItem.Value == null || !this.IsCurrentScreen())
return;
var rulesetInstance = rulesets.GetRuleset(SelectedItem.Value.RulesetID)?.CreateInstance();
var rulesetInstance = Rulesets.GetRuleset(SelectedItem.Value.RulesetID)?.CreateInstance();
Debug.Assert(rulesetInstance != null);
Mods.Value = UserMods.Value.Concat(SelectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))).ToList();
}
@ -473,7 +473,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
if (SelectedItem.Value == null || !this.IsCurrentScreen())
return;
Ruleset.Value = rulesets.GetRuleset(SelectedItem.Value.RulesetID);
Ruleset.Value = Rulesets.GetRuleset(SelectedItem.Value.RulesetID);
}
private void beginHandlingTrack()

View File

@ -241,8 +241,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
// update local mods based on room's reported status for the local user (omitting the base call implementation).
// this makes the server authoritative, and avoids the local user potentially setting mods that the server is not aware of (ie. if the match was started during the selection being changed).
var ruleset = Ruleset.Value.CreateInstance();
Mods.Value = client.LocalUser.Mods.Select(m => m.ToMod(ruleset)).Concat(SelectedItem.Value.RequiredMods.Select(m => m.ToMod(ruleset))).ToList();
var rulesetInstance = Rulesets.GetRuleset(SelectedItem.Value.RulesetID)?.CreateInstance();
Debug.Assert(rulesetInstance != null);
Mods.Value = client.LocalUser.Mods.Select(m => m.ToMod(rulesetInstance)).Concat(SelectedItem.Value.RequiredMods.Select(m => m.ToMod(rulesetInstance))).ToList();
}
[Resolved(canBeNull: true)]