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>
This commit is contained in:
Cyd
2026-07-17 23:47:47 -05:00
co-authored by Claude Fable 5
parent e79e8faeed
commit 48ede2f7d7
6 changed files with 701 additions and 20 deletions
+22
View File
@@ -2760,6 +2760,17 @@ bool L4NetworkManager::CheckSocket(SOCKET socket, SOCKADDR_IN *remoteEndpoint)
{
if (remoteEndpoint)
{
#ifdef BT_STEAM
//
// A Steam pseudo-socket's peer is its FAKE ipv4:port -- the same
// address the lobby-built egg carries in [pilots], so the swap/
// match logic downstream works unchanged.
//
if (BTSteamNet_Owns(socket))
{
return BTSteamNet_PeerAddress(socket, remoteEndpoint) != 0;
}
#endif
int size = sizeof(SOCKADDR_IN);
memset(remoteEndpoint, 0, size);
if(!getpeername(socket, (sockaddr*)remoteEndpoint, &size))
@@ -2818,6 +2829,17 @@ SOCKET L4NetworkManager::OpenConnection(
if(connection_type == NETNUB_TCP_OPEN)
{
#ifdef BT_STEAM
//
// A FakeIP target travels the Steam wire (SDR); the returned
// pseudo-SOCKET flows through the same L4Host bookkeeping.
//
if (BTSteamNet_IsFakeAddress((unsigned long)internet_address))
{
return BTSteamNet_Connect(
(unsigned long)internet_address, remote_port);
}
#endif
DEBUG_STREAM << "Opening connection to " << inet_ntoa(*(in_addr*)&internet_address) << ":" << remote_port << "...\n" << std::flush;
SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);