Expand description
Game-state synchronisation: snapshots, delta encoding, client-side prediction, lag compensation, and network clock synchronisation.
§Design
The server produces a GameStateSnapshot every server tick. Only
changed entities are shipped as DeltaSnapshot to save bandwidth.
Clients buffer recent snapshots in a SnapshotBuffer and use a
StateInterpolator to render smoothly between them.
ClientPrediction applies local inputs immediately and reconciles when
the authoritative state arrives. LagCompensation lets the server rewind
its history to the client’s perceived point in time for fair hit detection.
Structs§
- Client
Prediction - Client-side movement prediction with server reconciliation.
- Delta
Snapshot - Compact diff between two
GameStateSnapshotvalues. - Entity
Delta - Per-field diff for one entity between two consecutive snapshots.
- Entity
Snapshot - Complete state of one entity at a specific server tick.
- Game
State Snapshot - Authoritative game state for one server tick, ready to be diffed or sent.
- Input
Buffer - Holds un-acknowledged player inputs for prediction reconciliation.
- LagCompensation
- Server-side lag compensation: rewinds game state to a client’s perceived point in time for accurate hit registration.
- Network
Clock - NTP-style network clock: estimates server time from ping round-trips.
- Player
Input - One frame of local player input.
- Snapshot
Buffer - Ring buffer of recent game-state snapshots.
- State
Interpolator - Smoothly interpolates entity positions between buffered snapshots.
- Vec2
- 2D vector used for movement directions.
- Vec3
- 3D vector used for positions, velocities, and rotations.
Enums§
- Authority
Model - Which peer has authoritative control over a given entity or subsystem.