1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 04:52:55 +08:00

Sanity check received user joined messages

While test failures fixed in 9843da5 were a shortcoming of the test,
they exposed a potential vulnerable point of the multiplayer client
logic. In case of unreliable message delivery it is not unreasonable
that duplicate messages might arrive, in which case the same scenario
that failed in the tests could crash the game.

To ensure that is not the case, explicitly screen each new joined user
against the room user list, to ensure that duplicates do not show up.
`UserLeft` is already tolerant in that respect (if a user is requested
to be removed twice by the server, the second removal just won't do
anything).
This commit is contained in:
Bartłomiej Dach 2020-12-23 20:34:19 +01:00
parent 47020c8887
commit a71496bc4e

View File

@ -226,6 +226,10 @@ namespace osu.Game.Online.RealtimeMultiplayer
if (Room == null)
return;
// for sanity, ensure that there can be no duplicate users in the room user list.
if (Room.Users.Any(existing => existing.UserID == user.UserID))
return;
Room.Users.Add(user);
RoomChanged?.Invoke();