#1 - quicr module
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -117,8 +117,10 @@ void tw_serial_benchmark(std::vector<Position>& positions) {
|
||||
buf.reset();
|
||||
|
||||
tw::serial::BinaryWriter w(buf);
|
||||
// packet_type
|
||||
w.encode<uint32_t>(tw::serial::kWorldStatePacketType);
|
||||
// message_type — any value; only the size matters to the benchmark
|
||||
w.encode<uint32_t>(0u);
|
||||
// sequence — this message is never a reply to a request
|
||||
w.encode<uint32_t>(0u);
|
||||
// frame_idx
|
||||
w.encode<uint32_t>(static_cast<uint32_t>(frame));
|
||||
// entity_count placeholder
|
||||
|
||||
Reference in New Issue
Block a user