#1 - quicr module

This commit is contained in:
Martin Slachta
2026-07-22 17:34:44 +02:00
parent a04f0dc262
commit f4174eb0c7
177 changed files with 5309 additions and 2265 deletions
@@ -9,8 +9,9 @@
* Wire format (all values little-endian):
*
* ┌──────────────────────────────────────────────────────────┐
* │ Header (12 bytes) │
* │ packet_type : uint32 (PacketType::WORLD_STATE = 3)
* │ Header (16 bytes) │
* │ message_type : uint32 (supplied by the caller)
* │ sequence : uint32 (always 0, no reply expected) │
* │ frame_idx : uint32 │
* │ entity_count : uint32 (number of position records) │
* ├──────────────────────────────────────────────────────────┤
@@ -66,12 +67,6 @@
namespace tw::serial {
// ── Packet type tag ───────────────────────────────────────────────────────
// Mirrors PacketType::WORLD_STATE_PACKET (value 3) in packets/Packet.hpp.
// Hardcoded here so the serialisation module does not depend on the network
// module — the numerical value must stay in sync if the enum changes.
inline constexpr uint32_t kWorldStatePacketType = 3; // WORLD_STATE_PACKET
// ──────────────────────────────────────────────────────────────────────────
// WorldStateWriter
// ──────────────────────────────────────────────────────────────────────────
@@ -87,14 +82,20 @@ public:
explicit WorldStateWriter(BinaryBuffer& buf) noexcept : m_w(buf) {}
/**
* Write the packet header. Call once per frame, before everything else.
* Write the header. Call once per frame, before everything else.
* entity_count is patched in end().
*
* message_type is supplied by the caller so that this module stays free of
* the address the message is delivered to.
*/
void begin(uint32_t frame_idx) noexcept {
void begin(uint32_t frame_idx, uint32_t message_type) noexcept {
m_entity_count = 0;
// packet_type — lets the receiver dispatch without peeking further
m_w.encode<uint32_t>(kWorldStatePacketType);
// message_type — lets the receiver dispatch without peeking further
m_w.encode<uint32_t>(message_type);
// sequence — this message is never a reply to a request
m_w.encode<uint32_t>(0);
// frame_idx
m_w.encode<uint32_t>(frame_idx);