From e8338f2711ef20d3fc8ae16828d5f7b303583ad2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 21 Jul 2021 18:59:02 +0900 Subject: [PATCH 01/21] Add basic class structure for match rulesets and required state --- .../Online/Multiplayer/IMultiplayerClient.cs | 13 +++++++++++++ .../Multiplayer/MatchRulesetRoomState.cs | 18 ++++++++++++++++++ .../Online/Multiplayer/MatchRulesetType.cs | 11 +++++++++++ .../Multiplayer/MatchRulesetUserState.cs | 18 ++++++++++++++++++ .../MatchRulesets/TeamVs/MultiplayerTeam.cs | 19 +++++++++++++++++++ .../TeamVs/TeamVsMatchRoomState.cs | 14 ++++++++++++++ .../TeamVs/TeamVsMatchUserState.cs | 13 +++++++++++++ .../Online/Multiplayer/MultiplayerClient.cs | 10 ++++++++++ .../Online/Multiplayer/MultiplayerRoom.cs | 3 +++ .../Multiplayer/MultiplayerRoomSettings.cs | 7 ++++++- .../Online/Multiplayer/MultiplayerRoomUser.cs | 3 +++ 11 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs create mode 100644 osu.Game/Online/Multiplayer/MatchRulesetType.cs create mode 100644 osu.Game/Online/Multiplayer/MatchRulesetUserState.cs create mode 100644 osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs create mode 100644 osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs create mode 100644 osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs diff --git a/osu.Game/Online/Multiplayer/IMultiplayerClient.cs b/osu.Game/Online/Multiplayer/IMultiplayerClient.cs index 6d7b9d24d6..cfe5af3393 100644 --- a/osu.Game/Online/Multiplayer/IMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/IMultiplayerClient.cs @@ -50,6 +50,19 @@ namespace osu.Game.Online.Multiplayer /// The new state of the user. Task UserStateChanged(int userId, MultiplayerUserState state); + /// + /// Signals that the match ruleset state has changed for a user in this room. + /// + /// The ID of the user performing a state change. + /// The new state of the user. + Task MatchRulesetUserStateChanged(int userId, MatchRulesetUserState state); + + /// + /// Signals that the match ruleset state has changed for this room. + /// + /// The new state of the room. + Task MatchRulesetRoomStateChanged(MatchRulesetRoomState state); + /// /// Signals that a user in this room changed their beatmap availability state. /// diff --git a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs new file mode 100644 index 0000000000..21bdec1b20 --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs @@ -0,0 +1,18 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Multiplayer +{ + /// + /// Room-wide state for the current match ruleset. + /// Can be used to contain any state which should be used before or during match gameplay. + /// + [Serializable] + [MessagePackObject] + public abstract class MatchRulesetRoomState + { + } +} diff --git a/osu.Game/Online/Multiplayer/MatchRulesetType.cs b/osu.Game/Online/Multiplayer/MatchRulesetType.cs new file mode 100644 index 0000000000..b87a8eb174 --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesetType.cs @@ -0,0 +1,11 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Online.Multiplayer +{ + public enum MatchRulesetType + { + HeadToHead, + TeamVs + } +} diff --git a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs new file mode 100644 index 0000000000..647574b54a --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs @@ -0,0 +1,18 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Multiplayer +{ + /// + /// User specific state for the current match ruleset. + /// Can be used to contain any state which should be used before or during match gameplay. + /// + [Serializable] + [MessagePackObject] + public abstract class MatchRulesetUserState + { + } +} diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs new file mode 100644 index 0000000000..532111671e --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs @@ -0,0 +1,19 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs +{ + [Serializable] + [MessagePackObject] + public class MultiplayerTeam + { + [Key(0)] + public int ID { get; set; } + + [Key(1)] + public string Name { get; set; } + } +} diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs new file mode 100644 index 0000000000..6383617100 --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs @@ -0,0 +1,14 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Collections.Generic; +using MessagePack; + +namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs +{ + public class TeamVsMatchRoomState : MatchRulesetRoomState + { + [Key(0)] + public List Teams { get; set; } + } +} diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs new file mode 100644 index 0000000000..b35cfd3cdd --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs @@ -0,0 +1,13 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using MessagePack; + +namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs +{ + public class TeamVsMatchUserState : MatchRulesetUserState + { + [Key(0)] + public int TeamID { get; set; } + } +} diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index 9972d7e88d..fa0cbb1dff 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -420,6 +420,16 @@ namespace osu.Game.Online.Multiplayer return Task.CompletedTask; } + Task IMultiplayerClient.MatchRulesetUserStateChanged(int userId, MatchRulesetUserState state) + { + throw new NotImplementedException(); + } + + Task IMultiplayerClient.MatchRulesetRoomStateChanged(MatchRulesetRoomState state) + { + throw new NotImplementedException(); + } + Task IMultiplayerClient.UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability) { if (Room == null) diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs b/osu.Game/Online/Multiplayer/MultiplayerRoom.cs index c5fa6253ed..19c0d3cb24 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoom.cs @@ -47,6 +47,9 @@ namespace osu.Game.Online.Multiplayer [Key(4)] public MultiplayerRoomUser? Host { get; set; } + [Key(5)] + public MatchRulesetRoomState? MatchRulesetState { get; set; } + [JsonConstructor] [SerializationConstructor] public MultiplayerRoom(long roomId) diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs b/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs index 4e94c5982f..2c49e3b251 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs @@ -39,6 +39,9 @@ namespace osu.Game.Online.Multiplayer [Key(7)] public string Password { get; set; } = string.Empty; + [Key(8)] + public MatchRulesetType MatchRulesetType { get; set; } + public bool Equals(MultiplayerRoomSettings other) => BeatmapID == other.BeatmapID && BeatmapChecksum == other.BeatmapChecksum @@ -47,7 +50,8 @@ namespace osu.Game.Online.Multiplayer && RulesetID == other.RulesetID && Password.Equals(other.Password, StringComparison.Ordinal) && Name.Equals(other.Name, StringComparison.Ordinal) - && PlaylistItemId == other.PlaylistItemId; + && PlaylistItemId == other.PlaylistItemId + && MatchRulesetType == other.MatchRulesetType; public override string ToString() => $"Name:{Name}" + $" Beatmap:{BeatmapID} ({BeatmapChecksum})" @@ -55,6 +59,7 @@ namespace osu.Game.Online.Multiplayer + $" AllowedMods:{string.Join(',', AllowedMods)}" + $" Password:{(string.IsNullOrEmpty(Password) ? "no" : "yes")}" + $" Ruleset:{RulesetID}" + + $" MatchRuleset:{MatchRulesetType}" + $" Item:{PlaylistItemId}"; } } diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs b/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs index a49a8f083c..d97d49aa8a 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs @@ -36,6 +36,9 @@ namespace osu.Game.Online.Multiplayer [Key(3)] public IEnumerable Mods { get; set; } = Enumerable.Empty(); + [Key(4)] + public MatchRulesetUserState? MatchRulesetState { get; set; } + [IgnoreMember] public User? User { get; set; } From 9d1e95caf01b548f80dfe59d11f5a2576fe40ca2 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 21 Jul 2021 19:13:56 +0900 Subject: [PATCH 02/21] Add flow for sending match ruleset specific messages to the server --- .../Multiplayer/IMultiplayerRoomServer.cs | 6 ++++++ .../Multiplayer/MatchRulesetUserRequest.cs | 17 +++++++++++++++++ .../MatchRulesets/TeamVs/ChangeTeamRequest.cs | 13 +++++++++++++ .../Online/Multiplayer/MultiplayerClient.cs | 2 ++ .../Multiplayer/OnlineMultiplayerClient.cs | 8 ++++++++ .../Visual/Multiplayer/TestMultiplayerClient.cs | 2 ++ 6 files changed, 48 insertions(+) create mode 100644 osu.Game/Online/Multiplayer/MatchRulesetUserRequest.cs create mode 100644 osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs diff --git a/osu.Game/Online/Multiplayer/IMultiplayerRoomServer.cs b/osu.Game/Online/Multiplayer/IMultiplayerRoomServer.cs index 3527ce6314..20c9f9e216 100644 --- a/osu.Game/Online/Multiplayer/IMultiplayerRoomServer.cs +++ b/osu.Game/Online/Multiplayer/IMultiplayerRoomServer.cs @@ -55,6 +55,12 @@ namespace osu.Game.Online.Multiplayer /// The proposed new mods, excluding any required by the room itself. Task ChangeUserMods(IEnumerable newMods); + /// + /// Send a match ruleset specific request. + /// + /// The request to send. + Task SendMatchRulesetRequest(MatchRulesetUserRequest request); + /// /// As the host of a room, start the match. /// diff --git a/osu.Game/Online/Multiplayer/MatchRulesetUserRequest.cs b/osu.Game/Online/Multiplayer/MatchRulesetUserRequest.cs new file mode 100644 index 0000000000..3cc430a2b7 --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesetUserRequest.cs @@ -0,0 +1,17 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Multiplayer +{ + /// + /// A request from a user to perform an action specific to the current match ruleset. + /// + [Serializable] + [MessagePackObject] + public abstract class MatchRulesetUserRequest + { + } +} diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs new file mode 100644 index 0000000000..9dd01ea87c --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs @@ -0,0 +1,13 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using MessagePack; + +namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs +{ + public class ChangeTeamRequest : MatchRulesetUserRequest + { + [Key(0)] + public int TeamID { get; set; } + } +} diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index fa0cbb1dff..299da2e06e 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -293,6 +293,8 @@ namespace osu.Game.Online.Multiplayer public abstract Task ChangeUserMods(IEnumerable newMods); + public abstract Task SendMatchRulesetRequest(MatchRulesetUserRequest request); + public abstract Task StartMatch(); Task IMultiplayerClient.RoomStateChanged(MultiplayerRoomState state) diff --git a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs index 726e26ebe1..88d8c04c98 100644 --- a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs @@ -118,6 +118,14 @@ namespace osu.Game.Online.Multiplayer return connection.InvokeAsync(nameof(IMultiplayerServer.ChangeUserMods), newMods); } + public override Task SendMatchRulesetRequest(MatchRulesetUserRequest request) + { + if (!IsConnected.Value) + return Task.CompletedTask; + + return connection.InvokeAsync(nameof(IMultiplayerServer.SendMatchRulesetRequest), request); + } + public override Task StartMatch() { if (!IsConnected.Value) diff --git a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs index 3349d670c8..6a8bf87ff0 100644 --- a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs +++ b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs @@ -192,6 +192,8 @@ namespace osu.Game.Tests.Visual.Multiplayer return Task.CompletedTask; } + public override Task SendMatchRulesetRequest(MatchRulesetUserRequest request) => Task.CompletedTask; + public override Task StartMatch() { Debug.Assert(Room != null); From 1c125eef121ebfda79bf7069765092433e242eff Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Jul 2021 18:16:53 +0900 Subject: [PATCH 03/21] Make `Users` an `IList` for more flexibility server-side --- osu.Game/Online/Multiplayer/MultiplayerRoom.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs b/osu.Game/Online/Multiplayer/MultiplayerRoom.cs index 19c0d3cb24..07d87fafc3 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoom.cs @@ -39,7 +39,7 @@ namespace osu.Game.Online.Multiplayer /// All users currently in this room. /// [Key(3)] - public List Users { get; set; } = new List(); + public IList Users { get; set; } = new List(); /// /// The host of this room, in control of changing room settings. From 1d645d4ca99b6c8787ab53a7ba9e2d7adc62a5c0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 23 Jul 2021 19:48:52 +0900 Subject: [PATCH 04/21] Mark base classes non-abstract to fix messagepack serialisation --- osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs | 2 +- osu.Game/Online/Multiplayer/MatchRulesetUserState.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs index 21bdec1b20..d8072efa2a 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs @@ -12,7 +12,7 @@ namespace osu.Game.Online.Multiplayer /// [Serializable] [MessagePackObject] - public abstract class MatchRulesetRoomState + public class MatchRulesetRoomState { } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs index 647574b54a..e8d9961dbd 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs @@ -12,7 +12,7 @@ namespace osu.Game.Online.Multiplayer /// [Serializable] [MessagePackObject] - public abstract class MatchRulesetUserState + public class MatchRulesetUserState { } } From d17b2b3268982af8801539dcdaf5bd6390a09c4c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 26 Jul 2021 17:38:08 +0900 Subject: [PATCH 05/21] Add boilerplate for server events --- .../Online/Multiplayer/IMultiplayerClient.cs | 6 ++++++ .../Multiplayer/MatchRulesetServerEvent.cs | 17 +++++++++++++++++ .../Online/Multiplayer/MultiplayerClient.cs | 5 +++++ 3 files changed, 28 insertions(+) create mode 100644 osu.Game/Online/Multiplayer/MatchRulesetServerEvent.cs diff --git a/osu.Game/Online/Multiplayer/IMultiplayerClient.cs b/osu.Game/Online/Multiplayer/IMultiplayerClient.cs index cfe5af3393..839ec9bd1f 100644 --- a/osu.Game/Online/Multiplayer/IMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/IMultiplayerClient.cs @@ -63,6 +63,12 @@ namespace osu.Game.Online.Multiplayer /// The new state of the room. Task MatchRulesetRoomStateChanged(MatchRulesetRoomState state); + /// + /// Send a match ruleset specific request. + /// + /// The event to handle. + Task MatchRulesetEvent(MatchRulesetServerEvent e); + /// /// Signals that a user in this room changed their beatmap availability state. /// diff --git a/osu.Game/Online/Multiplayer/MatchRulesetServerEvent.cs b/osu.Game/Online/Multiplayer/MatchRulesetServerEvent.cs new file mode 100644 index 0000000000..c45615e914 --- /dev/null +++ b/osu.Game/Online/Multiplayer/MatchRulesetServerEvent.cs @@ -0,0 +1,17 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using MessagePack; + +namespace osu.Game.Online.Multiplayer +{ + /// + /// An event from the server to allow clients to update gameplay to an expected state. + /// + [Serializable] + [MessagePackObject] + public abstract class MatchRulesetServerEvent + { + } +} diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index 299da2e06e..225d86ed9c 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -432,6 +432,11 @@ namespace osu.Game.Online.Multiplayer throw new NotImplementedException(); } + public Task MatchRulesetEvent(MatchRulesetServerEvent e) + { + throw new NotImplementedException(); + } + Task IMultiplayerClient.UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability) { if (Room == null) From 035dfd071fb720af2245e478ea1a7d2c8baef821 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 27 Jul 2021 18:55:04 +0900 Subject: [PATCH 06/21] Add missing nullable specifications --- osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs | 2 ++ osu.Game/Online/Multiplayer/MatchRulesetUserState.cs | 2 ++ .../Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs | 2 ++ .../Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs | 4 +++- .../Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs | 4 +++- .../Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs | 2 ++ 6 files changed, 14 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs index d8072efa2a..be8e54d341 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs @@ -4,6 +4,8 @@ using System; using MessagePack; +#nullable enable + namespace osu.Game.Online.Multiplayer { /// diff --git a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs index e8d9961dbd..6fa0024c3d 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs @@ -4,6 +4,8 @@ using System; using MessagePack; +#nullable enable + namespace osu.Game.Online.Multiplayer { /// diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs index 9dd01ea87c..5e1d489d39 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs @@ -3,6 +3,8 @@ using MessagePack; +#nullable enable + namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs { public class ChangeTeamRequest : MatchRulesetUserRequest diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs index 532111671e..f6bf893818 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs @@ -4,6 +4,8 @@ using System; using MessagePack; +#nullable enable + namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs { [Serializable] @@ -14,6 +16,6 @@ namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs public int ID { get; set; } [Key(1)] - public string Name { get; set; } + public string Name { get; set; } = string.Empty; } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs index 6383617100..57aae6e534 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs @@ -4,11 +4,13 @@ using System.Collections.Generic; using MessagePack; +#nullable enable + namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs { public class TeamVsMatchRoomState : MatchRulesetRoomState { [Key(0)] - public List Teams { get; set; } + public List Teams { get; set; } = new List(); } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs index b35cfd3cdd..0880787a5a 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs @@ -3,6 +3,8 @@ using MessagePack; +#nullable enable + namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs { public class TeamVsMatchUserState : MatchRulesetUserState From 867426441e98dbcd9a3af0cba8ec1545b1e00258 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Jul 2021 17:58:50 +0900 Subject: [PATCH 07/21] Fix weird access to room via `Client` --- .../OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs index baf9570209..2a40a61257 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/MultiplayerReadyButton.cs @@ -99,7 +99,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match break; } - bool enableButton = Client.Room?.State == MultiplayerRoomState.Open && !operationInProgress.Value; + bool enableButton = Room?.State == MultiplayerRoomState.Open && !operationInProgress.Value; // When the local user is the host and spectating the match, the "start match" state should be enabled if any users are ready. if (localUser?.State == MultiplayerUserState.Spectating) From 359eb9c4ec81d700d53ae156a81d02272acd0415 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Jul 2021 18:10:38 +0900 Subject: [PATCH 08/21] Add new event flow for match ruleset state handling I'm totally not happy with how this is done, but don't have the energy to rewrite everything just now. --- .../Online/Multiplayer/MultiplayerClient.cs | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index 225d86ed9c..deac736b80 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -424,17 +424,42 @@ namespace osu.Game.Online.Multiplayer Task IMultiplayerClient.MatchRulesetUserStateChanged(int userId, MatchRulesetUserState state) { - throw new NotImplementedException(); + if (Room == null) + return Task.CompletedTask; + + Scheduler.Add(() => + { + if (Room == null) + return; + + Room.Users.Single(u => u.UserID == userId).MatchRulesetState = state; + RoomUpdated?.Invoke(); + }, false); + + return Task.CompletedTask; } Task IMultiplayerClient.MatchRulesetRoomStateChanged(MatchRulesetRoomState state) { - throw new NotImplementedException(); + if (Room == null) + return Task.CompletedTask; + + Scheduler.Add(() => + { + if (Room == null) + return; + + Room.MatchRulesetState = state; + RoomUpdated?.Invoke(); + }); + + return Task.CompletedTask; } public Task MatchRulesetEvent(MatchRulesetServerEvent e) { - throw new NotImplementedException(); + // not used by any match rulesets just yet. + return Task.CompletedTask; } Task IMultiplayerClient.UserBeatmapAvailabilityChanged(int userId, BeatmapAvailability beatmapAvailability) From ce92a47ec689da8765d8b8d383ab8b94aef7d06c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Jul 2021 18:19:46 +0900 Subject: [PATCH 09/21] Add silly event handling hookups --- osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs index 88d8c04c98..8137430d8e 100644 --- a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs @@ -56,6 +56,8 @@ namespace osu.Game.Online.Multiplayer connection.On(nameof(IMultiplayerClient.ResultsReady), ((IMultiplayerClient)this).ResultsReady); connection.On>(nameof(IMultiplayerClient.UserModsChanged), ((IMultiplayerClient)this).UserModsChanged); connection.On(nameof(IMultiplayerClient.UserBeatmapAvailabilityChanged), ((IMultiplayerClient)this).UserBeatmapAvailabilityChanged); + connection.On(nameof(IMultiplayerClient.MatchRulesetRoomStateChanged), ((IMultiplayerClient)this).MatchRulesetRoomStateChanged); + connection.On(nameof(IMultiplayerClient.MatchRulesetUserStateChanged), ((IMultiplayerClient)this).MatchRulesetUserStateChanged); }; IsConnected.BindTo(connector.IsConnected); From 4cf2c6188d3ecfd8b4e44a601941215cc78d9f82 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 30 Jul 2021 19:37:47 +0900 Subject: [PATCH 10/21] Add union attributes for derived class deserialisation --- osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs | 4 +++- osu.Game/Online/Multiplayer/MatchRulesetUserState.cs | 4 +++- .../Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs index be8e54d341..773c9a55e8 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs @@ -3,6 +3,7 @@ using System; using MessagePack; +using osu.Game.Online.Multiplayer.MatchRulesets.TeamVs; #nullable enable @@ -14,7 +15,8 @@ namespace osu.Game.Online.Multiplayer /// [Serializable] [MessagePackObject] - public class MatchRulesetRoomState + [Union(0, typeof(TeamVsMatchRoomState))] + public abstract class MatchRulesetRoomState { } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs index 6fa0024c3d..36eae2447e 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs @@ -3,6 +3,7 @@ using System; using MessagePack; +using osu.Game.Online.Multiplayer.MatchRulesets.TeamVs; #nullable enable @@ -14,7 +15,8 @@ namespace osu.Game.Online.Multiplayer /// [Serializable] [MessagePackObject] - public class MatchRulesetUserState + [Union(0, typeof(TeamVsMatchUserState))] + public abstract class MatchRulesetUserState { } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs index 57aae6e534..338b9c965d 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs @@ -8,6 +8,7 @@ using MessagePack; namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs { + [MessagePackObject] public class TeamVsMatchRoomState : MatchRulesetRoomState { [Key(0)] From 1cd967b35129193c8adf37646118e854c375f8b5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Aug 2021 14:37:47 +0900 Subject: [PATCH 11/21] Add signalr json type handling specification --- osu.Game/Online/HubClientConnector.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/osu.Game/Online/HubClientConnector.cs b/osu.Game/Online/HubClientConnector.cs index 90049a6501..3876c8bbe6 100644 --- a/osu.Game/Online/HubClientConnector.cs +++ b/osu.Game/Online/HubClientConnector.cs @@ -150,7 +150,16 @@ namespace osu.Game.Online { // eventually we will precompile resolvers for messagepack, but this isn't working currently // see https://github.com/neuecc/MessagePack-CSharp/issues/780#issuecomment-768794308. - builder.AddNewtonsoftJsonProtocol(options => { options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }); + builder.AddNewtonsoftJsonProtocol(options => + { + options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; + options.PayloadSerializerSettings = new JsonSerializerSettings + { + // TODO: This should only be required to be `TypeNameHandling.Auto`. + // See usage in osu-server-spectator for further documentation as to why this is required. + TypeNameHandling = TypeNameHandling.All + }; + }); } var newConnection = builder.Build(); From 617ff40de763228ed652828d67a14cf462a7e000 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Aug 2021 14:44:51 +0900 Subject: [PATCH 12/21] Add the ability to not use MessagePack when creating a `HubConnector` --- osu.Game/Online/API/APIAccess.cs | 4 ++-- osu.Game/Online/API/DummyAPIAccess.cs | 2 +- osu.Game/Online/API/IAPIProvider.cs | 3 ++- osu.Game/Online/HubClientConnector.cs | 7 +++++-- osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs | 4 +++- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/osu.Game/Online/API/APIAccess.cs b/osu.Game/Online/API/APIAccess.cs index b35dfa11cb..f7a3f4602f 100644 --- a/osu.Game/Online/API/APIAccess.cs +++ b/osu.Game/Online/API/APIAccess.cs @@ -257,8 +257,8 @@ namespace osu.Game.Online.API this.password = password; } - public IHubClientConnector GetHubConnector(string clientName, string endpoint) => - new HubClientConnector(clientName, endpoint, this, versionHash); + public IHubClientConnector GetHubConnector(string clientName, string endpoint, bool preferMessagePack) => + new HubClientConnector(clientName, endpoint, this, versionHash, preferMessagePack); public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password) { diff --git a/osu.Game/Online/API/DummyAPIAccess.cs b/osu.Game/Online/API/DummyAPIAccess.cs index 52f2365165..1ba31db9fa 100644 --- a/osu.Game/Online/API/DummyAPIAccess.cs +++ b/osu.Game/Online/API/DummyAPIAccess.cs @@ -89,7 +89,7 @@ namespace osu.Game.Online.API state.Value = APIState.Offline; } - public IHubClientConnector GetHubConnector(string clientName, string endpoint) => null; + public IHubClientConnector GetHubConnector(string clientName, string endpoint, bool preferMessagePack) => null; public RegistrationRequest.RegistrationRequestErrors CreateAccount(string email, string username, string password) { diff --git a/osu.Game/Online/API/IAPIProvider.cs b/osu.Game/Online/API/IAPIProvider.cs index 3a77b9cfee..686df5c57c 100644 --- a/osu.Game/Online/API/IAPIProvider.cs +++ b/osu.Game/Online/API/IAPIProvider.cs @@ -102,7 +102,8 @@ namespace osu.Game.Online.API /// /// The name of the client this connector connects for, used for logging. /// The endpoint to the hub. - IHubClientConnector? GetHubConnector(string clientName, string endpoint); + /// + IHubClientConnector? GetHubConnector(string clientName, string endpoint, bool preferMessagePack = true); /// /// Create a new user account. This is a blocking operation. diff --git a/osu.Game/Online/HubClientConnector.cs b/osu.Game/Online/HubClientConnector.cs index 3876c8bbe6..6c6a217f54 100644 --- a/osu.Game/Online/HubClientConnector.cs +++ b/osu.Game/Online/HubClientConnector.cs @@ -26,6 +26,7 @@ namespace osu.Game.Online private readonly string clientName; private readonly string endpoint; private readonly string versionHash; + private readonly bool preferMessagePack; private readonly IAPIProvider api; /// @@ -51,12 +52,14 @@ namespace osu.Game.Online /// The endpoint to the hub. /// An API provider used to react to connection state changes. /// The hash representing the current game version, used for verification purposes. - public HubClientConnector(string clientName, string endpoint, IAPIProvider api, string versionHash) + /// Whether to use MessagePack for serialisation if available on this platform. + public HubClientConnector(string clientName, string endpoint, IAPIProvider api, string versionHash, bool preferMessagePack = true) { this.clientName = clientName; this.endpoint = endpoint; this.api = api; this.versionHash = versionHash; + this.preferMessagePack = preferMessagePack; apiState.BindTo(api.State); apiState.BindValueChanged(state => @@ -144,7 +147,7 @@ namespace osu.Game.Online options.Headers.Add("OsuVersionHash", versionHash); }); - if (RuntimeInfo.SupportsJIT) + if (RuntimeInfo.SupportsJIT && preferMessagePack) builder.AddMessagePackProtocol(); else { diff --git a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs index 8137430d8e..1dfc60312b 100644 --- a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs @@ -37,7 +37,9 @@ namespace osu.Game.Online.Multiplayer [BackgroundDependencyLoader] private void load(IAPIProvider api) { - connector = api.GetHubConnector(nameof(OnlineMultiplayerClient), endpoint); + // Importantly, we are intentionally not using MessagePack here to correctly support derived class serialization. + // More information on the limitations / reasoning can be found in osu-server-spectator's initialisation code. + connector = api.GetHubConnector(nameof(OnlineMultiplayerClient), endpoint, false); if (connector != null) { From c7274355a4ca9cfccbf2d2bd493efb5bc4bf4bbf Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Aug 2021 17:05:05 +0900 Subject: [PATCH 13/21] Remove `abstract` definitions from multiplayer states for now --- osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs | 2 +- osu.Game/Online/Multiplayer/MatchRulesetUserState.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs index 773c9a55e8..105bb1c281 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs @@ -16,7 +16,7 @@ namespace osu.Game.Online.Multiplayer [Serializable] [MessagePackObject] [Union(0, typeof(TeamVsMatchRoomState))] - public abstract class MatchRulesetRoomState + public class MatchRulesetRoomState // TODO: this will need to be abstract or interface when/if we get messagepack working. for now it isn't as it breaks json serialisation. { } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs index 36eae2447e..aa34cdab41 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs @@ -16,7 +16,7 @@ namespace osu.Game.Online.Multiplayer [Serializable] [MessagePackObject] [Union(0, typeof(TeamVsMatchUserState))] - public abstract class MatchRulesetUserState + public class MatchRulesetUserState // TODO: this will need to be abstract or interface when/if we get messagepack working. for now it isn't as it breaks json serialisation. { } } From d93421b9b895a138870bc50bd14cd33df175ebf4 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Aug 2021 17:06:55 +0900 Subject: [PATCH 14/21] Expose a default `TeamVs` room state so it can be consumed by tests --- .../MatchRulesets/TeamVs/TeamVsMatchRoomState.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs index 338b9c965d..92f67e99bd 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs @@ -13,5 +13,15 @@ namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs { [Key(0)] public List Teams { get; set; } = new List(); + + public static TeamVsMatchRoomState CreateDefault() => + new TeamVsMatchRoomState + { + Teams = + { + new MultiplayerTeam { ID = 0, Name = "Team Red" }, + new MultiplayerTeam { ID = 1, Name = "Team Blue" }, + } + }; } } From 556962a3d881fe7a4f50ef8092432af19303521b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 3 Aug 2021 14:50:56 +0900 Subject: [PATCH 15/21] Add missing xmldoc comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bartłomiej Dach --- osu.Game/Online/API/IAPIProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/API/IAPIProvider.cs b/osu.Game/Online/API/IAPIProvider.cs index 686df5c57c..5ad5367924 100644 --- a/osu.Game/Online/API/IAPIProvider.cs +++ b/osu.Game/Online/API/IAPIProvider.cs @@ -102,7 +102,7 @@ namespace osu.Game.Online.API /// /// The name of the client this connector connects for, used for logging. /// The endpoint to the hub. - /// + /// Whether to use MessagePack for serialisation if available on this platform. IHubClientConnector? GetHubConnector(string clientName, string endpoint, bool preferMessagePack = true); /// From 5ac3abac99befc092b6e92d5489b7b8dfc4e0759 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 3 Aug 2021 14:53:04 +0900 Subject: [PATCH 16/21] Add missing `forceScheduled` parameter --- osu.Game/Online/Multiplayer/MultiplayerClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index deac736b80..5220db16b5 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -451,7 +451,7 @@ namespace osu.Game.Online.Multiplayer Room.MatchRulesetState = state; RoomUpdated?.Invoke(); - }); + }, false); return Task.CompletedTask; } From ee102e3755b0a15d7fd6af3be1e9de2b3beb09a6 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 3 Aug 2021 14:55:20 +0900 Subject: [PATCH 17/21] Fix incorrectly overwritten `ReferenceLoopHandling` setting --- osu.Game/Online/HubClientConnector.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/osu.Game/Online/HubClientConnector.cs b/osu.Game/Online/HubClientConnector.cs index 6c6a217f54..d2dba8a402 100644 --- a/osu.Game/Online/HubClientConnector.cs +++ b/osu.Game/Online/HubClientConnector.cs @@ -156,12 +156,9 @@ namespace osu.Game.Online builder.AddNewtonsoftJsonProtocol(options => { options.PayloadSerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; - options.PayloadSerializerSettings = new JsonSerializerSettings - { - // TODO: This should only be required to be `TypeNameHandling.Auto`. - // See usage in osu-server-spectator for further documentation as to why this is required. - TypeNameHandling = TypeNameHandling.All - }; + // TODO: This should only be required to be `TypeNameHandling.Auto`. + // See usage in osu-server-spectator for further documentation as to why this is required. + options.PayloadSerializerSettings.TypeNameHandling = TypeNameHandling.All; }); } From 66427127f0f48bcbce56a4b8fb4eee40e2775128 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 3 Aug 2021 15:09:03 +0900 Subject: [PATCH 18/21] Update naming in line with discussion --- osu.Game/Online/Multiplayer/MatchRulesetType.cs | 11 ----------- .../Online/Multiplayer/MultiplayerRoomSettings.cs | 3 ++- osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs | 6 +++--- 3 files changed, 5 insertions(+), 15 deletions(-) delete mode 100644 osu.Game/Online/Multiplayer/MatchRulesetType.cs diff --git a/osu.Game/Online/Multiplayer/MatchRulesetType.cs b/osu.Game/Online/Multiplayer/MatchRulesetType.cs deleted file mode 100644 index b87a8eb174..0000000000 --- a/osu.Game/Online/Multiplayer/MatchRulesetType.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -namespace osu.Game.Online.Multiplayer -{ - public enum MatchRulesetType - { - HeadToHead, - TeamVs - } -} diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs b/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs index 2c49e3b251..f76ab5da89 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using System.Linq; using MessagePack; using osu.Game.Online.API; +using osu.Game.Online.Rooms; namespace osu.Game.Online.Multiplayer { @@ -40,7 +41,7 @@ namespace osu.Game.Online.Multiplayer public string Password { get; set; } = string.Empty; [Key(8)] - public MatchRulesetType MatchRulesetType { get; set; } + public MatchType MatchRulesetType { get; set; } public bool Equals(MultiplayerRoomSettings other) => BeatmapID == other.BeatmapID diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs b/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs index d97d49aa8a..96e9a7fd4a 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs @@ -24,6 +24,9 @@ namespace osu.Game.Online.Multiplayer [Key(1)] public MultiplayerUserState State { get; set; } = MultiplayerUserState.Idle; + [Key(4)] + public MatchRulesetUserState? MatchRulesetState { get; set; } + /// /// The availability state of the current beatmap. /// @@ -36,9 +39,6 @@ namespace osu.Game.Online.Multiplayer [Key(3)] public IEnumerable Mods { get; set; } = Enumerable.Empty(); - [Key(4)] - public MatchRulesetUserState? MatchRulesetState { get; set; } - [IgnoreMember] public User? User { get; set; } From 70da58323a3781cd83fb8f462351ce8026523d6c Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 3 Aug 2021 15:43:04 +0900 Subject: [PATCH 19/21] Drop `MatchRuleset` terminology completely --- osu.Game/Online/Multiplayer/IMultiplayerClient.cs | 12 ++++++------ .../Online/Multiplayer/IMultiplayerRoomServer.cs | 4 ++-- ...{MatchRulesetRoomState.cs => MatchRoomState.cs} | 9 +++++---- ...chRulesetServerEvent.cs => MatchServerEvent.cs} | 2 +- .../TeamVersus}/ChangeTeamRequest.cs | 4 ++-- .../TeamVersus}/MultiplayerTeam.cs | 2 +- .../TeamVersus/TeamVersusRoomState.cs} | 8 ++++---- .../TeamVersus/TeamVersusUserState.cs} | 4 ++-- ...chRulesetUserRequest.cs => MatchUserRequest.cs} | 4 ++-- ...{MatchRulesetUserState.cs => MatchUserState.cs} | 9 +++++---- osu.Game/Online/Multiplayer/MultiplayerClient.cs | 14 +++++++------- osu.Game/Online/Multiplayer/MultiplayerRoom.cs | 2 +- .../Online/Multiplayer/MultiplayerRoomSettings.cs | 6 +++--- osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs | 2 +- .../Online/Multiplayer/OnlineMultiplayerClient.cs | 8 ++++---- .../Visual/Multiplayer/TestMultiplayerClient.cs | 2 +- 16 files changed, 47 insertions(+), 45 deletions(-) rename osu.Game/Online/Multiplayer/{MatchRulesetRoomState.cs => MatchRoomState.cs} (56%) rename osu.Game/Online/Multiplayer/{MatchRulesetServerEvent.cs => MatchServerEvent.cs} (89%) rename osu.Game/Online/Multiplayer/{MatchRulesets/TeamVs => MatchTypes/TeamVersus}/ChangeTeamRequest.cs (68%) rename osu.Game/Online/Multiplayer/{MatchRulesets/TeamVs => MatchTypes/TeamVersus}/MultiplayerTeam.cs (87%) rename osu.Game/Online/Multiplayer/{MatchRulesets/TeamVs/TeamVsMatchRoomState.cs => MatchTypes/TeamVersus/TeamVersusRoomState.cs} (73%) rename osu.Game/Online/Multiplayer/{MatchRulesets/TeamVs/TeamVsMatchUserState.cs => MatchTypes/TeamVersus/TeamVersusUserState.cs} (68%) rename osu.Game/Online/Multiplayer/{MatchRulesetUserRequest.cs => MatchUserRequest.cs} (83%) rename osu.Game/Online/Multiplayer/{MatchRulesetUserState.cs => MatchUserState.cs} (56%) diff --git a/osu.Game/Online/Multiplayer/IMultiplayerClient.cs b/osu.Game/Online/Multiplayer/IMultiplayerClient.cs index 839ec9bd1f..064065ab00 100644 --- a/osu.Game/Online/Multiplayer/IMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/IMultiplayerClient.cs @@ -51,23 +51,23 @@ namespace osu.Game.Online.Multiplayer Task UserStateChanged(int userId, MultiplayerUserState state); /// - /// Signals that the match ruleset state has changed for a user in this room. + /// Signals that the match type state has changed for a user in this room. /// /// The ID of the user performing a state change. /// The new state of the user. - Task MatchRulesetUserStateChanged(int userId, MatchRulesetUserState state); + Task MatchUserStateChanged(int userId, MatchUserState state); /// - /// Signals that the match ruleset state has changed for this room. + /// Signals that the match type state has changed for this room. /// /// The new state of the room. - Task MatchRulesetRoomStateChanged(MatchRulesetRoomState state); + Task MatchRoomStateChanged(MatchRoomState state); /// - /// Send a match ruleset specific request. + /// Send a match type specific request. /// /// The event to handle. - Task MatchRulesetEvent(MatchRulesetServerEvent e); + Task MatchEvent(MatchServerEvent e); /// /// Signals that a user in this room changed their beatmap availability state. diff --git a/osu.Game/Online/Multiplayer/IMultiplayerRoomServer.cs b/osu.Game/Online/Multiplayer/IMultiplayerRoomServer.cs index 20c9f9e216..b26c4d8201 100644 --- a/osu.Game/Online/Multiplayer/IMultiplayerRoomServer.cs +++ b/osu.Game/Online/Multiplayer/IMultiplayerRoomServer.cs @@ -56,10 +56,10 @@ namespace osu.Game.Online.Multiplayer Task ChangeUserMods(IEnumerable newMods); /// - /// Send a match ruleset specific request. + /// Send a match type specific request. /// /// The request to send. - Task SendMatchRulesetRequest(MatchRulesetUserRequest request); + Task SendMatchRequest(MatchUserRequest request); /// /// As the host of a room, start the match. diff --git a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs b/osu.Game/Online/Multiplayer/MatchRoomState.cs similarity index 56% rename from osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs rename to osu.Game/Online/Multiplayer/MatchRoomState.cs index 105bb1c281..5b662af100 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchRoomState.cs @@ -3,20 +3,21 @@ using System; using MessagePack; -using osu.Game.Online.Multiplayer.MatchRulesets.TeamVs; +using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus; #nullable enable namespace osu.Game.Online.Multiplayer { /// - /// Room-wide state for the current match ruleset. + /// Room-wide state for the current match type. /// Can be used to contain any state which should be used before or during match gameplay. /// [Serializable] [MessagePackObject] - [Union(0, typeof(TeamVsMatchRoomState))] - public class MatchRulesetRoomState // TODO: this will need to be abstract or interface when/if we get messagepack working. for now it isn't as it breaks json serialisation. + [Union(0, typeof(TeamVersusRoomState))] + // TODO: this will need to be abstract or interface when/if we get messagepack working. for now it isn't as it breaks json serialisation. + public class MatchRoomState { } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesetServerEvent.cs b/osu.Game/Online/Multiplayer/MatchServerEvent.cs similarity index 89% rename from osu.Game/Online/Multiplayer/MatchRulesetServerEvent.cs rename to osu.Game/Online/Multiplayer/MatchServerEvent.cs index c45615e914..891fb2cc3b 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetServerEvent.cs +++ b/osu.Game/Online/Multiplayer/MatchServerEvent.cs @@ -11,7 +11,7 @@ namespace osu.Game.Online.Multiplayer /// [Serializable] [MessagePackObject] - public abstract class MatchRulesetServerEvent + public abstract class MatchServerEvent { } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/ChangeTeamRequest.cs similarity index 68% rename from osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs rename to osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/ChangeTeamRequest.cs index 5e1d489d39..9c3b07049c 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/ChangeTeamRequest.cs +++ b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/ChangeTeamRequest.cs @@ -5,9 +5,9 @@ using MessagePack; #nullable enable -namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs +namespace osu.Game.Online.Multiplayer.MatchTypes.TeamVersus { - public class ChangeTeamRequest : MatchRulesetUserRequest + public class ChangeTeamRequest : MatchUserRequest { [Key(0)] public int TeamID { get; set; } diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/MultiplayerTeam.cs similarity index 87% rename from osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs rename to osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/MultiplayerTeam.cs index f6bf893818..f952dbc1b5 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/MultiplayerTeam.cs +++ b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/MultiplayerTeam.cs @@ -6,7 +6,7 @@ using MessagePack; #nullable enable -namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs +namespace osu.Game.Online.Multiplayer.MatchTypes.TeamVersus { [Serializable] [MessagePackObject] diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusRoomState.cs similarity index 73% rename from osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs rename to osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusRoomState.cs index 92f67e99bd..91d1aa43d4 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchRoomState.cs +++ b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusRoomState.cs @@ -6,16 +6,16 @@ using MessagePack; #nullable enable -namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs +namespace osu.Game.Online.Multiplayer.MatchTypes.TeamVersus { [MessagePackObject] - public class TeamVsMatchRoomState : MatchRulesetRoomState + public class TeamVersusRoomState : MatchRoomState { [Key(0)] public List Teams { get; set; } = new List(); - public static TeamVsMatchRoomState CreateDefault() => - new TeamVsMatchRoomState + public static TeamVersusRoomState CreateDefault() => + new TeamVersusRoomState { Teams = { diff --git a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusUserState.cs similarity index 68% rename from osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs rename to osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusUserState.cs index 0880787a5a..96a4e2ea99 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesets/TeamVs/TeamVsMatchUserState.cs +++ b/osu.Game/Online/Multiplayer/MatchTypes/TeamVersus/TeamVersusUserState.cs @@ -5,9 +5,9 @@ using MessagePack; #nullable enable -namespace osu.Game.Online.Multiplayer.MatchRulesets.TeamVs +namespace osu.Game.Online.Multiplayer.MatchTypes.TeamVersus { - public class TeamVsMatchUserState : MatchRulesetUserState + public class TeamVersusUserState : MatchUserState { [Key(0)] public int TeamID { get; set; } diff --git a/osu.Game/Online/Multiplayer/MatchRulesetUserRequest.cs b/osu.Game/Online/Multiplayer/MatchUserRequest.cs similarity index 83% rename from osu.Game/Online/Multiplayer/MatchRulesetUserRequest.cs rename to osu.Game/Online/Multiplayer/MatchUserRequest.cs index 3cc430a2b7..15c3ad0776 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetUserRequest.cs +++ b/osu.Game/Online/Multiplayer/MatchUserRequest.cs @@ -7,11 +7,11 @@ using MessagePack; namespace osu.Game.Online.Multiplayer { /// - /// A request from a user to perform an action specific to the current match ruleset. + /// A request from a user to perform an action specific to the current match type. /// [Serializable] [MessagePackObject] - public abstract class MatchRulesetUserRequest + public abstract class MatchUserRequest { } } diff --git a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs b/osu.Game/Online/Multiplayer/MatchUserState.cs similarity index 56% rename from osu.Game/Online/Multiplayer/MatchRulesetUserState.cs rename to osu.Game/Online/Multiplayer/MatchUserState.cs index aa34cdab41..f457191bb5 100644 --- a/osu.Game/Online/Multiplayer/MatchRulesetUserState.cs +++ b/osu.Game/Online/Multiplayer/MatchUserState.cs @@ -3,20 +3,21 @@ using System; using MessagePack; -using osu.Game.Online.Multiplayer.MatchRulesets.TeamVs; +using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus; #nullable enable namespace osu.Game.Online.Multiplayer { /// - /// User specific state for the current match ruleset. + /// User specific state for the current match type. /// Can be used to contain any state which should be used before or during match gameplay. /// [Serializable] [MessagePackObject] - [Union(0, typeof(TeamVsMatchUserState))] - public class MatchRulesetUserState // TODO: this will need to be abstract or interface when/if we get messagepack working. for now it isn't as it breaks json serialisation. + [Union(0, typeof(TeamVersusUserState))] + // TODO: this will need to be abstract or interface when/if we get messagepack working. for now it isn't as it breaks json serialisation. + public class MatchUserState { } } diff --git a/osu.Game/Online/Multiplayer/MultiplayerClient.cs b/osu.Game/Online/Multiplayer/MultiplayerClient.cs index 5220db16b5..873be7f49c 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerClient.cs @@ -293,7 +293,7 @@ namespace osu.Game.Online.Multiplayer public abstract Task ChangeUserMods(IEnumerable newMods); - public abstract Task SendMatchRulesetRequest(MatchRulesetUserRequest request); + public abstract Task SendMatchRequest(MatchUserRequest request); public abstract Task StartMatch(); @@ -422,7 +422,7 @@ namespace osu.Game.Online.Multiplayer return Task.CompletedTask; } - Task IMultiplayerClient.MatchRulesetUserStateChanged(int userId, MatchRulesetUserState state) + Task IMultiplayerClient.MatchUserStateChanged(int userId, MatchUserState state) { if (Room == null) return Task.CompletedTask; @@ -432,14 +432,14 @@ namespace osu.Game.Online.Multiplayer if (Room == null) return; - Room.Users.Single(u => u.UserID == userId).MatchRulesetState = state; + Room.Users.Single(u => u.UserID == userId).MatchState = state; RoomUpdated?.Invoke(); }, false); return Task.CompletedTask; } - Task IMultiplayerClient.MatchRulesetRoomStateChanged(MatchRulesetRoomState state) + Task IMultiplayerClient.MatchRoomStateChanged(MatchRoomState state) { if (Room == null) return Task.CompletedTask; @@ -449,16 +449,16 @@ namespace osu.Game.Online.Multiplayer if (Room == null) return; - Room.MatchRulesetState = state; + Room.MatchState = state; RoomUpdated?.Invoke(); }, false); return Task.CompletedTask; } - public Task MatchRulesetEvent(MatchRulesetServerEvent e) + public Task MatchEvent(MatchServerEvent e) { - // not used by any match rulesets just yet. + // not used by any match types just yet. return Task.CompletedTask; } diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs b/osu.Game/Online/Multiplayer/MultiplayerRoom.cs index 07d87fafc3..175c0e0e27 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoom.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoom.cs @@ -48,7 +48,7 @@ namespace osu.Game.Online.Multiplayer public MultiplayerRoomUser? Host { get; set; } [Key(5)] - public MatchRulesetRoomState? MatchRulesetState { get; set; } + public MatchRoomState? MatchState { get; set; } [JsonConstructor] [SerializationConstructor] diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs b/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs index f76ab5da89..706bc750d3 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoomSettings.cs @@ -41,7 +41,7 @@ namespace osu.Game.Online.Multiplayer public string Password { get; set; } = string.Empty; [Key(8)] - public MatchType MatchRulesetType { get; set; } + public MatchType MatchType { get; set; } public bool Equals(MultiplayerRoomSettings other) => BeatmapID == other.BeatmapID @@ -52,7 +52,7 @@ namespace osu.Game.Online.Multiplayer && Password.Equals(other.Password, StringComparison.Ordinal) && Name.Equals(other.Name, StringComparison.Ordinal) && PlaylistItemId == other.PlaylistItemId - && MatchRulesetType == other.MatchRulesetType; + && MatchType == other.MatchType; public override string ToString() => $"Name:{Name}" + $" Beatmap:{BeatmapID} ({BeatmapChecksum})" @@ -60,7 +60,7 @@ namespace osu.Game.Online.Multiplayer + $" AllowedMods:{string.Join(',', AllowedMods)}" + $" Password:{(string.IsNullOrEmpty(Password) ? "no" : "yes")}" + $" Ruleset:{RulesetID}" - + $" MatchRuleset:{MatchRulesetType}" + + $" Type:{MatchType}" + $" Item:{PlaylistItemId}"; } } diff --git a/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs b/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs index 96e9a7fd4a..5d11e2921a 100644 --- a/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs +++ b/osu.Game/Online/Multiplayer/MultiplayerRoomUser.cs @@ -25,7 +25,7 @@ namespace osu.Game.Online.Multiplayer public MultiplayerUserState State { get; set; } = MultiplayerUserState.Idle; [Key(4)] - public MatchRulesetUserState? MatchRulesetState { get; set; } + public MatchUserState? MatchState { get; set; } /// /// The availability state of the current beatmap. diff --git a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs index 1dfc60312b..00f30463a5 100644 --- a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs @@ -58,8 +58,8 @@ namespace osu.Game.Online.Multiplayer connection.On(nameof(IMultiplayerClient.ResultsReady), ((IMultiplayerClient)this).ResultsReady); connection.On>(nameof(IMultiplayerClient.UserModsChanged), ((IMultiplayerClient)this).UserModsChanged); connection.On(nameof(IMultiplayerClient.UserBeatmapAvailabilityChanged), ((IMultiplayerClient)this).UserBeatmapAvailabilityChanged); - connection.On(nameof(IMultiplayerClient.MatchRulesetRoomStateChanged), ((IMultiplayerClient)this).MatchRulesetRoomStateChanged); - connection.On(nameof(IMultiplayerClient.MatchRulesetUserStateChanged), ((IMultiplayerClient)this).MatchRulesetUserStateChanged); + connection.On(nameof(IMultiplayerClient.MatchRoomStateChanged), ((IMultiplayerClient)this).MatchRoomStateChanged); + connection.On(nameof(IMultiplayerClient.MatchUserStateChanged), ((IMultiplayerClient)this).MatchUserStateChanged); }; IsConnected.BindTo(connector.IsConnected); @@ -122,12 +122,12 @@ namespace osu.Game.Online.Multiplayer return connection.InvokeAsync(nameof(IMultiplayerServer.ChangeUserMods), newMods); } - public override Task SendMatchRulesetRequest(MatchRulesetUserRequest request) + public override Task SendMatchRequest(MatchUserRequest request) { if (!IsConnected.Value) return Task.CompletedTask; - return connection.InvokeAsync(nameof(IMultiplayerServer.SendMatchRulesetRequest), request); + return connection.InvokeAsync(nameof(IMultiplayerServer.SendMatchRequest), request); } public override Task StartMatch() diff --git a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs index 6a8bf87ff0..7deecdfa28 100644 --- a/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs +++ b/osu.Game/Tests/Visual/Multiplayer/TestMultiplayerClient.cs @@ -192,7 +192,7 @@ namespace osu.Game.Tests.Visual.Multiplayer return Task.CompletedTask; } - public override Task SendMatchRulesetRequest(MatchRulesetUserRequest request) => Task.CompletedTask; + public override Task SendMatchRequest(MatchUserRequest request) => Task.CompletedTask; public override Task StartMatch() { From e11b815b82171be2eb98bdac91564154c7f0f13f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 3 Aug 2021 23:08:11 +0900 Subject: [PATCH 20/21] Serialise `type` as snake_case --- osu.Game/Online/Rooms/MatchType.cs | 2 ++ osu.Game/Online/Rooms/Room.cs | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/osu.Game/Online/Rooms/MatchType.cs b/osu.Game/Online/Rooms/MatchType.cs index cafa147a61..36f0dc0c81 100644 --- a/osu.Game/Online/Rooms/MatchType.cs +++ b/osu.Game/Online/Rooms/MatchType.cs @@ -7,6 +7,8 @@ namespace osu.Game.Online.Rooms { public enum MatchType { + // used for osu-web deserialization so names shouldn't be changed. + Playlists, [Description("Head to head")] diff --git a/osu.Game/Online/Rooms/Room.cs b/osu.Game/Online/Rooms/Room.cs index fe7455d964..4bd5b1a788 100644 --- a/osu.Game/Online/Rooms/Room.cs +++ b/osu.Game/Online/Rooms/Room.cs @@ -64,6 +64,15 @@ namespace osu.Game.Online.Rooms [JsonIgnore] public readonly Bindable Type = new Bindable(); + // Todo: osu-framework bug (https://github.com/ppy/osu-framework/issues/4106) + [JsonConverter(typeof(SnakeCaseStringEnumConverter))] + [JsonProperty("type")] + private MatchType type + { + get => Type.Value; + set => Type.Value = value; + } + [Cached] [JsonIgnore] public readonly Bindable MaxParticipants = new Bindable(); From 401835a3d892ec1287183863ce42370a2afcda9b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 4 Aug 2021 13:13:47 +0900 Subject: [PATCH 21/21] Add missing event glue --- osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs index 00f30463a5..8b8d10ce4f 100644 --- a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs @@ -60,6 +60,7 @@ namespace osu.Game.Online.Multiplayer connection.On(nameof(IMultiplayerClient.UserBeatmapAvailabilityChanged), ((IMultiplayerClient)this).UserBeatmapAvailabilityChanged); connection.On(nameof(IMultiplayerClient.MatchRoomStateChanged), ((IMultiplayerClient)this).MatchRoomStateChanged); connection.On(nameof(IMultiplayerClient.MatchUserStateChanged), ((IMultiplayerClient)this).MatchUserStateChanged); + connection.On(nameof(IMultiplayerClient.MatchEvent), ((IMultiplayerClient)this).MatchEvent); }; IsConnected.BindTo(connector.IsConnected);