- LAN discovery: a listening server answers QUERY packets on its game port
plus one (ServerBeacon, off with --no-lan). ServerBrowser scans eight game
ports from 24650 by broadcast.
- A self-hostable list server: --list-server [--port=N] (ListServer,
default UDP 24660). Game servers register with --list=HOST[:PORT] and
--name=NAME; they are listed under their source address only after
echoing a CHALLENGE token. Entries expire after 45 s, 8 per address,
256 in all; every source is rate-limited (SourceLimiter).
- NetDiscovery messages: every QUERY is padded to 512 bytes and no answer
is bigger, so neither service amplifies spoofed requests.
- tidewall --browse [--list=...] [--lan-target=IP] [--lan-port=N] prints
the servers found as JSON until menus (A10) show them.
- People who connect mid-match or during results watch a living player
(Match.watch) and take places ahead of bots in the next lobby, instead
of being told the server is full. Bots fill only the places left when
the match starts.
- Tests: codec round trips, size limits and a 40,000-message fuzz; list
server with fake servers (challenge, stolen and wrong tokens, renewal,
expiry, caps, flood); LAN scan over loopback; watchers over UDP; lobby
backfill. make discovery-check runs it all as real processes.
Closes#37
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Built pieces, props' health, opened chests and the tide's schedule now reach
clients as WORLD messages on the reliable channel, and each player is told
what they carry as OWN messages.
- NetWorld: the WORLD and OWN wire formats, and world_hash(), a digest of
everything replicated this way.
- WorldSender: one message after each tick in which something changed, the
same for everyone, and the whole state for someone joining or a new match.
StructureSet and PropSet keep the change lists it reads.
- ClientWorld: applies them to the client's world, so pieces and broken props
are solid for prediction. A piece's health follows from its building and
damage, so building costs nothing on the wire.
- Placing ahead of the server: a provisional piece goes up with the command
and is replaced by the server's, or taken back once a snapshot shows the
server had its chance. Snapshots carry the newest WORLD number for that.
- Protocol version 3.
A test plays a whole scripted match on a real island with a ClientGame
attached and compares the two worlds' hashes throughout.
Closes#36
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A network client draws other players in the past and its commands take time
to arrive, so by the time the server fires a shot the target has moved on:
8 ticks at a 50 ms round trip, 12 at 200 ms.
Each PlayerCommand now carries view_lag: how far back its player was seeing
everyone else, in quarter ticks. The simulation keeps where every player's
body has been for the last 15 ticks (HitHistory), and a hitscan shot is
traced against other players where they were at the moment the shooter saw,
and against the world as it is now. Projectiles aren't rewound.
The client claims only when it was looking and where it aimed; the server
works out the hit from its own record. The moment is never more than
Tuning.LAG_COMPENSATION_MAX_TICKS back, never in the future, and never
earlier than a moment the same player has already claimed.
Commands are 15 bytes, so the command log's version is 2. The lag is in the
log, and replays judge every shot as the match did.
Measured in test/net/test_lag_compensation_link.gd over a simulated link:
a client firing at a walking target as drawn on its own screen hits 41 of
41 shots at 50, 100 and 200 ms round trips, 0 of 41 with the lag ignored,
and 0 of 41 at 500 ms, past the cap.
Closes#35
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The client's side of a networked match, in src/net/:
- ClientGame takes the server's notices and snapshots, generates the island
from the seed and answers with commands. It works on packets, so it runs
over a NetClient or a test's simulated link.
- ClientClock decides which tick the next command is for, from the server's
echo of the newest command tick it has received, holding three commands
waiting at the server.
- ClientPrediction runs each command on a copy of the client's own player
with the server's movement code, and compares every snapshot with what it
predicted. A difference is replayed from the server's state and eased in.
- SnapshotInterpolator draws everyone else four ticks in the past, between
snapshots, on a clock steered gently by arrivals.
Snapshots now carry the client's own block: exact position and velocity,
the water around the player, stamina and state flags, so a prediction can
match the server to the bit. The command echo is now the newest tick
received rather than taken. Protocol version 2.
Snapshots go out every second tick. The interval was three ticks, which is
10 a second, not the 20 the documents claimed; 15 a second is the nearest
even spacing and what interpolation is tuned for.
Drop.ride() holds the barge ride for the server and the client alike, and
NetGame's joining, input and snapshot steps can be called without a socket.
Measured in test/net/test_prediction_link.gd over a simulated link with
100 ms each way, 20 ms jitter and 2% loss: no corrections to own movement
in about 1,400 snapshots per client, and the other player drawn 0.4 mm on
average from where a perfect link would draw them.
Closes#34
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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>
ENet over UDP, used directly through ENetConnection, with a handshake before a
connection counts as a player.
- NetProtocol: HELLO, WELCOME and REJECT layouts, the protocol version, name
cleaning, the reasons a connection ends and a sentence for the player about
each. Decoders return nothing for malformed input and never raise an error.
- NetServer: listens, takes each guest through the handshake, and reports
joined, left and refused. It refuses a different protocol version, a full
server, a malformed HELLO and a guest that stays silent, each with its own
reason. Handles are never reused; duplicate names get a number.
- NetClient: connects, introduces itself, and ends up joined or closed with a
reason. Leaving says goodbye so the server knows at once; a client that
vanishes is dropped by ENet's timeout.
- Tests run a real server and clients over loopback UDP, with bare ENet peers
sending malformed and random packets.
The headless server doesn't listen yet; N2 connects this to the match.
Closes#32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>