Photon/matchmaking/implement/premade matchmaking#1494
Open
Davetsa wants to merge 50 commits into
Open
Conversation
- Implemented InRoomInviteSelectorPanel to allow users to select and invite online players to a premade room. - Added UI elements including title, close button, and player list with dynamic row generation. - Included fallback styles for UI elements to ensure consistent appearance. - Created InviteDecisionPopupHandler for handling invite decisions with customizable messages and button texts. - Updated RoomSetupManager and MatchmakingPanel to handle new game type InRoom_ and ensure proper UI interactions. - Enhanced error handling and null checks across various scripts to improve stability.
- Updated InviteDecisionPanel prefab to include reject and accept buttons with corresponding text fields. - Modified InRoomController to handle invite selection more gracefully, ensuring the invite selector panel is available before proceeding. - Enhanced GetInviteCandidatesRoutine to prefer fresh server data when fetching online players. - Removed unnecessary runtime creation logic from InRoomInviteSelectorPanel, ensuring it is assigned from prefab. - Simplified ConfigureVisualStyle method in InRoomInviteSelectorPanel to streamline visual updates based on button styles.
…hmaking/implement/PremadeMatchmaking
- Introduced InviteSelectorRow prefab for inviting online players. - Updated Battle Popup prefab to include a reference to the new InviteSelectorRow. - Adjusted layout settings in Battle Popup for better UI alignment. - Enhanced InRoomController to ensure InviteSelectorPanel is initialized correctly. - Implemented functionality in InRoomInviteSelectorPanel to handle click events for closing the panel. - Improved visual style configuration for invite rows and adjusted row height for better usability.
…ion and visibility management
Add queue pair metadata for duos/solo blocks and carry it into formed matchmaking rooms. Centralize queue match formation in QueueTimerCoroutine with ready checks, retries, and master-transfer preference for duo continuity. Improve premade teammate resolution and same-side reservation logic, including validation and requeue fallback when block composition is invalid. Guard against duplicate start/follow handoffs with debounce and explicit-room duplicate suppression. Skip follower join-timeout requeue logic for queue-formed expected-user rooms. Track post-StartGame state to avoid cancel/requeue behavior after match start and reset it consistently on failures/room transitions.
…lan2v2 add pending leader/expected-user grace tracking to avoid splitting duos during queue handoff defer early queue starts for multi-duo, one-sided premade, and transient orphan-follower states include Photon expected users in join watcher logic and queue expected-user detection improve follower handoff by passing expected teammate overrides during room follow sync reserved player slots on join and allow reserved users in full queue-formed rooms prevent partial gameplay starts when human players are missing from start slots skip bot backfill when room is already full with humans keep master-switch restart/requeue logic out of persistent queue rooms route leave/requeue flow through persistent queue auto-join handling
…hmaking/implement/PremadeMatchmaking
…tics -Add robust queue helpers and checks to identify queue-formed/expected-user flows. Prevent premature match formation by verifying premade/teammate integrity in timer and selection logic. -Implement premade-pair reservation failure handling (abort, leave room and requeue leader). -Refine solo/orphan selection (solo cap when 3 solos) and pending-duo signal handling. -Improve payload parsing for RoomChangeRequested (flatten varied shapes). -Add extensive diagnostic logging and snapshots to aid debugging and trace reservation/readback steps.
…onsistency and delayed matchmaking checks
…f eligible players
…ring match creation
…for solo and duo handling
…tines on matchmaking stop
…equired followers are insufficient Co-authored-by: Copilot <copilot@github.com>
…ing premade invites
…or improved rendering
…current match formations
…duo pairing logic
… update logging for room joins
…ite handling logic
…n interaction logic
…empts and improve error handling
…nager and InLobbyController
…error handling in InLobbyController for failed room invites.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Implement Premade Matchmaking Flow
This pull request introduces a comprehensive premade matchmaking system that allows players to form duos, send invites, and queue together through dedicated friend lobbies. The implementation includes new game types, Photon room properties, queue management infrastructure, and UI components for the premade invite flow.
Core Features: Premade Matchmaking
New GameType.FriendLobby: Added a new game mode for 2-player premade friend lobbies that serve as the entry point for premade player interactions. Friend lobbies have a maximum of 2 players and are distinct from matchmaking and queue rooms. [1]
Premade Invite System: Implemented
SendPremadeInvite()method inPhotonRealtimeClientto send invitations from one player to another. Invites track state (pending, accepted, declined, expired) and timestamp to manage the lifecycle of premade pairing requests. [1]Premade Invite Room Properties: Added 9 new room property keys to track premade state:
PremadeModeKey("pm"): Boolean flag indicating premade modePremadeTargetGameTypeKey("ptg"): Target game type (Random2v2, Clan2v2)PremadeLeaderUserIdKey("plid"): The leader's user IDPremadeInvitedUserIdKey("piu"): The invited player's user IDPremadeInviteStateKey("pis"): Current invite state (none=0, pending=1, accepted=2, declined=3, expired=4)PremadeInviteTimestampKey("pits"): Timestamp of invite creationPremadeUserId1Key("pm1") andPremadeUserId2Key("pm2"): The two paired user IDsCreateInRoomPremadeLobbyRoom(): New method to create friend lobby rooms with expected users, enabling the initial 2-player room setup for premade pairs. [1]
Queue Management Infrastructure
JoinAttemptTracker: New utility class to track and manage join attempt history for rooms, helping prevent redundant join attempts and enabling diagnostics for join failures. [1]
Enhanced Queue Formation Logic:
SelectQueueFollowersForMatch()and related methods now include sophisticated handling for premade duos within queues, including:Two-Player Block Selection: Implemented
SelectQueueFollowersFromTwoPlayerBlocks()for 2v2 match formations, which:Queue Timer Enhancements:
QueueTimerCoroutine()now includes:Room State Validation: Added
ValidateQueueTwoPlayerBlockComposition()to ensure queue-formed matchmaking rooms contain valid 2-player block arrangements before game start. [1]Premade Flow & Room Transitions
Premade-to-Queue Handoff:
StartMatchmaking()now includes intelligent premade teammate resolution:pm,pm1,pm2,plid) before followers joinRoomChangeRequested Selective Updates: Updated to only modify
LeaderIdKeyfor targeted followers, preventing corruption of duo linkage for non-targeted players during queue transitions. [1]Queue-Formed Match Formation:
FormMatchFromQueue()now:QueueDuoPairsKeyto track duo groupingsGame Start Validation:
StartTheGameplay()now validates that all in-room human players are included in computedPlayerSlotUserIdsbefore starting. If validation fails, sendsCancelGameStartand restarts waiting loop. [1]UI Components & Invite Handling
InviteDecisionPanel.prefab: New popup panel for displaying and handling invite acceptance/declination decisions. [1]
InviteSelectorRow.prefab: New UI row component for displaying individual invites in a list, with accept/decline buttons. [1]
InRoomInviteSelectorPanel.cs: New panel script managing the display and interaction of multiple invite rows, handling UI state and callbacks. [1]
InviteDecisionPopupHandler.cs: New handler for managing the lifecycle of invite decision popups, ensuring fail-closed behavior (decline + notification on UI failure). [1]
Enhanced InLobbyController: Updated to:
Updated LobbyRoomListingController: Added single-flight guard for queue room join requests to prevent duplicate room creation from rapid UI interactions. [1]
BattlePopupPanelManager Enhancements: Updated to support invite button rendering and premade flow UI state. [1]
InRoomController Updates: Added event handlers and logic for premade-specific in-room behavior and state management. [1]
RoomSetupManager Updates: Enhanced to handle premade room properties and invite state changes. [1]
Critical Stability Improvements
Orphan Follower Handling: Queue selection now properly excludes orphaned followers (those with missing leaders) from solo-candidate pools in 2v2 modes, preventing transient leader-absence from splitting valid duos. [1]
Multi-Duo Preservation: When 2+ complete duo pairs exist in a queue with extra players, selection defers formation to allow both duos to stabilize before creating matches, preventing premature solo+one-duo starts. [1]
One-Sided Premade Metadata Handling: When premade metadata exists but one partner is absent, the present partner is marked incomplete rather than blocked, allowing valid compositions while deferring fully-settled pairs. [1]
Non-Master Join Timeout Disable for Queue-Formed Rooms: Followers in queue-formed matchmaking rooms skip the 5-second join-timeout watcher, preventing false timeouts during multi-follower convergence. [1]
Join Failure Auto-Requeue Guard:
OnJoinRoomFailed()now setsIsJoinFailureAutoRequeueInFlightflag so duplicate queue rejoin attempts are skipped for the same failure. [1]Defensive Callback Subscription:
Activate()now resets Photon callback handlers before re-subscribing, preventing duplicate handler registrations across lifecycle transitions. [1]OnStartMatchmakingEvent Debouncing: Added frame-level debounce to prevent back-to-back event publications from spawning duplicate matchmaking transitions. [1]
Summary
This implementation establishes a complete premade matchmaking flow from friend lobbies through queue formation to game start, with robust safeguards against duo splits, race conditions, and metadata corruption. The system tracks premade relationships across multiple room transitions and ensures both players in a premade pair reach the matchmaking room together and maintain their team assignment through game start.