1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 09:42:57 +08:00

Change PlayingUsers population logic to match expectations

This commit is contained in:
Bartłomiej Dach 2020-12-28 19:11:44 +01:00
parent 9155671557
commit 1d311a6680

View File

@ -133,6 +133,7 @@ namespace osu.Game.Online.Multiplayer
apiRoom = null;
Room = null;
PlayingUsers.Clear();
RoomUpdated?.Invoke();
}, false);
@ -302,8 +303,7 @@ namespace osu.Game.Online.Multiplayer
Room.Users.Single(u => u.UserID == userId).State = state;
if (state != MultiplayerUserState.Playing)
PlayingUsers.Remove(userId);
updatePlayingUsers(userId, state);
RoomUpdated?.Invoke();
}, false);
@ -337,8 +337,6 @@ namespace osu.Game.Online.Multiplayer
if (Room == null)
return;
PlayingUsers.AddRange(Room.Users.Where(u => u.State == MultiplayerUserState.Playing).Select(u => u.UserID));
MatchStarted?.Invoke();
}, false);
@ -454,5 +452,17 @@ namespace osu.Game.Online.Multiplayer
apiRoom.Playlist.Clear(); // Clearing should be unnecessary, but here for sanity.
apiRoom.Playlist.Add(playlistItem);
}
private void updatePlayingUsers(int userId, MultiplayerUserState state)
{
bool isPlaying = state >= MultiplayerUserState.WaitingForLoad && state <= MultiplayerUserState.FinishedPlay;
bool wasPlaying = PlayingUsers.Contains(userId);
if (!wasPlaying && isPlaying)
PlayingUsers.Add(userId);
if (wasPlaying && !isPlaying)
PlayingUsers.Remove(userId);
}
}
}