From 00f0321f25dde61ff830aaf2284a9a5b1a569fbe Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Tue, 16 Nov 2021 15:44:47 +0900 Subject: [PATCH] Add nullable equality comparers --- .../Multiplayer/MultiplayerRoomSettings.cs | 17 +++++++++++------ .../Online/Multiplayer/MultiplayerRoomUser.cs | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs b/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs index 0f7c61bbc6..e84026529f 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs @@ -29,12 +29,17 @@ namespace osu.Game.Online.Multiplayer [Key(4)] public QueueMode QueueMode { get; set; } = QueueMode.HostOnly; - public bool Equals(MultiplayerRoomSettings other) - => Password.Equals(other.Password, StringComparison.Ordinal) - && Name.Equals(other.Name, StringComparison.Ordinal) - && PlaylistItemId == other.PlaylistItemId - && MatchType == other.MatchType - && QueueMode == other.QueueMode; + public bool Equals(MultiplayerRoomSettings? other) + { + if (ReferenceEquals(this, other)) return true; + if (other == null) return false; + + return Password.Equals(other.Password, StringComparison.Ordinal) + && Name.Equals(other.Name, StringComparison.Ordinal) + && PlaylistItemId == other.PlaylistItemId + && MatchType == other.MatchType + && QueueMode == other.QueueMode; + } public override string ToString() => $"Name:{Name}" + $" Password:{(string.IsNullOrEmpty(Password) ? "no" : "yes")}" diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs b/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs index 519bfff116..f0b7dcbff8 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs @@ -48,9 +48,10 @@ namespace osu.Game.Online.Multiplayer UserID = userId; } - public bool Equals(MultiplayerRoomUser other) + public bool Equals(MultiplayerRoomUser? other) { if (ReferenceEquals(this, other)) return true; + if (other == null) return false; return UserID == other.UserID; }