NewNetworkProtocol
Specification of the new asynchronous Network Protocol
New Async Network protocol
Instead having a DirectX based network system, we use a dedicated Server.
The Server component is only responsible to broadcast messages between the Clients so all TTDPatch Clients work in sync. Unlike traditional TTD, network joining will work while the first player is already in a game, the other players will get synced.
Both Server and Client have a framecounter, every action will take place at a certain framenumber.
A client sends actions to the server, which then decides at what frame the action on a client should take place. (The client doesn't cache the data, so the server has to send the data back.) The server is aswell responsible to initate a client sync and aswell check the random gen number of the clients from time to time, if they are in sync, if not the server initiate a sync.
A client will only advance to the next frame if the server sends a hearbeat packet.
The heartbeat packet is created every 27ms, at a configurable duration the heartbeat packet with randomgen request is send, a client then has to answer with a random gen number package and the server checks each active client if the random number matches with the other client.
Note: The action data for a frame has to arrive directly before the heartbeat package for that frame number.
-=Packets=-
A network packet has a variable lenght and is always in little endian format.
Each package start with a <u32 framenumber> follwed by a <u8 type>.
||Type|Name|Description|Following Data
0x01|Action Data|The raw action data of ttd follows| <u8 len> <u8 data*len>
0x02|Action Data End Marker|Send after all actions of this frame got send|-||
Service Packets:
||Type|Name|Description|Following Data
0x30|Heartbeat|Send by the server to a client| -
0x31|Heartbeat with rnd request|with additional requesting a random number|-||