Files
BT411/engine/MUNGA_L4/L4STEAMNET.h
T
CydandClaude Fable 5 f703bb1d56 Steam: the lobby + IDENTITY-TOKEN roster -- internet MP code-complete (step 4c)
NEW gated (BT_STEAM) game/glass/btl4lobby: an ISteamMatchmaking room replacing
the arcade Site-Management screen -- host creates (lobby data btl4=1), members
join by filter, pilots publish name/mech/color, the host ENTER mints the
roster and signals GO.

THE FAKEIP LESSON (live-verified, prior-art assumption DISPROVEN): a fresh
process gets a DIFFERENT FakeIP, so menu-time fake addresses go stale by
mission time -- the first cycle timed out connecting to its own stale address.
Redesign: roster addresses are opaque ipv4-shaped TOKENS (169.254.77.N with
ports 1501/1502) minted by the host at GO, mapped to Steam IDENTITIES;
connections ride ConnectP2P(identity, channel) with console=0/game=1 virtual
ports; the map reaches mission processes via env (BT_FE_MYFAKE +
BT_FE_STEAMMAP); the GetMyAddress seam feeds the pod its own token for roster
self-match; CheckSocket reports peers by token.  L4STEAMNET reworked (no
FakeIP allocation at all); the marshal gained the Steam-wire branch.

Verified single-machine (ON/ON, live Steam): menu -> HOST STEAM LOBBY ->
room -> GO -> token map minted -> egg roster carries the token -> mission
process up with 1 roster token incl. self -> pod self-matches -> stock
console ladder -> mission RUNS (46 ticks).  Remaining: the live 2-account
cross-machine session (docs/STEAM_TEST.md).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-18 00:03:17 -05:00

71 lines
2.4 KiB
C

#pragma once
//###########################################################################
//
// L4STEAMNET -- the Steam internet transport (BT_STEAM only).
//
// ISteamNetworkingSockets with FakeIP + SDR behind the L4NET.CPP wire
// seam: connections carry the engine's exact TCP byte stream as reliable
// Steam messages, re-assembled into per-connection rings so the engine's
// nonblocking recv semantics hold (empty -> WSAEWOULDBLOCK, peer-closed
// -> 0). Handles are pseudo-SOCKETs (0x5EA0xxxx) so L4Host and every
// call site above the seam are identical on both wires; the peer address
// reported through CheckSocket is the peer's FAKE IPv4:port, so the
// engine's roster matching works against a lobby-built egg whose
// [pilots] carry FakeIPs.
//
// Install: env BT_STEAM_NET=1 (set by the lobby launch path) -- needs the
// Steam client running and content\steam_appid.txt (written with the 480
// Spacewar test id if absent). Everything degrades gracefully: no Steam
// -> inactive -> pure Winsock.
//
// Ports: FakeIP port index 0 = the CONSOLE channel, 1 = the GAME channel
// (mirroring the arcade console-port / game-port=console+1 convention).
//
//###########################################################################
#include <winsock2.h>
int
BTSteamNet_Install(); // 0 = up (FakeIP allocated)
int
BTSteamNet_Active();
void
BTSteamNet_Pump(); // callbacks + rx drain (game thread)
//
// The wire-seam surface (BTNet* wrappers in L4NET.CPP + the marshal).
//
int
BTSteamNet_Owns(SOCKET wire_socket);
int
BTSteamNet_Send(SOCKET wire_socket, const char *data, int length);
int
BTSteamNet_Recv(SOCKET wire_socket, char *buffer, int capacity);
SOCKET
BTSteamNet_Accept(SOCKET listener_socket);
void
BTSteamNet_Close(SOCKET wire_socket);
int
BTSteamNet_PeerAddress(SOCKET wire_socket, SOCKADDR_IN *out);
//
// Connection establishment (the OpenConnection TCP_OPEN delegate + the
// marshal): True when the IPv4 is a Steam FakeIP.
//
int
BTSteamNet_IsFakeAddress(unsigned long internet_address_be);
SOCKET
BTSteamNet_Connect(unsigned long internet_address_be, int remote_port);
//
// The lobby surface: my identity; my roster token (raw, for the
// GetMyAddress self-match seam). Roster tokens + the token->identity map
// arrive in the MISSION process via env (BT_FE_MYFAKE / BT_FE_STEAMMAP --
// see the token-table note in the .cpp).
//
unsigned long long
BTSteamNet_MySteamID();
int
BTSteamNet_GetFakeAddressRaw(unsigned long *internet_address_be);