N2: Snapshot replication and interest management
NetSnapshot defines the game traffic after the handshake: delta snapshots of quantized entity records, the client's input packet and a reliable match notice. SnapshotSender builds each client's snapshot against the newest one it acknowledged, tells it only about entities near the player it is watching, and keeps every snapshot under 1,200 bytes, nearest first, with a staleness bonus so nothing starves. SnapshotReceiver rebuilds the picture, ignores old and repeated snapshots and asks for a fresh start if it is ever sent a delta on something it doesn't hold. NetGame joins the transport to the match: people who connect become participants, their inputs go through ServerLoop.submit() once per tick, and snapshots go out 20 times a second. `--server --listen` makes the headless server take network players and wait in the lobby for the first of them. Measured by test on a 24-player match start with every player a client, a tenth of packets lost and late acknowledgements: 2.4 KB/s mean and 2.5 KB/s for the worst client, packet headers included, against a 40 KB/s limit. Closes #33 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,15 @@ func test_all_options() -> void:
|
||||
assert_eq(config.to_dictionary()["bot_difficulty"], "hard")
|
||||
|
||||
|
||||
func test_listen_is_off_by_default_and_refuses_idle_slots() -> void:
|
||||
assert_false(_parse(["--server"]).listen)
|
||||
var config: ServerConfig = _parse(["--server", "--listen", "--port=4001", "--bots=24"])
|
||||
assert_true(config.is_valid(), str(config.errors))
|
||||
assert_true(config.listen)
|
||||
assert_eq(config.to_dictionary()["listen"], true)
|
||||
assert_false(_parse(["--server", "--listen", "--players=2"]).is_valid())
|
||||
|
||||
|
||||
func test_bot_difficulty_defaults_to_mixed_and_rejects_unknown_names() -> void:
|
||||
assert_eq(_parse(["--server"]).bot_difficulty, -1)
|
||||
assert_eq(_parse(["--server", "--bot-difficulty=mixed"]).bot_difficulty, -1)
|
||||
|
||||
Reference in New Issue
Block a user