R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
delta_snapshot.hpp File Reference

Snapshots encoded against a baseline the client acknowledged: only what changed. More...

#include <rtype/snapshot.hpp>
#include <cstddef>
#include <cstdint>
#include <optional>
#include <span>
#include <vector>

Go to the source code of this file.

Classes

struct  rtype::EntityDelta
 What a delta snapshot says of one entity. More...
 
struct  rtype::DeltaSnapshot
 One payload of a snapshot encoded against a baseline. More...
 

Namespaces

namespace  rtype
 R-Type game code, built on the Aegis2D engine.
 

Enumerations

enum class  rtype::EntityChange : std::uint8_t { rtype::Updated = 0 , rtype::Added = 1 , rtype::Removed = 2 }
 What a delta snapshot says of an entity. More...
 
enum class  rtype::EntityField : std::uint8_t { rtype::X = 1U << 0U , rtype::Y = 1U << 1U , rtype::Velocity = 1U << 2U , rtype::Frame = 1U << 3U }
 Fields of an EntityChange::Updated record, one bit each. More...
 

Functions

EntityRecord rtype::quantized (const EntityRecord &entity) noexcept
 A record as the client gets it: position and velocity rounded as compact.hpp does, frame at most 15.
 
std::vector< std::vector< std::byte > > rtype::write_delta_snapshot (const Snapshot &snapshot, const Snapshot *baseline)
 Encodes a snapshot against a baseline, as the payloads of Snapshot datagrams.
 
std::optional< DeltaSnapshot > rtype::read_delta_snapshot (std::span< const std::byte > payload)
 Decodes one payload written by write_delta_snapshot().
 
std::optional< Snapshot > rtype::apply_delta (const Snapshot *baseline, std::span< const DeltaSnapshot > parts)
 Rebuilds a snapshot from its baseline and every payload of its tick.
 

Variables

constexpr unsigned rtype::change_bits = 2
 Bits of the change of a delta record.
 
constexpr unsigned rtype::entity_field_bits = 4
 Bits of the fields of an EntityChange::Updated record.
 

Detailed Description

Snapshots encoded against a baseline the client acknowledged: only what changed.