From 0d86dab80a4791b0882c3a79ddd462121ad146ab Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 14 Oct 2021 17:37:08 +0900 Subject: [PATCH] Fix multiplayer components updating when not alive Should close https://github.com/ppy/osu/issues/15092. - [ ] Depends on https://github.com/ppy/osu-framework/pull/4826. --- .../Multiplayer/MultiplayerRoomComposite.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomComposite.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomComposite.cs index 0f256160eb..a380ddef25 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomComposite.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomComposite.cs @@ -19,15 +19,19 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer { base.LoadComplete(); - Client.RoomUpdated += OnRoomUpdated; - - Client.UserLeft += UserLeft; - Client.UserKicked += UserKicked; - Client.UserJoined += UserJoined; + Client.RoomUpdated += invokeOnRoomUpdated; + Client.UserLeft += invokeUserLeft; + Client.UserKicked += invokeUserKicked; + Client.UserJoined += invokeUserJoined; OnRoomUpdated(); } + private void invokeOnRoomUpdated() => Scheduler.AddOnce(OnRoomUpdated); + private void invokeUserJoined(MultiplayerRoomUser user) => Scheduler.AddOnce(UserJoined, user); + private void invokeUserKicked(MultiplayerRoomUser user) => Scheduler.AddOnce(UserKicked, user); + private void invokeUserLeft(MultiplayerRoomUser user) => Scheduler.AddOnce(UserLeft, user); + /// /// Invoked when a user has joined the room. /// @@ -63,10 +67,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer { if (Client != null) { - Client.UserLeft -= UserLeft; - Client.UserKicked -= UserKicked; - Client.UserJoined -= UserJoined; - Client.RoomUpdated -= OnRoomUpdated; + Client.RoomUpdated -= invokeOnRoomUpdated; + Client.UserLeft -= invokeUserLeft; + Client.UserKicked -= invokeUserKicked; + Client.UserJoined -= invokeUserJoined; } base.Dispose(isDisposing);