diff --git a/osu.Game/Online/Multiplayer/StatefulMultiplayerClient.cs b/osu.Game/Online/Multiplayer/StatefulMultiplayerClient.cs index 98b53e723c..fcb0977f53 100644 --- a/osu.Game/Online/Multiplayer/StatefulMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/StatefulMultiplayerClient.cs @@ -33,7 +33,7 @@ namespace osu.Game.Online.Multiplayer /// /// Invoked when any change occurs to the multiplayer room. /// - public event Action? RoomChanged; + public event Action? RoomUpdated; /// /// Invoked when the multiplayer server requests the current beatmap to be loaded into play. @@ -134,7 +134,7 @@ namespace osu.Game.Online.Multiplayer apiRoom = null; Room = null; - RoomChanged?.Invoke(); + RoomUpdated?.Invoke(); }, false); return Task.CompletedTask; @@ -214,7 +214,7 @@ namespace osu.Game.Online.Multiplayer break; } - RoomChanged?.Invoke(); + RoomUpdated?.Invoke(); }, false); return Task.CompletedTask; @@ -238,7 +238,7 @@ namespace osu.Game.Online.Multiplayer Room.Users.Add(user); - RoomChanged?.Invoke(); + RoomUpdated?.Invoke(); }, false); } @@ -255,7 +255,7 @@ namespace osu.Game.Online.Multiplayer Room.Users.Remove(user); PlayingUsers.Remove(user.UserID); - RoomChanged?.Invoke(); + RoomUpdated?.Invoke(); }, false); return Task.CompletedTask; @@ -278,7 +278,7 @@ namespace osu.Game.Online.Multiplayer Room.Host = user; apiRoom.Host.Value = user?.User; - RoomChanged?.Invoke(); + RoomUpdated?.Invoke(); }, false); return Task.CompletedTask; @@ -305,7 +305,7 @@ namespace osu.Game.Online.Multiplayer if (state != MultiplayerUserState.Playing) PlayingUsers.Remove(userId); - RoomChanged?.Invoke(); + RoomUpdated?.Invoke(); }, false); return Task.CompletedTask; @@ -419,7 +419,7 @@ namespace osu.Game.Online.Multiplayer // In-order for the client to not display an outdated beatmap, the playlist is forcefully cleared here. apiRoom.Playlist.Clear(); - RoomChanged?.Invoke(); + RoomUpdated?.Invoke(); var req = new GetBeatmapSetRequest(settings.BeatmapID, BeatmapSetLookupType.BeatmapId); req.Success += res => updatePlaylist(settings, res); diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs index 15d6ef8aff..281e92404c 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs @@ -56,11 +56,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match sampleReadyCount = audio.Samples.Get(@"SongSelect/select-difficulty"); } - protected override void OnRoomChanged() + protected override void OnRoomUpdated() { - base.OnRoomChanged(); + base.OnRoomUpdated(); + + // this method is called on leaving the room, so the local user may not exist in the room any more. + localUser = Room?.Users.SingleOrDefault(u => u.User?.Id == api.LocalUser.Value.Id); - localUser = Room?.Users.Single(u => u.User?.Id == api.LocalUser.Value.Id); button.Enabled.Value = Client.Room?.State == MultiplayerRoomState.Open; updateState(); } diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomComposite.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomComposite.cs index ac608a13d4..8030107ad8 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomComposite.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerRoomComposite.cs @@ -19,18 +19,21 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer { base.LoadComplete(); - Client.RoomChanged += OnRoomChanged; - OnRoomChanged(); + Client.RoomUpdated += OnRoomUpdated; + OnRoomUpdated(); } - protected virtual void OnRoomChanged() + /// + /// Invoked when any change occurs to the multiplayer room. + /// + protected virtual void OnRoomUpdated() { } protected override void Dispose(bool isDisposing) { if (Client != null) - Client.RoomChanged -= OnRoomChanged; + Client.RoomUpdated -= OnRoomUpdated; base.Dispose(isDisposing); } diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs index 044afa7445..de3069b2f6 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantPanel.cs @@ -135,9 +135,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants }; } - protected override void OnRoomChanged() + protected override void OnRoomUpdated() { - base.OnRoomChanged(); + base.OnRoomUpdated(); if (Room == null) return; diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantsList.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantsList.cs index b9ac096c4a..3759e45f18 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantsList.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Participants/ParticipantsList.cs @@ -36,9 +36,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants }; } - protected override void OnRoomChanged() + protected override void OnRoomUpdated() { - base.OnRoomChanged(); + base.OnRoomUpdated(); if (Room == null) panels.Clear();