19. Network failures and recovery
Networks fail in many small ways: two browsers talk at once, a player's Wi-Fi drops, a laptop goes to sleep, a message arrives twice or too late, a server restarts. This chapter is a catalogue of such failures. For each one it says what the situation is, what the original NetWars did in the equivalent case, and what the protocol of chapter 18 does, step by step. Use it as a test plan: each scenario is something an implementation should survive on purpose.
The "Original" paragraphs describe NetWars 2.06 and carry evidence marks, as in the rest of this document: O observed in a recorded run or stated plainly by the code, D derived by reasoning from the code but not watched, H hypothesis, ? unknown. The "Protocol" paragraphs describe the design of chapter 18: a proposal, not something the original did. Timer values are those of chapter 18's "Timers and limits" table; a step is one simulation step (70 per second by default).
The scenarios
- Simultaneous connection attempts (glare)
- Two newcomers claim the same slot
- Partial mesh: A sees B, B sees C, A does not see C
- One-way loss: a peer that sends but does not receive
- A peer silently vanishes
- A peer reloads the page
- A reload while the service is down
- A duplicated tab
- Laptop sleep, mobile freeze, back/forward cache
- A connection breaks and is repaired
- The signalling service goes down and comes back
- The inviter leaves
- A late hit from a previous life
- A late satellite event after a new satellite exists
- Duplicated and reordered messages
- Congestion
- Very high latency
- No direct path and no TURN relay
- A hidden or background tab
- Clock drift and slow devices
- Version or settings mismatch
- A cheating or broken peer
1. Simultaneous connection attempts (glare)
Situation. Two browsers each send the other an offer at the same moment: two newcomers find each other at once, or both start a repair. Without a rule, both reject the other's offer, or the connection ends in a confused state.
Original. Cannot happen: there are no connections and no handshake. Each computer opens its
sockets and starts broadcasting on its own O
(src/net.c, net_start_session).
Protocol.
- At the start, only the newcomer offers; the page already present creates its connection and channels only when the newcomer's first offer arrives, before applying it. Repairs are started by the impolite side (smaller peer id) only; the polite side starts one only as a fallback after 5 s.
- If two offers still cross, perfect negotiation decides: the polite peer (larger id) applies the incoming offer (its own is rolled back) and answers; the impolite peer ignores the incoming offer and waits for the answer to its own.
- The connection comes up once, with one pair of data channels: both sides create them with
negotiated: trueand fixed ids, so no extra channels appear. - An offer that gets no answer for 10 s is rolled back and the attempt counts as failed; the meshing-again rule tries later.
2. Two newcomers claim the same slot
Situation. Two people open the invitation at the same time and both press Enter on PLAYER 3, which both see as Free.
Original. Both become PLAYER 3 if they press Enter before either one's first packet
reaches the other D. Neither notices (a player never listens to its own
slot's channel); the others show one ship, name and score that jump between the two, and a hit on slot
3 is applied by both (chapter 8). There is a second way in: when the lobby opens, every slot's
"heard" counter is 0, and in each lobby frame the Enter test runs before
net_lobby_age_slots updates the counters, so an Enter typed ahead can take a slot
somebody is using D (src/players.c
lobby_select_slot, src/net.c net_open).
Protocol.
- Both pages send
claim(2). The service handles claims one at a time: the first finds the slot free (gen + 1, grant number + 1,claimed, roster to all), the second finds it held (denied taken) and stays in the lobby. - Even a buggy client acting as holder anyway is not shown: peers accept STATE for slot 2 only from the peer id and gen in their roster.
- While the service is unreachable, no slot changes hands at all; both wait.
3. Partial mesh: A sees B, B sees C, A does not see C
Situation. Three players. A–B and B–C work, but A and C cannot reach each other (their networks block it and there is no TURN relay, or the relay failed).
Original. On one LAN every broadcast reaches every machine, so this needs a broken network. If A does not hear C, A's liveness counter for C reaches 0 after 4 frames and A plays as if C had left; C does the same with A; hits between them never arrive; B sees everyone; nothing ever corrects it D.
Protocol. Every two players must have a live link; when pairs have had none for 20 s while both sides are demonstrably present, the service revokes the holder that is in the most broken pairs (on a tie, the newer one).
- While the link is missing, A does not show C and C does not show A; B shows both. Both A and C keep trying to connect (meshing again: 2, 4, 8 … 60 s) and report their live links to the service.
- The pair is down while either side's report leaves the other out. The service judges a pair
only with fresh reports from both (each page sends one right after
welcomeorresumed, and every 10 s), never while it is recovering. It starts counting no earlier than the roster that first listed both as holders, and counts only while both are present (live WebSocket, or another player reports a live link to it). - If the link comes up, the count starts again from 0.
- After 20 s down (longer than a 10 s negotiation timeout plus the first retry), A and C are each in
one broken pair: a tie, so the newer grant loses. The service sends C (grant 6, newer than A's 4)
revoked(unreachable, partner A)and frees slot 2. C sends BYE (reason 4) and returns to the lobby with "Could not connect to A". For 60 s, while A is present, C's claims are refused (denied unreachable); it may spectate. - B sees C leave like any other player. The game goes on with A and B.
- If the older partner is the broken one (A's computer died silently): A is not present for long (its WebSocket times out after 25 s, and nobody reports a live link to it), so C is never revoked because of A. A's slot is reserved for 60 s, then freed.
- If the older partner lost every link but kept its WebSocket (its connections broke, the service still hears it): A–B and A–C are down, B–C is up. A is in two broken pairs, B and C in one each, so A is revoked and B and C play on. Revoking only by "newer grant" would have removed both healthy players and left A alone.
- A page that is away (hidden tab) is reported as live by its partners for up to 10 minutes after its last away message, so a throttled, silent away tab does not make pairs "down".
- While the service is unreachable nobody is revoked; the game goes on with the missing link.
- A spectator with no link to some player shows "no connection" for that slot; nothing else happens.
Why not relay C's messages through B? It would make B a server for two others, double its upload, and add a hop of delay to every hit between A and C. A player who cannot reach one partner usually cannot reach anyone (a blocking network), and a TURN relay fixes that far better (scenario 18).
4. One-way loss: a peer that sends but does not receive
Situation. A hears B, but nothing from A reaches B (a firewall rule, a broken relay direction).
Original. B drops A after 4 frames and stops waiting for it; A keeps showing B and waits for it normally. B's hits on A arrive; A's hits on B never do D.
Protocol.
- B: nothing from A for 1 s, so the link is not live; A's ship is hidden on B's screen.
- A: B's messages still arrive, but no PONG answers A's PINGs. After 3 s without a PONG, A treats the link as not live too. The pair is now down on both sides, symmetric.
- Both report it; scenario 3 decides after 20 s if it lasts.
- The browser's own check of the path (ICE "consent", renewed every few seconds) fails after about 30 s without answers and the connection becomes "failed"; the repair rules take over.
5. A peer silently vanishes
Situation. A player's computer loses power, its cable is pulled, or the browser crashes. No goodbye is sent.
Original. Every other machine waits up to 5 timer ticks (about 275 ms) per frame for the missing packet, 4 frames in a row: about 1.1 s of slow motion for everyone. Then the player is inactive: its ship, shot copies and satellite copy disappear O (run #24). If its last packet carried a hit, the hit is applied again every frame while it stays silent: 20 shields gone in about 20 frames in a test, and a dead victim's countdown restarted every frame O. Its satellite copy can be collected on each held frame D. In the lobby its slot shows "Free" about half a second after the last packet D.
Protocol.
- Nobody slows down: steps never wait for peers. Its ship is extrapolated for at most 4 steps, then held.
- After 1 s without a message (3 s without a PONG) the link is not live: ship, shot copies and satellite copy hidden; STATE to it stops.
- Its last HIT was applied once (event number); nothing repeats.
- The connection's ICE state goes "disconnected", then "failed"; repairs run without success, then meshing again keeps trying at growing intervals while the service still lists it.
- The service: a crashed browser's WebSocket closes at once; a pulled cable is noticed after 25 s
of silence. Then
member left, the slot reserved for 60 s ("reconnecting"), then Free. - Back within that time (a short outage): its link becomes live with its next message and its ship reappears; life, score and slot unchanged.
6. A peer reloads the page
Situation. A player presses F5 in the middle of a game.
Original. The nearest case is quitting and restarting the program: the others behave as in scenario 5; the returning player goes through the title screen and the lobby; its old slot is Free about half a second after its last packet; joining resets its score to 0 D.
Protocol.
- On
pagehidethe page tries to send BYE (reason 0); nothing depends on it. - Its connections close; the others remove its ship at once.
- The service sees the WebSocket close without
releaseand reserves the slot for the tab's session id for 60 s. - The new page reads session id, room, slot, gen, grant, roster version, score and name from
sessionStorageand joins withresume {…, reload: true}. - The service answers
resumed okwith a new peer id, the same slot and gen + 1, and sends the roster to all. - The others accept STATE for that slot only from the new peer id. A HIT on its way to the old peer id is lost; one addressed to the old id is ignored by the new page.
- The new page connects to everyone as a newcomer, starts at life 1 on the name screen, and sends its restored score (scores are self-reported, as in the original).
- More than 60 s later:
resumed ok: false, expired; the page is in the lobby and may claim a Free slot.
7. A reload while the service is down
Situation. As scenario 6, but the service is unreachable at that moment.
Original. No service exists O; see scenario 6.
Protocol.
- The old connections close; the others remove that ship at once. Their frozen roster still lists the old peer id for the slot, so nobody else can take it.
- The new page cannot join; it shows "Connecting…" and retries (1, 2, 4, 8, 15, 15 … s).
- The service comes back. If it kept its state and the reservation is still running, or if it
restarted empty and is recovering: the resume with
reload: truegives a new peer id, the same slot and gen + 1, and the page reconnects to everyone. (A service that was unreachable but kept running restarts its reservation timers when pages can reach it again, so its own outage does not eat the 60 s.) - If the reservation has expired and someone else took the slot:
resumed ok: false, expired; lobby.
8. A duplicated tab
Situation. A player uses "Duplicate tab". The browser copies sessionStorage, so the
new tab has the same session id and believes it holds the same slot.
Original. Not applicable: a DOS computer runs one copy.
Protocol.
- Each page holds the Web Lock
"netwars:" + session idwhile it lives. The duplicate cannot get it, so it creates a new session id, forgets the copied slot, and joins as a new member in the lobby. - Second line of defence: the service refuses a join whose session id belongs to a page with a live
WebSocket (
error session-in-use); the page then does the same. - The original tab is not disturbed.
9. Laptop sleep, mobile freeze, back/forward cache
Situation. The lid is closed, the phone locks, or the player navigates away and comes back with the Back button. The page is frozen for seconds or hours and then resumes as if nothing happened; its connections may be long dead.
Original. Not applicable. The nearest case is a machine that stops: scenario 5 O.
Protocol.
- While frozen, the others see scenario 5: hidden after 1 s, removed by the service after 25 s, slot reserved for 60 s.
- On resume (
visibilitychange,pageshowwithpersistedtrue, or simply aperformance.now()jump), if more than 5 s passed, the page does not trust anything: it closes all connections and its WebSocket and joins again withresume {…, reload: true}, exactly as after a reload (scenario 6). - If less than 5 s passed it continues; the repair rules handle what broke.
10. A connection breaks and is repaired
Situation. A laptop moves from Wi-Fi to a phone hotspot, or a router changes its public address. The connection object still exists, its network path is gone.
Original. IPX has no connections. When packets arrive again, the first one sets the player's
liveness counter back to 4 at once O (net_sync_frame).
Protocol.
- No messages: after 1 s the link is not live (ship hidden).
- "disconnected" for 2 s, or "failed": the impolite side calls
restartIce(); the polite side does so only if no offer came within 5 s. The offer travels through the service. - The data channels survive the restart. Reliable events queued during the gap arrive late: HITs whose excess delay is over 1 s are dropped by the victim; SATs are checked by satellite id and stay correct however late they are. STATEs sent during the gap are simply lost.
- First message after the restart: the link is live again; the ship reappears with the next STATE.
- The same network change often leaves the page's WebSocket half-open: the page notices within
15 s (no answer to its ping), reconnects and sends
joinwith aresumenaming its current peer id. The service lets that resume take the session over and closes the old socket, even though it has not yet timed it out; the page keeps its peer id, slot and gen. - 3 restarts within 30 s without success: close the connection. Meshing again then never stops while the service lists both: the smaller peer id offers on a new connection after 2 s, 4 s, 8 s … up to 60 s between attempts. A new link sends a new HELLO; event and step counters continue, so nothing is applied twice.
- While the service is unreachable no offer can be carried; the repair waits for it.
11. The signalling service goes down and comes back
Situation. The service restarts (an update) or is unreachable for a minute.
Original. There is no service O. (In our test setup one DOSBox-X emulator relays the emulated network; closing it cuts everyone off. That is the emulator's tunnel, not the game: chapter 8.)
Protocol.
- Each page's WebSocket closes, or the page notices that the service stopped answering (no answer for 5 s after a ping, so within 15 s). Pages retry after 1, 2, 4, 8, 15, 15 … s, each ±20 % random, so they do not all return at once.
- Play continues on the existing connections: STATE, HIT, SAT and PING never touch the service.
- The roster is frozen. No slot changes hands: spectators and lobby pages wait, newcomers cannot join, broken connections cannot be repaired, nobody is revoked.
- The service is back. Each page joins with
resume {peer, role, slot, gen, grant, rosterV, reload: false}. - Each page sends its
linksright afterresumed, so the service never judges a pair without fresh reports. - If the service kept its state, it continues; it restarts its reservation timers.
- If it started empty, it is recovering for 45 s (detection within 15 s + the longest retry
gap of 18 s + margin): it accepts only joins with
resume(others:error recovering, retry later), so no new peer id can collide with one named in a resume; it adopts each resumed slot with its peer id, gen and grant; sets its grant counter above the largest reported grant and its roster version above the largest reported one; refuses claims and spectates (denied recovering); and does not apply the partial-mesh rule. Two resumes for the same slot: higher gen, then lower peer id wins. A loser that comes second getsresumed ok: false, conflict; a loser adopted first getsrevoked(conflict)when the winner arrives. Either goes to the lobby. - The
welcomeroster of a restarted service replaces each page's roster even though its version numbers may be lower than before. - During recovery a holder may be missing from the roster for a moment; peers keep accepting its STATE while their link to it is live and no roster names another holder of that slot.
- After 45 s, slots nobody resumed are Free. New TURN credentials come with
welcome. - Only one page loses the service (its own network path to the server broke, the mesh still works): the others report a live link to it, so the service counts it as present and its reservation does not run out; nobody can claim its slot. When it gets through again, its resume takes the session over (scenario 10).
12. The inviter leaves
Situation. The person who created the link closes the tab while the others play.
Original. Nothing special happens; nobody "started" the game D (chapter 8).
Protocol.
- The inviter is a member like any other: BYE,
release(or a dead WebSocket and a reservation), roster to all. Its ship disappears; the game goes on. - The room lives at the service while any page or reservation is in it; anyone with the link can still join.
- If everybody leaves, the room disappears. The link still works: the next page to open it creates the room again, with the settings in the link (or its defaults).
13. A late hit from a previous life
Situation. Bob's shot hits Alice. Before the report reaches her, she has died from another hit and started a new life, or the report is stuck for a second in a broken connection.
Original. A hit report names only the victim's slot, and whatever is in the receive buffer
is applied every frame, alive, dead or reborn O (src/net.c
net_sync_frame). With a silent shooter the same hit kept a dead victim's countdown at its
start, so the victim never got "Press ENTER to restart" O (run #24).
Protocol.
- Bob's HIT carries Alice's peer id and the life id he saw (3), and his step.
- Alice has respawned (life 4): 3 ≠ 4, ignored. Still in life 3 but dead: ignored.
- Excess delay over 1 s (later than Bob's fastest messages by more than a second): ignored. A constant delay does not count: if Bob's or Alice's connection is always slow, his hits still land, so lag never makes anyone invulnerable.
- Bob keeps his 50 points in every case: the shooter scores when he sees the hit, as in the original.
14. A late satellite event after a new satellite exists
Situation. Carol collected Alice's satellite; the report arrives late, or a second report about the same satellite arrives, after Alice already has a new satellite.
Original. The event names only the owner's slot, so it removes (or explodes) whatever satellite the owner has at that moment D. A stale event (collector silent, or on its name screen right after a pick-up) removes every new satellite in the frame it appears, so the owner has none; a stale "shot" event keeps it exploding for ever D. The collector may get the bonus on 1–2 frames, and on every frame while the owner is on its name screen O (run satrep; chapter 8, "Satellites between players").
Protocol.
- Alice's satellite 17 is in her STATE. Carol touches it: bonus at once, SAT (collected, 17) to Alice, (Alice, 17) into Carol's taken set, so she neither sees nor touches it again.
- Alice gets the SAT while her satellite is still 17: it is gone.
- At her next 128th step (1 to 128 steps later) Alice spawns satellite 18.
- A late or repeated SAT for 17 arrives: 17 ≠ 18, ignored. Satellite 18 stays.
- Carol sees 18 in Alice's STATE, drops 17 from taken, and may collect 18 like anyone.
- If Dan touched 17 in the same moment as Carol, both got the bonus (as in the original; chapter 18 explains the choice). Alice applied the first SAT and ignored the second.
15. Duplicated and reordered messages
Situation. The network delivers a message twice, or an older one after a newer one.
Original. Packets have no sequence numbers: a later-arriving older packet overwrites the newer state, and a duplicate repeats its hits D. On a 1993 LAN both were rare; re-reading the same buffered packet (scenario 5) was the common case.
Protocol.
- STATE travels unordered, so reordering is normal there: a STATE whose step is not greater than the last accepted step of its sender is dropped; a duplicate has the same step and is dropped too.
- Shot records are keyed by shot id: a repeat changes nothing, except that a later copy with the "exploded" bit sets the hit point of a copy created from an earlier record.
- "name has been killed" happens once per (sender, life); cloak may toggle freely.
- Events on
evarrive in order and once per connection; across connections the event number decides, checked on arrival (apply only if greater than the last one from that sender). - An event may arrive before or after the STATE of its step; no rule depends on that.
16. Congestion
Situation. A player's upload is slower than its traffic (a phone on a weak network, a video call in the background); messages pile up in the browser's send buffer and arrive later and later.
Original. A machine sends its state only if the previous send has finished
O (net_send_state_if_idle); otherwise that frame's packet, with any
hit or satellite event in it, is gone D. A receiver catches one packet per player
per frame; others arriving in that frame are lost D. The whole game slows to the
pace of the slowest machine O.
Protocol.
- Before each STATE to a link:
st.bufferedAmountover 1,024 bytes means skip this step for that link. Old state never queues; the receiver gets fewer, but fresh, states. Shot records go into the next 4 STATEs actually sent, so skipped steps do not lose them. - Events are never skipped.
ev.bufferedAmountover 65,536 bytes: the link is congested, no STATE until it is below 16,384. Congested for more than 5 s: close and repair (scenario 10). - The receiver processes everything that arrived since its last step; only the newest STATE counts.
- Nobody else slows down. The congested player's ship moves in jumps on the others' screens; after 1 s without anything it is hidden.
17. Very high latency
Situation. One player is far away or on a satellite link: a steady one-way delay of 1 s or more.
Original. Every frame waits at most 5 ticks for the packets; with a delay longer than that, the packets of this frame never arrive within the wait, the player keeps dropping to inactive and coming back with each late packet, and every frame is held for 275 ms D.
Protocol.
- Messages keep arriving steadily, so the link stays live. The step mapping's offset contains the delay; the far player is drawn about 1 s + D in the past.
- Its hits still land (a constant delay is not excess delay), and so do hits on it.
- Play gets unfair in the way chapter 13 describes: its victims are hit about a second after they reached cover on their own screens, and two players can both collect a satellite within that second. The page shows a warning next to a player whose round-trip time is over 300 ms.
- Spikes on top of the steady delay drop HITs whose excess delay is over 1 s.
18. No direct path and no TURN relay
Situation. Two browsers are behind routers or firewalls that do not let them reach each other directly (common in companies, schools, some mobile networks, and Wi-Fi with client isolation), and there is no working TURN relay.
Original. Not applicable: IPX runs on one local network and is not routed over the internet D.
Protocol.
- ICE tries every candidate pair and gives up: "failed". Repairs fail too; meshing again keeps trying at growing intervals.
- Between two players, scenario 3 decides after 20 s: the newer one goes to the lobby with "Could not connect to name"; the page adds "Your network may need a relay server".
- A newcomer that can reach nobody fails the same way against each player and is revoked.
- With TURN (credentials from
welcome), ICE finds a relayed path and the game works, at double cost on the relay. TURN over TLS on port 443 passes most strict firewalls; over such a TCP relay, states arrive in bursts after a lost packet, which interpolation absorbs.
19. A hidden or background tab
Situation. A player switches to another tab or minimises the browser. Hidden pages get no animation frames and slow timers (about once a second; in some browsers once a minute after several minutes).
Original. Not applicable (DOS runs one program). The nearest case: a machine that falls behind slows the whole game to its pace O (chapter 8).
Protocol (the steps of a hidden page cannot be relied on, so it leaves the flight on purpose):
- On
visibilitychangeto hidden, a player in flight goes to status 2 (not in play), its satellite becomes kind 0, the away flag is set, and one STATE says so. Unlike the original's Esc, which zeroes the score (src/main.c), the score is kept. - Away, it ignores HIT (its ship is hidden, so none should come). The original's name screen does
apply hits (it calls
net_sync_frame, src/namentry.c) O. - It keeps sending PING with the away flag from its timer and answering PINGs in its message handler. The others treat an away PING as status 2 even if the STATE was lost, and allow 10 s between its messages.
- If the browser throttles harder and it is silent for more than 10 s, the others treat it as vanished in the game (hidden), but they keep reporting it as live to the service for up to 10 minutes, so it is not revoked; the service keeps its slot while its WebSocket lives.
- Visible again: name screen; Enter starts a new life (life + 1). If more than 5 s passed while it was frozen, scenario 9 applies.
How strongly each browser throttles a hidden page that holds WebRTC connections differs between browsers and versions; measure it in the browsers you support ?.
20. Clock drift and slow devices
Situation. Real computer clocks differ by 10–100 parts per million, and a weak device may not manage 70 steps per second (it runs at, say, 90 %).
Original. No clock in multiplayer: every frame waits for the retrace and for the other players, so the game runs at the pace of the slowest machine and its monitor; about 70 frames per second in our recordings O.
Protocol.
- Each page steps by its own clock. 100 ppm at 70 steps per second is 25 steps per hour. A constant offset alone would let the drawn position creep away from the newest state and jump back (a sawtooth); the step mapping fits the sender's rate over the last 10 s instead, so drift and slow devices are followed smoothly.
- A device that cannot keep up runs at most 5 steps per animation frame and drops the rest: its world runs slower than real time and its ship moves slower on everybody's screen. Nobody else is affected.
- When a sender's fitted rate is below 0.95 of the room rate for 10 s, the others show "name's game is running slowly" next to the name. Nothing else happens.
- A step jump of more than 35 against the estimate (the device froze) restarts the fit.
21. Version or settings mismatch
Situation. One player has an old copy of the page cached, or opened the link with different settings.
Original. No version field: any 160-byte packet on a game socket is accepted and copied into the game's records O (docs/network-protocol.md).
Protocol.
- At
jointhe service compares protocol major version and settings (preset, step period, rules hash) with the room's:error versionorerror settings. The page says "Reload the page to get the current version" or "This room plays with other settings". - If a page got through anyway, HELLO refuses the link: BYE reason 3, close, the same message.
- Different minor versions play together; each side ignores message types and trailing bytes it does not know, and rule options at their default do not enter the rules hash.
22. A cheating or broken peer
Situation. A modified page claims hits it never made, teleports or gives itself points, or a buggy page sends garbage.
Original. Everyone trusts everyone: any machine may claim any hit, score, status or name, and
nothing is checked O (no validation in net_sync_frame or the receive
path).
Protocol. Without a game server nobody can prove a cheat; each page can only refuse what is clearly impossible, with tolerances wide enough that an honest player with a poor connection is never punished. Numbers used: L = rtt in steps + D + 2 (how far apart in time the two views of one moment can be); 288 world units per step = the fastest ship (throttle 144, doubled by extra thrust); 64 = the collision push; 400 = 288 + 64 + margin.
| Message | Check (by the receiver) | On failure |
|---|---|---|
| any | known length; slot 0..3; n ≤ 8; at most 200 st and 100 ev
messages per second (sliding 1 s) | drop and log, 1 strike |
| STATE | each axis 16,384 long ± 5 %; axes perpendicular (each dot product below 5 % of 16,384²) | drop, 1 strike |
| STATE | speed |velocity| ≤ 400 world units per step; within one life, the position moves at most 400 × steps elapsed + 64 | keep the previous position, 1 strike |
| STATE | score = previous + 50·k (k ≥ 0), counting the wrap above 1,000,000 (subtract
1,000,000; exactly 1,000,000 is kept, src/screens.c add_score), with k at most the shots
the sender fired since then + 8; or 0 after the sender was in status 2 (a new join, or an original-style
Esc) | show the last plausible score, 1 strike |
| shot record | at most 8 live shots per sender; |velocity − 1,024 × (a unit vector)| ≤ 400, i.e. its length between 624 and 1,424 world units per step | ignore the record, 1 strike |
| HIT | its step lies within the shot's 24 flying steps; the shot copy's position at that step comes within (L × 288 + 1,024) world units of my own ship at some step of my history between the mapped step − L and + 2; at most one HIT per shot id | ignore and log, 1 strike |
| SAT collected | the sender's ship as I drew it came within (L × 288 + 1,024) of the satellite in that window | still remove the satellite (it costs nothing), 1 strike |
- Strikes are counted per sender over a sliding 60 s. 10 strikes: the page mutes that sender: its HIT and SAT messages are ignored (and logged) until its slot changes hands; a mark is shown next to its name; its ship is still drawn.
- No strikes for anything arriving in the first 2 s after a link became live again (bursts after a repair or through a TCP relay). A HIT whose shot record I never saw is applied without the distance check (all 4 records may have been lost); only if more than half of at least 10 HITs from a sender in 60 s lack records does each further one count a strike.
- Reliable events are never dropped silently: every ignored HIT or SAT is logged with its reason.
- Muting is local: each page decides for itself. The service runs no game logic and cannot judge; a room that wants to be rid of someone needs a new link.
- Clever cheats (aiming help, faked delay) cannot be caught this way. A game that must be fair among strangers needs a server that runs the simulation: a different design.
Each scenario can be produced on one computer: several tabs, a small layer between the game and its data channels that can delay, drop, duplicate and reorder messages per direction and cut single links, and a local copy of the service with switches for "unreachable" and "restart empty". Write one automated test per scenario that checks its "Protocol" steps: for example scenario 13 sends a HIT with the previous life id and checks that the shields do not change; scenario 3 cuts the A–C link and checks that C, and not A, is in the lobby after 20 s; the same test with A's tab killed checks that C stays, and one that cuts both of A's links checks that A, not B or C, is revoked.