diff --git a/docs/netcode-revival.md b/docs/netcode-revival.md index 2ef47bc..46c2e43 100644 --- a/docs/netcode-revival.md +++ b/docs/netcode-revival.md @@ -40,13 +40,31 @@ Implemented in `rexglue-sdk/src/kernel/xam/xam_net.cpp`: - `getsockopt`: real basic reads off the native socket. - `XNetSetSystemLinkPort`: accept. -## Phase 1 — relay game-transport + session registry (next) -- Extend `ghost_relay` to forward game UDP between room members + expose the - session list that `XNetQosLookup` reads. -- Give rexglue `XSocket` a relay-transport mode (recognize `10.80.0.x` - virtual destinations; route via the relay outbound). -- Test: two game instances on one machine (loopback through the relay) reach - a joined session. +## Phase 1 — relay game-transport + session registry (done, built) +- v5 relay: `kTypeGame` (opaque game UDP, unicast or room-broadcast) + + `kTypeSessionQuery`/`Reply` (discovery). JoinPayload carries the virtual IP. +- rexglue `XNetTransport`: joins the same relay + room as the ghost client, + routes `sendto` to `10.80.0.x` peers through the relay, injects inbound + game datagrams into the game's sockets, and serves session discovery to + `XNetQosLookup`. +- Wire structs byte-verified against the game's proto (sizes 7/31/1410/25/801) + with `static_assert`s on both sides. + +## Test recipe (two instances on one machine, local relay) +1. Build: `cmake --build out/build/linux-relwithdebinfo --target ghost_relay skate3 -j$(nproc)` +2. Start the local relay: `./out/build/linux-relwithdebinfo/ghost_relay --port 40001` +3. Launch instance A: `./out/build/linux-relwithdebinfo/skate3` + Launch instance B (same machine; the relay loops them via 127.0.0.1). +4. In each instance's M menu: set `skate3_ghost_server = 127.0.0.1`, enable + multiplayer, join the SAME room code. The relay then routes both the ghost + poses and the game's own netcode traffic. +5. Verify in the log (stdout): `xnet transport: connecting to relay ...`, + `xnet transport: relay joined`, and on session search + `xnet transport: session reply with N session(s)`. Enable the game's + online flow (invite/join) and check whether RakNet establishes a session. +6. Two instances bind the same UDP data port → the second may fail to bind. + If so, the game's socket bind must become relay-aware (bind to an + ephemeral port in relay mode) — a known Phase 3 item. ## Phase 2 — invite UI - `XamShowGameInviteUI` / `XamShowFriendsUI` as ImGui `XamDialog`s backed by