Skip to main content

Module sync

Module sync 

Source
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§

ClientPrediction
Client-side movement prediction with server reconciliation.
DeltaSnapshot
Compact diff between two GameStateSnapshot values.
EntityDelta
Per-field diff for one entity between two consecutive snapshots.
EntitySnapshot
Complete state of one entity at a specific server tick.
GameStateSnapshot
Authoritative game state for one server tick, ready to be diffed or sent.
InputBuffer
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.
NetworkClock
NTP-style network clock: estimates server time from ping round-trips.
PlayerInput
One frame of local player input.
SnapshotBuffer
Ring buffer of recent game-state snapshots.
StateInterpolator
Smoothly interpolates entity positions between buffered snapshots.
Vec2
2D vector used for movement directions.
Vec3
3D vector used for positions, velocities, and rotations.

Enums§

AuthorityModel
Which peer has authoritative control over a given entity or subsystem.