Files
BT411/engine/MUNGA_L4/L4STEAMNET.h
T
CydandClaude Fable 5 48ede2f7d7 Net: the Steam transport -- FakeIP + SDR behind the wire seam (step 4b)
NEW gated (BT_STEAM) TU L4STEAMNET: ISteamNetworkingSockets with FakeIP --
pseudo-SOCKET handles (0x5EA0xxxx) behind the L4NET BTNet* seam; the engine
TCP byte stream rides reliable-NoNagle Steam messages re-assembled into
per-connection rings (nonblocking recv semantics preserved: empty ->
WSAEWOULDBLOCK, peer-closed -> 0); two FakeIP ports mirror the arcade
console/game channel convention; listen sockets + accept queues via the
global status-changed callback; graceful degrade to Winsock at every step.
Seam completions in L4NET.CPP: CheckSocket reports a pseudo-socket peer as
its FAKE ipv4:port (the lobby egg roster matches unchanged); OpenConnection
TCP_OPEN delegates FakeIP targets to BTSteamNet_Connect.  WinMain installs
on BT_STEAM_NET=1 (lobby launch path / by hand).  CMake: gated SDK include/
lib/dll-copy.  Both pumps (SteamAPI_RunCallbacks + sockets RunCallbacks)
drive it -- the FakeIP result rides the GENERAL dispatch (first attempt with
only the sockets pump timed out).

Verified live (ON/ON build, Steam client running): SteamAPI_Init OK,
steam_appid.txt(480) auto-written, FakeIP allocated
(169.254.36.58, console 54464 / game 54465); without BT_STEAM_NET or
without Steam the game stays pure Winsock.

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

67 lines
2.3 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: our own fake address, dotted, plus its two ports.
//
int
BTSteamNet_GetFakeAddress(char *dotted_out, int capacity,
int *console_port, int *game_port);