Pages

Showing posts with label network. Show all posts
Showing posts with label network. Show all posts

Network model

A brief overview of how networking is implemented in the game.

UDP is the protocol, with a custom reliability/ordering capability available.

Packets are compressed with zstd using a dictionary.

The game sends all input events to the server, these are then resent out to all other players, who replay them in the correct order.

Physics data is constantly sent out by the server, and clients interpolate toward the servers version. It uses a priority system to determinate which bodies to transmit, the system is stateless and relies on weighed randomness to determine which is sent. Basically compute a weight per body(based on proximity/visibility etc) + a random value between 0-1 for each body, multiply them, and then pick the top N bodies.  

I experimented with extreme quantization of physics data but found it caused jittering, so the quantization is limited to 16 bit floats, the server imposes this same quantization on its own data to match the clients.

 Map data is the bulk of what is initially sent, basically all those damn edits! The server tracks exactly which edits each player is aware of, when a player connects it bulk sends sections of the world to the player. And as minor edits happen these are also send out to players with some location priority to pick the most important. Edit order matters so each edit has an associated order so they can be reassembled in the correct order.