diff --git a/src/MHServerEmu.Core/Network/GameServiceProtocol.cs b/src/MHServerEmu.Core/Network/GameServiceProtocol.cs index bf127589..ce727dd2 100644 --- a/src/MHServerEmu.Core/Network/GameServiceProtocol.cs +++ b/src/MHServerEmu.Core/Network/GameServiceProtocol.cs @@ -461,7 +461,7 @@ namespace MHServerEmu.Core.Network /// /// [Game -> PlayerManager] Relays a match region request command from a client. /// - public readonly struct MatchRegionRequestQueueCommand(ulong playerDbId, ulong regionProtoId, ulong difficultyTierProtoId, ulong metaStateProtoId, RegionRequestQueueCommandVar command, ulong regionRequestGroupId, ulong targetPlayerDbId) + public readonly struct MatchRegionRequestQueueCommand(ulong playerDbId, ulong regionProtoId, ulong difficultyTierProtoId, ulong metaStateProtoId, RegionRequestQueueCommandVar command, ulong regionRequestGroupId, ulong targetPlayerDbId, int teamSizeOverride) : IGameServiceMessage { public readonly ulong PlayerDbId = playerDbId; @@ -471,6 +471,7 @@ namespace MHServerEmu.Core.Network public readonly RegionRequestQueueCommandVar Command = command; public readonly ulong RegionRequestGroupId = regionRequestGroupId; public readonly ulong TargetPlayerDbId = targetPlayerDbId; + public readonly int TeamSizeOverride = teamSizeOverride; } // MatchQueueUpdate is based on PlayerMgrToGameServer.proto from 1.53 diff --git a/src/MHServerEmu.Games/Entities/Player.cs b/src/MHServerEmu.Games/Entities/Player.cs index f31a5f1a..70e794c5 100644 --- a/src/MHServerEmu.Games/Entities/Player.cs +++ b/src/MHServerEmu.Games/Entities/Player.cs @@ -2872,7 +2872,7 @@ namespace MHServerEmu.Games.Entities } public bool SendRegionRequestQueueCommandToPlayerManager(PrototypeId regionRef, PrototypeId difficultyTierRef, - RegionRequestQueueCommandVar command, ulong groupId = 0, ulong targetPlayerDbId = 0) + RegionRequestQueueCommandVar command, ulong groupId = 0, ulong targetPlayerDbId = 0, int teamSizeOverride = -1) { ulong playerDbId = DatabaseUniqueId; ulong regionProtoId = (ulong)regionRef; @@ -2904,7 +2904,7 @@ namespace MHServerEmu.Games.Entities break; } - ServiceMessage.MatchRegionRequestQueueCommand message = new(playerDbId, regionProtoId, difficultyTierProtoId, metaStateProtoId, command, groupId, targetPlayerDbId); + ServiceMessage.MatchRegionRequestQueueCommand message = new(playerDbId, regionProtoId, difficultyTierProtoId, metaStateProtoId, command, groupId, targetPlayerDbId, teamSizeOverride); ServerManager.Instance.SendMessageToService(GameServiceType.PlayerManager, message); return true; diff --git a/src/MHServerEmu.Games/Regions/MatchQueues/MatchQueueStatus.cs b/src/MHServerEmu.Games/Regions/MatchQueues/MatchQueueStatus.cs index 57d830d5..16caecad 100644 --- a/src/MHServerEmu.Games/Regions/MatchQueues/MatchQueueStatus.cs +++ b/src/MHServerEmu.Games/Regions/MatchQueues/MatchQueueStatus.cs @@ -214,7 +214,7 @@ namespace MHServerEmu.Games.Regions.MatchQueues /// Handles a request from a client. /// public bool TryRegionRequestCommand(PrototypeId regionRef, PrototypeId difficultyTierRef, - ulong groupId, RegionRequestQueueCommandVar command) + ulong groupId, RegionRequestQueueCommandVar command, int teamSizeOverride = -1) { if (regionRef == PrototypeId.Invalid) return Logger.WarnReturn(false, "TryRegionRequestCommand(): regionRef == PrototypeId.Invalid"); @@ -272,7 +272,7 @@ namespace MHServerEmu.Games.Regions.MatchQueues if (command == RegionRequestQueueCommandVar.eRRQC_AddToQueueBypass && regionProto.AllowsQueueBypass == false) return false; - _owner.SendRegionRequestQueueCommandToPlayerManager(regionRef, difficultyTierRef, command, groupId); + _owner.SendRegionRequestQueueCommandToPlayerManager(regionRef, difficultyTierRef, command, groupId, 0, teamSizeOverride); return true; } diff --git a/src/MHServerEmu.PlayerManagement/Matchmaking/Match.cs b/src/MHServerEmu.PlayerManagement/Matchmaking/Match.cs index c8841e72..fbe32b28 100644 --- a/src/MHServerEmu.PlayerManagement/Matchmaking/Match.cs +++ b/src/MHServerEmu.PlayerManagement/Matchmaking/Match.cs @@ -28,16 +28,12 @@ namespace MHServerEmu.PlayerManagement.Matchmaking int[] teamLimits = Queue.Prototype.TeamLimits; - if (queueParams.TeamSizeOverride > 0) - { - _teams.Add(new MatchTeam(0, queueParams.TeamSizeOverride)); - _teams.Add(new MatchTeam(1, queueParams.TeamSizeOverride)); - } - else if (teamLimits.HasValue()) + if (teamLimits.HasValue()) { for (int i = 0; i < teamLimits.Length; i++) { - MatchTeam team = new(i, teamLimits[i]); + int teamLimit = (queueParams.TeamSizeOverride > 0) ? queueParams.TeamSizeOverride : teamLimits[i]; + MatchTeam team = new(i, teamLimit); _teams.Add(team); } } @@ -103,11 +99,6 @@ namespace MHServerEmu.PlayerManagement.Matchmaking return true; } - public bool IsCompatibleWith(in RegionRequestQueueParams queueParams) - { - return QueueParams.TeamSizeOverride == queueParams.TeamSizeOverride; - } - public bool IsReady() { if (IsFull() == false && IsBypass == false && Queue.Prototype.QueueDoNotWaitToFull == false) diff --git a/src/MHServerEmu.PlayerManagement/Matchmaking/RegionRequestQueue.cs b/src/MHServerEmu.PlayerManagement/Matchmaking/RegionRequestQueue.cs index 58729d24..35b458e5 100644 --- a/src/MHServerEmu.PlayerManagement/Matchmaking/RegionRequestQueue.cs +++ b/src/MHServerEmu.PlayerManagement/Matchmaking/RegionRequestQueue.cs @@ -45,7 +45,7 @@ namespace MHServerEmu.PlayerManagement.Matchmaking foreach (Match match in _matches) { - if (match.IsLookingForMore() && match.IsCompatibleWith(queueParams)) + if (match.IsLookingForMore()) lfmMatches.Add(match); } diff --git a/src/MHServerEmu.PlayerManagement/Network/PlayerManagerServiceMailbox.cs b/src/MHServerEmu.PlayerManagement/Network/PlayerManagerServiceMailbox.cs index 7abfbaed..25754e66 100644 --- a/src/MHServerEmu.PlayerManagement/Network/PlayerManagerServiceMailbox.cs +++ b/src/MHServerEmu.PlayerManagement/Network/PlayerManagerServiceMailbox.cs @@ -429,9 +429,10 @@ namespace MHServerEmu.PlayerManagement.Network RegionRequestQueueCommandVar command = matchRegionRequestQueueCommand.Command; ulong regionRequestGroupId = matchRegionRequestQueueCommand.RegionRequestGroupId; ulong targetPlayerDbId = matchRegionRequestQueueCommand.TargetPlayerDbId; + int teamSizeOverride = matchRegionRequestQueueCommand.TeamSizeOverride; PlayerHandle player = _playerManager.ClientManager.GetPlayer(playerDbId); - player?.ReceiveRegionRequestQueueCommand(regionRef, difficultyTierRef, metaStateRef, command, regionRequestGroupId, targetPlayerDbId); + player?.ReceiveRegionRequestQueueCommand(regionRef, difficultyTierRef, metaStateRef, command, regionRequestGroupId, targetPlayerDbId, teamSizeOverride); return true; } diff --git a/src/MHServerEmu.PlayerManagement/PlayerManagerService.cs b/src/MHServerEmu.PlayerManagement/PlayerManagerService.cs index 3b576e61..dca9ec71 100644 --- a/src/MHServerEmu.PlayerManagement/PlayerManagerService.cs +++ b/src/MHServerEmu.PlayerManagement/PlayerManagerService.cs @@ -147,11 +147,6 @@ namespace MHServerEmu.PlayerManagement statusDict["PlayerManagerPendingSessions"] = SessionManager.PendingSessionCount; } - public PlayerHandle GetPlayer(ulong playerDbId) - { - return ClientManager.GetPlayer(playerDbId); - } - private void OnRouteMessageBuffer(in ServiceMessage.RouteMessageBuffer routeMessageBuffer) { IFrontendClient client = routeMessageBuffer.Client; diff --git a/src/MHServerEmu.PlayerManagement/Players/PlayerHandle.cs b/src/MHServerEmu.PlayerManagement/Players/PlayerHandle.cs index 71b3b2fa..be9dc490 100644 --- a/src/MHServerEmu.PlayerManagement/Players/PlayerHandle.cs +++ b/src/MHServerEmu.PlayerManagement/Players/PlayerHandle.cs @@ -814,7 +814,7 @@ namespace MHServerEmu.PlayerManagement.Players } public void ReceiveRegionRequestQueueCommand(PrototypeId regionRef, PrototypeId difficultyTierRef, PrototypeId metaStateRef, - RegionRequestQueueCommandVar command, ulong regionRequestGroupId, ulong targetPlayerDbId, int teamSizeOverride = -1) + RegionRequestQueueCommandVar command, ulong regionRequestGroupId, ulong targetPlayerDbId, int teamSizeOverride) { _regionRequestQueueCommandHandler.HandleCommand(regionRef, difficultyTierRef, metaStateRef, command, regionRequestGroupId, targetPlayerDbId, teamSizeOverride); } diff --git a/src/MHServerEmu/Commands/Implementations/PvPCommands.cs b/src/MHServerEmu/Commands/Implementations/PvPCommands.cs index 5384ea7c..9ae91f98 100644 --- a/src/MHServerEmu/Commands/Implementations/PvPCommands.cs +++ b/src/MHServerEmu/Commands/Implementations/PvPCommands.cs @@ -4,8 +4,6 @@ using MHServerEmu.Core.Network; using MHServerEmu.DatabaseAccess.Models; using MHServerEmu.Games.GameData; using MHServerEmu.Games.Network; -using MHServerEmu.PlayerManagement; -using MHServerEmu.PlayerManagement.Players; namespace MHServerEmu.Commands.Implementations { @@ -32,13 +30,7 @@ namespace MHServerEmu.Commands.Implementations : RegionRequestQueueCommandVar.eRRQC_AddToQueueSolo; int limit = (size == 5) ? -1 : size; - - var playerManager = ServerManager.Instance.GetGameService(GameServiceType.PlayerManager) as PlayerManagerService; - if (playerManager == null) return "Failed to connect to the player manager."; - - PlayerHandle destPlayer = playerManager.GetPlayer(playerConnection.PlayerDbId); - destPlayer.ReceiveRegionRequestQueueCommand(RegionRef, DifficultyRef, PrototypeId.Invalid, command, 0, 0, limit); - + player.MatchQueueStatus.TryRegionRequestCommand(RegionRef, DifficultyRef, 0, command, limit); return $"Queued for {size}v{size} PvP! ({(isInParty ? "Party" : "Solo")})"; }