|
group2 0.1.0
CSE 125 Group 2
|
Replay client-stored inputs to recover prediction after a server snapshot apply. More...
#include "InputRingBuffer.hpp"#include "ecs/components/InputSnapshot.hpp"#include "ecs/components/LocalPlayer.hpp"#include "ecs/physics/SweptCollision.hpp"#include "ecs/registry/Registry.hpp"#include "ecs/systems/CollisionSystem.hpp"#include "ecs/systems/MovementSystem.hpp"#include "systems/PredictionSystem.hpp"#include <SDL3/SDL_log.h>#include <cstdint>#include <entt/entt.hpp>Go to the source code of this file.
Namespaces | |
| namespace | systems |
| Client-only input sampling system — split into two halves so mouse look can run every iterate() (smooth camera at any FPS) while movement keys run once per physics tick group (server-consistent). | |
Functions | |
| void | systems::runReconciliation (Registry ®istry, const InputRingBuffer &ring, uint32_t ackedTick, uint32_t currentTick, float dt, const physics::WorldGeometry &world) |
| Replay stored inputs from ackedTick + 1 through currentTick on the local player, restoring its predicted state after a snapshot apply rewrote it to the server-authoritative value. | |
Replay client-stored inputs to recover prediction after a server snapshot apply.
Phase 5b: when an UPDATE_REGISTRY snapshot arrives, the local player's Position/Velocity/PlayerVisState/etc. get rewritten from the server's authoritative values. Those values represent the state at some past client tick T (the most-recently-server-acked input tick), not the current client predict tick. To get back to "where the client thinks we should be right now" we replay every input the client stored after T using the same MovementSystem + CollisionSystem the server runs — yielding a state consistent with the current input, just with any server-side correction (knockback, hit-stop, etc.) folded in along the way.
We always replay (no "compare-and-skip" fast path). The cost is ~RTT-in-ticks of runMovement calls per snapshot apply. At 50 ms RTT and 128 Hz physics that's ~6 ticks of work, and runMovement for just the local player on the client is microseconds. Cheap.