Skip to content

fix(coop): refuse a lobby join on a different build or mod list (#211) - #235

Merged
NonPolynomialTim merged 4 commits into
mainfrom
fix/issue-211-join-checks
Nov 6, 2026
Merged

NonPolynomialTim merged 4 commits into
mainfrom
fix/issue-211-join-checks

Conversation

@NonPolynomialTim

@NonPolynomialTim NonPolynomialTim commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Two players on different builds, or with different mod lists, could join each other's lobby on most paths. What each path let through on main (reproduced by the new tests, below):

Join path (test cells) Different build Host reports no build Host reports no mods Mod at another version Mods in another order
TCP: Direct Connect, saved server (join_tcp) joins joins joins joins joins
TCP host with a password password prompt, then joins password prompt, then joins password prompt, then joins password prompt, then joins password prompt, then joins
UDP (the same handshake over UDP) joins joins joins joins joins
Online server list, clicking the room not listed not listed online; listed through LAN discovery password prompt, then joins password prompt, then joins password prompt, then joins
Online room joined by id stuck on "Connecting..." joins

Root cause (captured with temporary logging, removed before commit)

  • The TCP join reply carries no build version, and the joiner compares none. Captured reply keys: mods,playername,servername,state, with the joiner reporting build 9.9.9.9 and hasRequiredMods=1.
  • Every mod list on the wire is names only. A host on mod A 1.0 and a joiner on mod A 2.0 both sent xcom1;Coop_JoinCheck_A_Test;Coop_JoinCheck_B_Test;.
  • hasRequiredMods compares the names as a set: host xcom1;A;B; against joiner xcom1;B;A; returned true.
  • An empty list passes: hasRequiredMods("") returns true, and the rendezvous join check skips an empty room version.
  • The online and LAN joins never sent a mod list to the rendezvous server. Captured stub requests: every JOIN_ROOM had mod_hash '', so the server's exact-string mod check never ran (the issue's table assumed it did).
  • The password challenge carries nothing to check, so the joiner is asked for the password first.
  • A rendezvous refusal sets onConnect = -4, which nothing handles. Captured: onConnect -1 -> -4 with "Connecting..." on top, unchanged until the test left.

Fix

The joiner compares the host's build version and whole mod list (each mod's id and metadata version, in load order) with its own before it enters the lobby. An empty version or mod list never matches.

  • The host's join reply and its password challenge carry game_version and each mod's version. The joiner checks all three messages. This covers TCP (Direct Connect, saved servers, the password retry) and every UDP join, since they run the same handshake. A refused join opens the incompatible-mods screen (ModCheckMenu) and never the password prompt.
  • A room publishes its mods as id:version; in load order. The server browser's click check and filter, the Direct Connect UDP check and the LAN list's version filter compare it whole.
  • A rendezvous refusal (-4) now opens the incompatible-mods screen with the refused room's mods, and the Direct Connect UDP failure callbacks no longer open the password prompt for it.
  • The incompatible-mods screen names what differs. A line under the title names both builds when they differ ("Host build 2.0.36.0, your build 2.0.35.0.", or "unknown" for a host that reports none). A mod the host loads at another version shows "Different version (host 3.9).", and a mod in another place among the mods both games load shows "Different load order.". Before this, those refusals listed every mod as "This mod is enabled.".
  • The incompatible-mods screen no longer lists xcom1 a second time as an extra mod to disable. The display rename changed the list the extra-mod check read. This happened on main too, for every mod-name refusal.

The rendezvous server is unchanged.

Tests

  • test_join_checks_tcp.py: join_tcp without and with a host password (the challenge and the retry).
  • test_join_checks_udp.py: the direct UDP transport, and the online server list served by rendezvous_stub.py (clicking the listed room, or joining by room id when the list leaves the room out).

Each file has six cells per path: a different build, a host reporting an empty build, a host reporting an empty mod list, a mod at another metadata version, the same mods in another load order, and a matching game. A refused cell must end on the incompatible-mods screen, with the lobby, the join popup and the password prompt never shown, the session down, and the screen showing exactly the expected rows and build line. Test support: set_reported_identity replaces the build version or mod list a game reports. There are server-browser and incompatible-mods-screen test commands, and three data-only test mods (Coop_JoinCheck_A_Test at 1.0 and 2.0 with the same id, Coop_JoinCheck_B_Test).

  • Red on main plus the test commit: 3 of 3 runs per file, every mismatch cell fails, both matching cells pass.
  • Green on this branch: both files pass. 20 of 20 runs per file (10 per harness slot, two slots in parallel), every run RESULT PASS.
  • Local walls over those 40 runs: TCP file 13.9 to 14.2 s, UDP file 33.6 to 34.7 s (CI budget 180 s). After hosting rendezvous rooms the UDP host exits 0xC0000409 with only the std::terminate called (no active exception). crash line (20 of 20 runs; main does the same). The test accepts exactly that exit, as test_udp_rejoin.py does.
  • Existing tests run once each, all pass: test_lobby_dialogs, test_server_browser, test_udp_rejoin, test_handshake, test_session_hardening, test_skirmish_flow, test_retry_cancel, test_client_gates, test_bringup_capture, test_crashlog_modlist, test_lobby_gating, test_lobby_polish, test_udp_bringup, test_skirmish_saved_battle_join, test_shared_toggles, test_pvp_rehost_mode. The four CI lints pass.

Not driven by a test

  • The LAN server list and Direct Connect UDP find the host through LAN discovery on the fixed UDP port 39002, which parallel harness lanes share, so no verdict depends on it. They use the same compare (isCoopJoinCompatible) and refusal (-4, the screen the online-by-id cell drives), and the UDP handshake check behind them is driven. One LAN effect shows up as evidence: on main the room of a host reporting no build reached the joiner's list in 3 of 3 red runs. The stub's list filter leaves it out, so it came through LAN discovery. With the fix it is absent.
  • Saved TCP servers and the Direct Connect TCP button make the same connectTCPServer call as join_tcp.

Known limits

  • A room's published mod list grows by each mod's version. The LAN discovery answer is still capped at 1000 bytes, so a very long mod list drops out of the LAN list sooner than before (the online list is not capped).

  • The check runs on the joiner. A joiner on an older build is not refused by a host on this build.

  • The host still shows " has joined" for a moment before the joiner disconnects, as it already did for a mod-name refusal.

Fixes #211

…in path

Two lobby tests join a host from a game that differs in exactly one way
(another build version, a host that reports an empty build version or mod
list, a mod at another metadata version, the same mods in another load
order) and from a matching game:

- test_join_checks_tcp.py: join_tcp, without and with a host password
  (the challenge and the retry).
- test_join_checks_udp.py: the direct UDP transport, and the online server
  list served by rendezvous_stub.py (clicking the listed room, or joining
  by room id when the list leaves the room out).

A refused join must end on the incompatible-mods screen without ever
showing the lobby, the join popup or the password prompt.

Test support:
- The build version and mod list a game reports (getReportedGameVersion,
  getReportedMods) can be replaced by the set_reported_identity test
  server command.
- Test server commands to list, refresh and join server browser rows and
  to read or close the incompatible-mods screen. ServerList's row join
  moves into joinServer() so a command can drive it.
- Three data-only test mods: Coop_JoinCheck_A_Test at versions 1.0 and
  2.0 (same mod id) and Coop_JoinCheck_B_Test.
…ery path

A joiner now compares the host's build version and whole mod list (each
mod's id and metadata version, in load order) with its own before it
enters the lobby, and an empty version or mod list never matches.

- The host's join reply and its password challenge carry game_version and
  each mod's version. The joiner checks all three messages, so TCP joins
  (Direct Connect, a saved server, the password retry) and the UDP joins
  that run the same handshake are refused, and a refused join never
  reaches the password prompt.
- A room publishes its mods as "id:version;" in load order. The server
  browser's click check and filter, the Direct Connect UDP check and the
  LAN list's version filter compare it whole.
- A rendezvous refusal (onConnect -4) used to leave the joiner on
  "Connecting..."; it now shows the incompatible-mods screen with the
  refused room's mods, and the Direct Connect UDP failure callbacks no
  longer open the password prompt for it.
- The incompatible-mods screen no longer lists xcom1 a second time as an
  extra mod to disable: renaming it for display changed the list the
  extra-mod check read.

Fixes #211
A join refused for another build, mod version or load order showed every
mod as "This mod is enabled.", so nothing said why it was refused.

- A line under the title names both builds when they differ, for
  example "Host build 2.0.36.0, your build 2.0.35.0." A host that
  reports no build shows as "unknown".
- A mod the host loads at another version shows "Different version
  (host 3.9)."; a mod loaded in another place among the mods both games
  share shows "Different load order."
- The rendezvous refusals keep the refused room's build version for the
  line; a refusal opened from a server browser row has none (the list
  only shows rooms on the joiner's own build), so it shows no line.

The join-check tests now assert the exact rows and line for each cell.
@NonPolynomialTim
NonPolynomialTim marked this pull request as ready for review November 6, 2026 02:29
@NonPolynomialTim
NonPolynomialTim enabled auto-merge (squash) November 6, 2026 02:29
@NonPolynomialTim
NonPolynomialTim merged commit c3def5c into main Nov 6, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lobby join: block different builds and mod lists on every join path (TCP skips the version check)

1 participant