]> git.localhorst.tv Git - blank.git/blobdiff - src/net/Packet.hpp
exchange block updates with clients
[blank.git] / src / net / Packet.hpp
index b32b42b5bceee10c901d8335426bb971b81c5746..7b9b69e447289efbd2831503f5e3ea2689ce64e4 100644 (file)
@@ -10,6 +10,7 @@
 
 namespace blank {
 
+class Block;
 class Entity;
 class EntityState;
 
@@ -197,6 +198,26 @@ struct Packet {
                void ReadData(std::uint8_t *, std::size_t maxlen) const noexcept;
        };
 
+       struct BlockUpdate : public Payload {
+               static constexpr std::uint8_t TYPE = 11;
+               static constexpr std::size_t MAX_LEN = 484;
+
+               static constexpr std::uint32_t MAX_BLOCKS = 78;
+               static constexpr std::size_t GetSize(std::uint32_t num) noexcept {
+                       return 16 + (num * 6);
+               }
+
+               void WriteChunkCoords(const glm::ivec3 &) noexcept;
+               void ReadChunkCoords(glm::ivec3 &) const noexcept;
+               void WriteBlockCount(std::uint32_t) noexcept;
+               void ReadBlockCount(std::uint32_t &) const noexcept;
+
+               void WriteIndex(std::uint16_t, std::uint32_t) noexcept;
+               void ReadIndex(std::uint16_t &, std::uint32_t) const noexcept;
+               void WriteBlock(const Block &, std::uint32_t) noexcept;
+               void ReadBlock(Block &, std::uint32_t) const noexcept;
+       };
+
 
        template<class PayloadType>
        PayloadType As() {