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:
+10
-2
@@ -4,7 +4,8 @@
|
||||
# - exits 0 and logs start, stats and stop lines that all carry the seed,
|
||||
# - produces the same state hash when run again with the same seed,
|
||||
# - exits non-zero when a script error happens (a deliberate --fault),
|
||||
# - exits non-zero on a bad command line.
|
||||
# - exits non-zero on a bad command line,
|
||||
# - listens on a UDP port when asked to.
|
||||
#
|
||||
# tools/smoke.sh unthrottled, so it finishes in seconds
|
||||
# SMOKE_REALTIME=1 tools/smoke.sh at the real 30 Hz tick rate (about 34 seconds)
|
||||
@@ -69,7 +70,14 @@ run --bots=99 --nonsense
|
||||
[[ "$code" -eq 2 ]] || fail "a bad command line exited $code, expected 2"
|
||||
grep -q '"event":"config_error"' <<<"$output" || fail "a bad command line logged no config_error"
|
||||
|
||||
# A listening server opens its port, waits in the lobby with nobody there, and stops cleanly.
|
||||
port=$((20000 + RANDOM % 20000))
|
||||
run --listen --port="$port" --seed="$seed" --bots=4 --ticks=120 --unthrottled
|
||||
[[ "$code" -eq 0 ]] || fail "a listening server exited $code"
|
||||
[[ "$(field start listening)" == "true" ]] || fail "a listening server didn't say it was listening"
|
||||
[[ "$(field start match_phase)" == "lobby" ]] || fail "a listening server didn't start in the lobby"
|
||||
|
||||
if [[ "$status" -eq 0 ]]; then
|
||||
echo "smoke: ok (clean run, reproducible hash, script error exits 1, bad config exits 2)"
|
||||
echo "smoke: ok (clean run, reproducible hash, script error exits 1, bad config exits 2, listens)"
|
||||
fi
|
||||
exit "$status"
|
||||
|
||||
Reference in New Issue
Block a user