Network System
src/decnet.cpp) is incomplete.
DirectPlay support through Free Direct / Free API is unverified.
This page documents the intended architecture from the source code and README.
Overview
Free Eggbert supports up to 4 simultaneous network players via DirectPlay (DirectX 3). The implementation spans two files:
-
src/network.cpp—CNetworkclass: DirectPlay session management, lobby browsing, transport selection -
src/decnet.cpp—CDecornetwork methods: in-game tick-by-tick synchronization, packet send/receive, event replay
Session Lifecycle
The multiplayer flow is driven by WM_PHASE_* messages dispatched by
CEvent:
-
WM_PHASE_SERVICE— Player selects the DirectPlay transport (IPX, TCP/IP, modem) -
WM_PHASE_SESSION— Browse existing sessions (up toMAXSESSION=100 shown) or create a new one -
WM_PHASE_MULTI— Pre-game lobby; players wait until the host starts the game -
WM_PHASE_PLAY— Synchronized gameplay; each player sends aNetPacketevery game tick
Packet Flow (Per Tick)
Every game tick during WM_PHASE_PLAY:
-
Each player constructs a
NetPacketfrom their current input (KEY_*bitmask), position (blupiPosX/Y), animation state (blupiIcon,blupiChannel), and vehicle (blupiTransport) - Up to 5
NetMessagegame events are embedded in the packet - The packet is broadcast via
CNetwork::Send()to all other players - Each client receives packets, replays the events in
decnet.cpp
Packet Types (PK_*)
| Constant | Value | Description |
|---|---|---|
PK_LEAVE | 8 | Player left the session gracefully |
PK_LOST | 9 | Player connection lost (dropped) |
PK_DIE | 10 | Player character died |
PK_PAUSE | 12 | Game pause toggled by a player |
Game Events (MESS_*)
Up to MAXMESSAGEPERPACKET (5) game events can be piggy-backed in each
NetPacket. They use NetMessage structs with a type
field set to one of these constants:
| Constant | Value | Description |
|---|---|---|
MESS_RESUME | 0 | Resume game after pause |
MESS_PAUSE | 1 | Pause the game |
MESS_LOBBY | 4 | Return to lobby |
MESS_START | 10 | Start game from lobby |
MESS_OBJECTSTART | 20 | Spawn a new moving object |
MESS_OBJECTDELETE | 21 | Remove a moving object |
MESS_MODIFDECOR | 30 | Modify a world decor cell |
MESS_PLAYSOUND | 40 | Play a sound effect |
MESS_STOPSOUND | 41 | Stop a sound effect |
MESS_ASCENSEURSTART | 50 | Start an elevator |
MESS_ASCENSEUREND | 51 | Stop an elevator |
MESS_STOPCLOUD | 60 | Stop cloud invisibility effect |
Personal Bombs
In multiplayer mode, each player has their own colored personal bomb type. These are fired and tracked independently per player, allowing bombs to be attributed to their owner:
| Player | Constant | Color |
|---|---|---|
| Player 1 | TYPE_BOMBEPERSO1 | Yellow |
| Player 2 | TYPE_BOMBEPERSO2 | Orange |
| Player 3 | TYPE_BOMBEPERSO3 | Blue |
| Player 4 | TYPE_BOMBEPERSO4 | Green |
Data Structures
See Data Structures — NetPacket
for the full NetPacket and NetMessage struct field tables.
Network Limits
| Constant | Value | Description |
|---|---|---|
MAXNETPLAYER | 4 | Maximum simultaneous players |
MAXTEAM | 4 | Maximum teams |
MAXSESSION | 100 | Max sessions listed in browser |
MAXNETMESSAGE | 20 | Max pending queued messages |
MAXMESSAGEPERPACKET | 5 | Max game events per packet |
Related Pages
- CNetwork module — session management class
- NetPacket / NetMessage structs
- Game Phases Reference — WM_PHASE_SERVICE, WM_PHASE_SESSION, WM_PHASE_MULTI
- Object Types — TYPE_BOMBEPERSO1–4