executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
authoritative-serverExpert authoritative game server architecture — tick loop, world state, client input authority, rollback, lag compensation and connection handling for online games.
Independent GitHub snapshot · Automated classification · Original documentation governs
The server is the single source of truth. Clients only intend; the server decides. This skill covers the server tick loop, world-state serialization, input authority, reconciliation/rollback, lag compensation and session/connection management that make online games correct, cheat-resistant and smooth under real network loss.
client sends INPUT (intent) → net
server runs sim (authoritative) → sim decides
server sends SNAPSHOT (state) → net
client renders (interpolated) → visual
| Decided by | Where |
|---|---|
| Compile-time rules, rules engine (damage, physics) | server |
| Cosmetic-only (VFX transform, emote) | client |
| Compromise (authoritative with client prediction) | server + prediction |
Pick: full authoritative (server runs everything; client is dumb viewer) vs client-predicted (client predicts its own move; server reconciles) vs client-side prediction + server rollback (fast action games). All start from "server is truth".
sleep(frame): use deltaTime accumulation (see game-loop-and-timestep). Server ticks at exact fixed dt regardless of wall clock.// server main loop:
tick = 0;
while (running) {
dtFromWallClock = now - last;
accumulator += dtFromWallClock;
while (accumulator >= TICK_MS) {
SimulateTick(tick); // deterministic, fixed dt
accumulator -= TICK_MS;
tick++;
}
netOutputs[ticksToSend].Flush();
}
The server sim must be deterministic given a seed: lockstep (see game-engine/multiplayer-netcode determinism refs) so replay, spec or tests reproduce identically. No fast-math, no wall-clock, no rand() global.
client: sample input → serialized command {tick, seq, buttons, aim} → UDP
server: collect per-tick input, run queued commands, apply at tick boundary, optionally re-sim (rollback)
Key properties:
commandTick), not when it arrives.rollback-and-reconciliation.md).Server serializes deltas, not full state:
| Approach | Cost | Use |
|---|---|---|
| Full state | bloom | lobbies/tiny |
| Delta (since last ack) | efficient | standard |
| Interest-gated masks | minimal | open world (see interest-management skill) |
Snapshot minimal components:
matchId, tick, seq, per-entity: {entityId, flags, bits...}.Standard formats: UE replicas, OSSNet Snapshot = "columns of bytes" per entity with networked mask; netcode in game-engine/multiplayer skill.
Client predicts; server re-sims when input ran in the wrong order (delayed arrival). Server stores the last N-tick state frames; on late arrival re-runs tick with the corrected input:
server keeps history[40 ticks]
incoming input says "my tick 1000 shot"
if history[1000] exists → re-run 1000..now with that input
→ send diff to client (rollback) ≤ threshold
Server can't "aim at where client renders" — it rewinds to the client's requested timestamp to check the shot hit:
rewind to (arrivalTime - ping/2), run raycast vs stored poses.The criterion: a valid shot = the server re-sim with client's inputs would have produced a hit. This is authoritative but player-fair. Cheat-resistant because "position" is server-side truth, not client-reported.
UNRESPONSIVE → HANDSHAKE (challenge/response) → ESTABLISHED
→ RESYNC (after rejoin) → (periodic heartbeat) → TIMEDOUT (kicked)
nonce) — client signs → avoids spoofed connects.ping every ~1 s; server drops idle > 5–10 s (configurable).sessionToken; a client reconnecting with an old token resumes state (or is denied on match close).If a client drops in a rank/match, on return server either:
Pick 1 for most titles; 2 only for spectator/require.
| Attack | Server counter |
|---|---|
| Modded client teleport | server sim ignores client positions |
| Speed hack ("0 ping looks") | speed-check: max Δpos / tick |
| Input flood | cap commands/s + rate limit |
| Item duplication | every item change server-confirmed |
| Hit-scan "aim assist" | server ran the shot against stored poses |
Combined with validation hooks in anti-cheat-server.
| Per-player server budget | Target |
|---|---|
| CPU / tick | < 0.1 ms |
| Bandwidth out | ≤ ~60 kB/s (deltas) |
| Memory | ≤ 2 MB (state) |
| Tick compute | ~50–200 us/player typical |
Under load: more than 60 players/tick ● split world (zones/chunks) or shard (interest-management). If a tick > budget, drop non-crucial systems (network simulation throttle — not gameplay).
references/tick-loop.md — fixed timestep, accumulator, tick queue, determinism under loadreferences/world-state-snapshot.md — entity serialization, deltas, dirty flags, quantization, ack/gap detectionreferences/input-authority.md — input command flow, server queues, anti-abuse capsreferences/rollback-and-reconciliation.md — client prediction, server reconcile, rubber-banding, rollback replayreferences/lag-compensation.md — hit-scan rewinding, stored poses, fair-shot verificationreferences/connection-and-session.md — handshake, heartbeat, timeouts, resume, backfill