game/src/net/lagcomp.rs#
Source: lib/game/src/net/lagcomp.rs
lagcomp -- hits with lag compensation: the server keeps where the figures were over the last ticks and,
for a shot, puts them back to the time the shooter saw them, at most 300 ms back unless set (the interpolation's
100 ms and 200 ms beyond them, the user's decision of 2026-11-19)
view_time(tick, view, max_back) the shooter's view time from its input (NetInput::view: the lag of
its picture in 1/256 ticks), clamped to max_back ticks before tick
HitHistory the centres of the figures' hit volumes per tick (a ring); rewind(view time) blends the
two recorded ticks around it as a client blends two snapshots
hitscan a ray against the map (physics::World::ray_cast) and the rewound figures
(physics::query::ray against each capsule): the nearest hit, the shooter left out
What the client saw and what the server rewinds differ by the quantisation of the snapshots (under a
millimetre) and, when a figure turns within a snapshot's interval, by blending ticks one apart where
the client blended snapshots two apart (docs/NETCODE.md, "Treffer").
fn view_time(tick: u32, view: u16, max_back: u32) -> (u32, f64)the view time (a tick and the fraction towards the next) of an input oftickwhose picture laggedview/ 256 ticks, at mostmax_backticks backstruct HitHistorythe figures' hit volumes over the last ticks (see the module header)
impl HitHistory
fn new(cap: usize) -> HitHistoryremembercapticksfn record(&mut self, tick: u32, figures: &[(u16, Vec3)])where the figures (id, centre of the hit volume) are aftertick; ids ascendingfn span(&self) -> Option<(u32, u32)>the oldest and newest tick rememberedfn rewind(&self, tick: u32, frac: f64, out: &mut Vec<(u16, Vec3)>) -> boolthe figures at view time (tick, frac): blended between tick and tick + 1 where both have them, clamped to the ticks remembered; false when nothing is rememberedenum Hitwhat a shot hitFigure { id: u16, t: f64, point: Vec3 }-- a figure: its id, the distance along the ray and the pointWorld { t: f64, point: Vec3 }-- the map
fn hitscan(map: &physics::World, figures: &[(u16, Vec3)], shape: &Shape, shooter: u16, origin: Vec3, dir: Vec3, max_t: f64) -> Option<Hit>a ray fromoriginalongdir(unit length) up tomax_tagainst the map and the figures (shapeat each centre), the figureshooterleft out: the nearest hit