diff --git a/osu.Game/Online/RealtimeMultiplayer/MultiplayerClientState.cs b/osu.Game/Online/RealtimeMultiplayer/MultiplayerClientState.cs index 17c209ba26..8c440abba3 100644 --- a/osu.Game/Online/RealtimeMultiplayer/MultiplayerClientState.cs +++ b/osu.Game/Online/RealtimeMultiplayer/MultiplayerClientState.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +#nullable enable + namespace osu.Game.Online.RealtimeMultiplayer { public class MultiplayerClientState diff --git a/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoom.cs b/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoom.cs index dc7ced7a9a..e70e12c89e 100644 --- a/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoom.cs +++ b/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoom.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +#nullable enable + using System; using System.Collections.Generic; @@ -25,13 +27,18 @@ namespace osu.Game.Online.RealtimeMultiplayer /// /// All currently enforced game settings for this room. /// - public MultiplayerRoomSettings Settings { get; set; } + public MultiplayerRoomSettings Settings { get; set; } = MultiplayerRoomSettings.Empty(); /// /// All users currently in this room. /// public List Users { get; set; } = new List(); + /// + /// The host of this room, in control of changing room settings. + /// + public MultiplayerRoomUser? Host { get; set; } + private object writeLock = new object(); /// diff --git a/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomSettings.cs b/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomSettings.cs index 4c2c014cd9..3137afa8a4 100644 --- a/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomSettings.cs +++ b/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomSettings.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +#nullable enable + using System; using System.Collections.Generic; using System.Linq; @@ -9,6 +11,7 @@ using osu.Game.Online.API; namespace osu.Game.Online.RealtimeMultiplayer { + [Serializable] public class MultiplayerRoomSettings : IEquatable { public int? BeatmapID { get; set; } @@ -18,8 +21,10 @@ namespace osu.Game.Online.RealtimeMultiplayer [NotNull] public IEnumerable Mods { get; set; } = Enumerable.Empty(); - public bool Equals(MultiplayerRoomSettings other) => BeatmapID == other?.BeatmapID && Mods.SequenceEqual(other?.Mods) && RulesetID == other?.RulesetID; + public bool Equals(MultiplayerRoomSettings other) => BeatmapID == other.BeatmapID && Mods.SequenceEqual(other.Mods) && RulesetID == other.RulesetID; public override string ToString() => $"Beatmap:{BeatmapID} Mods:{string.Join(',', Mods)} Ruleset:{RulesetID}"; + + public static MultiplayerRoomSettings Empty() => new MultiplayerRoomSettings(); } } diff --git a/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomState.cs b/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomState.cs index 60e47e9027..9f76cd945e 100644 --- a/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomState.cs +++ b/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomState.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +#nullable enable + namespace osu.Game.Online.RealtimeMultiplayer { /// diff --git a/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomUser.cs b/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomUser.cs index 3daebe3dda..17aca4458a 100644 --- a/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomUser.cs +++ b/osu.Game/Online/RealtimeMultiplayer/MultiplayerRoomUser.cs @@ -1,27 +1,29 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +#nullable enable + using System; using osu.Game.Users; namespace osu.Game.Online.RealtimeMultiplayer { + [Serializable] public class MultiplayerRoomUser : IEquatable { + public readonly long UserID; + + public MultiplayerUserState State { get; set; } = MultiplayerUserState.Idle; + + public User? User { get; set; } + public MultiplayerRoomUser(in int userId) { UserID = userId; } - public long UserID { get; } - - public MultiplayerUserState State { get; set; } - - public User User { get; set; } - public bool Equals(MultiplayerRoomUser other) { - if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return UserID == other.UserID; @@ -29,9 +31,8 @@ namespace osu.Game.Online.RealtimeMultiplayer public override bool Equals(object obj) { - if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != this.GetType()) return false; + if (obj.GetType() != GetType()) return false; return Equals((MultiplayerRoomUser)obj); }