4#include <aegis2d/net/packet.hpp>
31inline constexpr std::uint32_t
no_entity = 0xFFFFFFFF;
64 std::optional<std::uint16_t>
input;
134[[nodiscard]] std::optional<Snapshot>
read_snapshot(std::span<const std::byte> payload);
Compact encoders of snapshot fields: fixed-point positions, integer velocities and varint ids,...
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
std::size_t entity_record_bits(std::uint32_t id_gap) noexcept
Size of an entity record.
std::optional< Snapshot > read_snapshot(std::span< const std::byte > payload)
Decodes the payload of one Snapshot datagram.
constexpr unsigned id_high_bits
High bits of a network id, sent as they are: the generation of Entity handles.
Definition snapshot.hpp:39
constexpr std::uint32_t short_id_gap
Largest gap between the low bits of two records' ids that keeps a record within 10 bytes (77 bits).
Definition snapshot.hpp:50
constexpr std::uint32_t no_entity
Network id that names no entity, for a player out of lives.
Definition snapshot.hpp:31
constexpr unsigned position_bits
Bits of a position, sign included.
Definition compact.hpp:16
constexpr unsigned varint_group_bits
Bits of each group of a varint, followed by one continuation bit.
Definition compact.hpp:39
constexpr std::size_t snapshot_fixed_bits
Bits of the tick, the player count and the entity count of a snapshot payload.
Definition snapshot.hpp:34
EntityKind
Kind of an entity in snapshots and events (RFC section 4.1).
Definition snapshot.hpp:19
@ PlayerShip
A player's ship.
@ EnemyMissile
A missile fired by an enemy.
@ BydosSlave
A Bydos slave.
@ PlayerMissile
A missile fired by a player.
std::vector< std::vector< std::byte > > write_snapshot(const Snapshot &snapshot)
Encodes a snapshot as the payloads of Snapshot datagrams, header excluded.
constexpr unsigned id_low_bits
Low bits of a network id, sent as their gap to those of the previous record: the index of the engine'...
Definition snapshot.hpp:37
constexpr unsigned frame_bits
Bits of the frame of an entity record: frames above 15 are sent as 15.
Definition snapshot.hpp:43
constexpr std::size_t entity_record_fixed_bits
Bits of an entity record besides the gap of its id's low bits: the id's high bits,...
Definition snapshot.hpp:46
constexpr unsigned kind_bits
Bits of the kind of an entity record: kinds 0 to 7.
Definition snapshot.hpp:41
constexpr unsigned velocity_bits
Bits of a velocity, sign included; velocities are sent in whole pixels per second.
Definition compact.hpp:29
What a snapshot says of an entity.
Definition snapshot.hpp:72
float x
Position of its center, in logical pixels.
Definition snapshot.hpp:78
float vx
Velocity, in logical pixels per second.
Definition snapshot.hpp:82
float y
Position of its center, in logical pixels.
Definition snapshot.hpp:80
float vy
Velocity, in logical pixels per second.
Definition snapshot.hpp:84
std::uint8_t frame
Frame of its sprite sheet to show.
Definition snapshot.hpp:86
bool operator==(const EntityRecord &) const =default
Field-by-field equality.
std::uint8_t kind
Kind, an EntityKind value (others are reserved).
Definition snapshot.hpp:76
What a snapshot says of a player.
Definition snapshot.hpp:53
std::optional< std::uint16_t > input
Sequence of the last Input of the player the server applied (InputRecord), or nothing before the firs...
Definition snapshot.hpp:64
bool operator==(const PlayerRecord &) const =default
Field-by-field equality.
std::uint32_t ship
Network id of its ship, or no_entity once out of lives.
Definition snapshot.hpp:57
std::uint8_t lives
Lives left.
Definition snapshot.hpp:59
std::uint8_t player
Player number, 0 to 3.
Definition snapshot.hpp:55
std::uint32_t score
Score.
Definition snapshot.hpp:61
The state of the world at one tick.
Definition snapshot.hpp:94
std::uint32_t tick
Server tick of the state.
Definition snapshot.hpp:96
bool operator==(const Snapshot &) const =default
Field-by-field equality.
std::vector< EntityRecord > entities
Every replicated entity of the world.
Definition snapshot.hpp:100
std::vector< PlayerRecord > players
Every player of the game.
Definition snapshot.hpp:98
Gameplay values of R-Type: play area, speeds, sizes, health, lives and scores.