feat(lobby): block create/join while in matchmaking - #1
Open
ChronoFinale wants to merge 1 commit into
Open
Conversation
Creating or joining a custom lobby while a matchmaking search was active left the player searching and in a lobby at once. Route create_lobby_with_gamemode and SPDRN._join_lobby_with_code through MPAPI.matchmaking.guard_queued, which shows the "Leave Queue & Continue" overlay and stashes a replay of the consumer function so the full setup (setup_lobby_events + the connected handler) runs on continue. Requires MultiplayerAPI with the guard_queued helper and the api_client concurrent-request fix.
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.
While a matchmaking search is active, you could still create or join a custom lobby and end up searching and in a lobby at the same time. With this PR, a queued player who tries either gets a "Leave Queue & Continue" overlay instead; continuing leaves the queue and then re-runs the action. When not searching, nothing changes.
The bug
create_lobby_with_gamemode(ui/main_menu/create_lobby.lua) andSPDRN._join_lobby_with_code(ui/main_menu/join.lua) never checked matchmaking state.The fix
Both entry points now open with a guard — join's:
(create's is identical, replaying
create_lobby_with_gamemode(key).) When not searching,guard_queuedreturns false and the function proceeds as before. When searching, it shows the overlay and stashes the closure to run after leaving the queue. If the player declines, the entry point has already returned; nothing happens.The closure re-enters the mod's own entry point, not
MPAPI.create_lobby/MPAPI.join_lobby. That is the load-bearing detail: these entry points callSPDRN.setup_lobby_events, which wires the lobby events and the connected handler that moves the client into the lobby. Replaying only the API call would create/join server-side (the host sees you) while your client stays stranded on the main menu.How to review
ui/main_menu/create_lobby.luaandui/main_menu/join.lua. Start there.Tests
From the repo root:
Covers:
setup_lobby_events, for both create and joinsetup_lobby_eventsnever runs, pinning the stranding failure modeDepends on
Both must merge before this PR:
MPAPI.matchmaking.guard_queuedand the overlay. The guards call it unconditionally, so the installed API must include it.Related: Balatro-Multiplayer/BalatroMultiplayer#496 adds the same guard to the PvP mod, so behavior is consistent across mods.
What it looks like
Clicking a lobby create/join button while searching shows the shared guard overlay (from the API's queue-guard PR) instead of silently stranding the queue — with the search visibly running in the status panel:
Full annotated gallery of the guard's behavior (every entry point, every button outcome): VERIFICATION.md