mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 12:23:13 +08:00
Change PlayingUsers population logic to match expectations
This commit is contained in:
parent
9155671557
commit
1d311a6680
@ -133,6 +133,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
apiRoom = null;
|
apiRoom = null;
|
||||||
Room = null;
|
Room = null;
|
||||||
|
PlayingUsers.Clear();
|
||||||
|
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
}, false);
|
}, false);
|
||||||
@ -302,8 +303,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
|
|
||||||
Room.Users.Single(u => u.UserID == userId).State = state;
|
Room.Users.Single(u => u.UserID == userId).State = state;
|
||||||
|
|
||||||
if (state != MultiplayerUserState.Playing)
|
updatePlayingUsers(userId, state);
|
||||||
PlayingUsers.Remove(userId);
|
|
||||||
|
|
||||||
RoomUpdated?.Invoke();
|
RoomUpdated?.Invoke();
|
||||||
}, false);
|
}, false);
|
||||||
@ -337,8 +337,6 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
if (Room == null)
|
if (Room == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PlayingUsers.AddRange(Room.Users.Where(u => u.State == MultiplayerUserState.Playing).Select(u => u.UserID));
|
|
||||||
|
|
||||||
MatchStarted?.Invoke();
|
MatchStarted?.Invoke();
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
@ -454,5 +452,17 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
apiRoom.Playlist.Clear(); // Clearing should be unnecessary, but here for sanity.
|
apiRoom.Playlist.Clear(); // Clearing should be unnecessary, but here for sanity.
|
||||||
apiRoom.Playlist.Add(playlistItem);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user