Documentation
¶
Overview ¶
Package lagcomp implements server-side time rewind for client hit adjudication in authoritative-action multiplayer games.
The server keeps a fixed-size ring buffer of hurtbox snapshots, one per subtick. When a client reports a hit at their perceived time, the server rewinds to the client's RTT-corrected subtick and runs the hit trace against rewound state.
This is intentionally game-specific (sits under kit/game/) — outside networked authoritative-action games there is no analogue. The ring is fixed-capacity and zero-alloc on Push/At after construction.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attack ¶
type Attack struct {
Origin geometry.Vec3
Direction geometry.Vec3 // unit vector
Range float32
Width float32 // capsule/swept-sphere radius; 0 for ray test
}
Attack describes a single hit attempt to adjudicate.
type Ring ¶
type Ring[H any] struct { // contains filtered or unexported fields }
Ring is a fixed-size, allocation-free ring buffer of hurtbox snapshots. Sized for the rewind window the game needs (e.g. 30 snapshots at 60Hz = 500ms).
Not safe for concurrent access; the typical owner is the per-entity actor goroutine (see kit/actor).
func (*Ring[H]) At ¶
func (r *Ring[H]) At(sub SubtickIndex) (Snapshot[H], bool)
At returns the snapshot for the given subtick, or false if it has fallen out of the window.
func (*Ring[H]) Push ¶
Push writes a snapshot; the oldest entry is overwritten when the ring is full. Allocation-free.
type Snapshot ¶
type Snapshot[H any] struct { Subtick SubtickIndex At time.Time Hurtbox H }
Snapshot is one entry in the ring buffer: a snapshot of the entity's hurtbox state at a specific subtick.
type SubtickIndex ¶
type SubtickIndex uint64
SubtickIndex is a monotonically increasing subtick counter. The caller chooses tick rate (60Hz is a common default; the ring's window depends on size × tick interval).