Synvael/docs/adr/0004-server-authoritative-simulation.md
Serkyo cae434d227
Some checks are pending
CI / Rust Check & Lint (push) Waiting to run
CI / Rust Tests (push) Waiting to run
CI / Lua Lint & Format (push) Waiting to run
CI / LFS Pointer Guard (push) Waiting to run
docs(workspace): rewrite the subsystem notes and ADRs
2026-08-06 22:52:57 +02:00

2.1 KiB

0004. Server-authoritative simulation

  • Status: Accepted
  • Date: 2026-06-27

Context

The game supports both single-player and multiplayer through a single dedicated server crate. Single-player literally just runs the server logic locally rather than using a separate offline path. Because of this, the networked simulation has to clearly define where authority lives and how strictly deterministic the simulation needs to be.

One option is full simulation determinism (using lockstep, rollback, or replay-from-inputs). This allows clients to advance the simulation in perfect agreement by only exchanging inputs. While powerful, it imposes a massive, ongoing maintenance cost: every single float, every hash-map iteration, and all platform-specific math would have to be perfectly cross-platform reproducible forever.

Decision

The simulation is strictly server-authoritative. The server computes the absolute truth; clients simply send their inputs and receive state snapshots in return. Clients predict locally to stay responsive, and reconcile when they disagree with the server. Combat, physics, mob AI, and item drops are all computed exactly once, exclusively on the server.

Full simulation determinism (lockstep, rollback, or replay-from-inputs) is an explicit non-goal. Outside of worldgen (which has its own strict rules in ADR-0003), you are free to use floats, hash-map iteration, and platform-specific math.

Consequences

  • The engine avoids the massive ongoing cost of cross-platform float reproducibility for the main simulation. Only worldgen carries that specific burden.
  • Clients have to implement prediction and reconciliation logic to actually feel responsive while playing against an authoritative server.
  • We get cheat resistance practically for free since authority strictly resides on the server.
  • Any features that would inherently require deterministic replay of the full simulation are completely out of scope due to this decision. If we ever want to revisit them, we would have to accept the determinism cost we are deliberately avoiding here.