108 std::span<const DeltaSnapshot> parts);
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
EntityChange
What a delta snapshot says of an entity.
Definition delta_snapshot.hpp:16
@ Removed
In the baseline, gone since.
@ Added
Not in the baseline (or no baseline): every field is sent.
@ Updated
Some fields changed since the baseline; EntityDelta::fields says which.
std::optional< DeltaSnapshot > read_delta_snapshot(std::span< const std::byte > payload)
Decodes one payload written by write_delta_snapshot().
std::vector< std::vector< std::byte > > write_delta_snapshot(const Snapshot &snapshot, const Snapshot *baseline)
Encodes a snapshot against a baseline, as the payloads of Snapshot datagrams.
constexpr unsigned change_bits
Bits of the change of a delta record.
Definition delta_snapshot.hpp:38
constexpr unsigned entity_field_bits
Bits of the fields of an EntityChange::Updated record.
Definition delta_snapshot.hpp:40
std::optional< Snapshot > apply_delta(const Snapshot *baseline, std::span< const DeltaSnapshot > parts)
Rebuilds a snapshot from its baseline and every payload of its tick.
EntityRecord quantized(const EntityRecord &entity) noexcept
A record as the client gets it: position and velocity rounded as compact.hpp does,...
EntityField
Fields of an EntityChange::Updated record, one bit each.
Definition delta_snapshot.hpp:26
@ Velocity
vx and vy, together.
Snapshots of the world sent to the clients (RFC section 4.3).
One payload of a snapshot encoded against a baseline.
Definition delta_snapshot.hpp:57
std::optional< std::uint32_t > baseline
Tick of the baseline, or nothing for a full snapshot.
Definition delta_snapshot.hpp:61
bool operator==(const DeltaSnapshot &) const =default
Field-by-field equality.
std::uint32_t tick
Server tick of the state.
Definition delta_snapshot.hpp:59
std::vector< EntityDelta > entities
The entities added, changed or removed since the baseline.
Definition delta_snapshot.hpp:65
std::vector< PlayerRecord > players
Every player of the game, as in a full snapshot.
Definition delta_snapshot.hpp:63
What a delta snapshot says of one entity.
Definition delta_snapshot.hpp:43
EntityChange change
How it differs from the baseline.
Definition delta_snapshot.hpp:45
EntityRecord record
Its id, and the fields sent; the others are 0.
Definition delta_snapshot.hpp:49
bool operator==(const EntityDelta &) const =default
Field-by-field equality.
std::uint8_t fields
For EntityChange::Updated, the EntityField bits of the fields sent.
Definition delta_snapshot.hpp:47
What a snapshot says of an entity.
Definition snapshot.hpp:72
The state of the world at one tick.
Definition snapshot.hpp:94