CNetwork

Header: include/network.hpp
Implementation: src/network.cpp

CNetwork wraps DirectPlay (DirectX 3) session management. It handles the multiplayer lobby: creating and browsing game sessions, connecting players, and sending/receiving NetPacket data each game tick. In-game synchronization is handled in src/decnet.cpp (part of CDecor).

🚨
Multiplayer is currently broken
Network synchronization in src/decnet.cpp is incomplete. DirectPlay support through Free Direct / Free API is unverified. Do not expect multiplayer to work in the current build.

Overview

Free Eggbert supports up to 4 simultaneous network players. Networking is built on DirectPlay from DirectX 3, which provides session browsing over IPX, TCP/IP, and modem transports.

Session Lifecycle

The multiplayer flow is driven by game phases in CEvent:

  1. WM_PHASE_SERVICE — select DirectPlay transport (IPX, TCP/IP, modem)
  2. WM_PHASE_SESSION — browse available sessions or create a new one
  3. WM_PHASE_MULTI — pre-game lobby; wait for all players to join
  4. WM_PHASE_PLAY — synchronized gameplay begins

Methods

Full signatures from include/network.hpp:

// Session management
BOOL EnumProviders();
int  GetNbProviders();
char* GetProviderName(int index);
BOOL CreateProvider(int index);  // selects IPX, TCP/IP, modem
void FreeProviderList();

BOOL EnumSessions();
int  GetNbSessions();
char* GetSessionName(int index);
BOOL JoinSession(int index, char* pPlayerName);
BOOL CreateSession(char* pSessionName, char* pPlayerName);
void FreeSessionList();

BOOL Close();
BOOL IsHost();

// Raw packet I/O (called by decnet.cpp each tick)
BOOL Send(LPVOID lpData, DWORD dwDataSize, DWORD dwFlags);
BOOL Receive(LPVOID pDest, DWORD dwDataSize, LPDWORD lpdwPlayer);

NetPlayer Struct

Tracks one remote player's connection state, stored in m_players[MAXNETPLAYER]:

typedef struct {
    char  bIsPresent;   // slot occupied
    char  ready;        // player ready to start
    char  unk_2;
    char  unk_3;
    DPID  dpid;         // DirectPlay player ID
    short team;
    char  name[22];     // player name string
} NetPlayer;

Packet Types (PK_*)

ConstantValueDescription
PK_LEAVE8Player left the session
PK_LOST9Player lost (game over)
PK_DIE10Player died
PK_PAUSE12Game pause toggled

In-Game Synchronization

Actual in-game synchronization is implemented in src/decnet.cpp, which is part of the CDecor class. Each game tick, every player sends a NetPacket containing their current input, position, animation state, and up to 5 NetMessage game events.

See Network System for the full packet structure, MESS_* constants, and personal bomb types. See Data Structures for the NetPacket and NetMessage struct layouts.

Session Limits

ConstantValueDescription
MAXNETPLAYER4Maximum simultaneous network players
MAXTEAM4Maximum teams
MAXSESSION100Max sessions shown in browser UI
MAXNETMESSAGE20Max pending network messages
MAXMESSAGEPERPACKET5Max game events per packet