1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 08:07:24 +08:00

Move scheduler logic to client callback rather than inside the update method

This commit is contained in:
Dean Herbert 2021-02-11 16:00:26 +09:00
parent 21f66a19fd
commit 549e7520c5

View File

@ -281,6 +281,17 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
}, true);
}
protected override void UpdateMods()
{
if (SelectedItem.Value == null || client.LocalUser == null)
return;
// 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 settings 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).ToList();
}
public override bool OnBackButton()
{
if (client.Room != null && settingsOverlay.State.Value == Visibility.Visible)
@ -370,23 +381,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
private void onRoomUpdated()
{
UpdateMods(); // user mods may have changed.
}
protected override void UpdateMods()
{
if (SelectedItem.Value == null || client.LocalUser == null)
return;
// 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 settings mods that the server is not aware of (ie. if the match was started during the selection being changed).
var localUserMods = client.LocalUser.Mods.ToList();
Schedule(() =>
{
var ruleset = Ruleset.Value.CreateInstance();
Mods.Value = localUserMods.Select(m => m.ToMod(ruleset)).Concat(SelectedItem.Value.RequiredMods).ToList();
});
// user mods may have changed.
Scheduler.AddOnce(UpdateMods);
}
private void onLoadRequested()