1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Add nullable equality comparers

This commit is contained in:
Dan Balasescu 2021-11-16 15:44:47 +09:00
parent 29d0d5badf
commit 00f0321f25
2 changed files with 13 additions and 7 deletions

View File

@ -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")}"

View File

@ -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;
}