group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
InputRingBuffer.hpp File Reference

Per-tick history of stamped input snapshots, keyed by clientPredictTick. More...

#include "ecs/components/InputSnapshot.hpp"
#include <array>
#include <cstddef>
#include <cstdint>
Include dependency graph for InputRingBuffer.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  InputRingBuffer
struct  InputRingBuffer::Entry

Detailed Description

Per-tick history of stamped input snapshots, keyed by clientPredictTick.

Phase 5b uses this to replay inputs during reconciliation. When a server snapshot arrives ack'ing client-tick T, we know the server's authoritative state at tick T. We snap the local player to that state and replay every stored input from tick T+1 up through the current predict tick — feeding each one into runMovement + runCollision — landing on the correct predicted state for the current tick.

Capacity: 256 entries ≈ 2 s of input history at 128 Hz physics. Far more than typical RTT (10–200 ms = 1–26 ticks); the slack absorbs spikes.

Ring writes are O(1); lookup by tick is O(N) but N is bounded at 256 and the access pattern is "find the most recent entry with tick ≥ T", which usually walks just a handful of slots.