13 std::deque<Moment>& moments = moments_[id];
14 moments.push_back({.time = time, .place = place});
15 while (moments.front().time < time -
kKept) {
21 std::chrono::nanoseconds time)
const {
22 const auto found = moments_.find(
id);
23 if (found == moments_.end()) {
26 const std::deque<Moment>& moments = found->second;
28 const auto after = std::ranges::upper_bound(moments, time, {}, &Moment::time);
29 if (after == moments.begin()) {
30 return moments.front().place;
32 if (after == moments.end()) {
33 return moments.back().place;
35 const Moment& from = *std::prev(after);
36 const float share = std::chrono::duration<float>(time - from.time) /
37 std::chrono::duration<float>(after->time - from.time);
38 return Place{.x = from.place.
x + (after->place.x - from.place.
x) * share,
39 .z = from.place.
z + (after->place.z - from.place.
z) * share};
std::optional< Place > At(uint32_t id, std::chrono::nanoseconds time) const
static constexpr std::chrono::seconds kKept
A second: more than any blow goes back.
void Record(uint32_t id, std::chrono::nanoseconds time, Place place)
void Leave(uint32_t id)
Forgets a player who's left.