X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnet%2FPacket.hpp;h=7b9b69e447289efbd2831503f5e3ea2689ce64e4;hb=933ca0fe6c660e482edd45742d981f2de59a32df;hp=b32b42b5bceee10c901d8335426bb971b81c5746;hpb=c1da86ebab41895bf49ed747c75ecf722e8c5586;p=blank.git diff --git a/src/net/Packet.hpp b/src/net/Packet.hpp index b32b42b..7b9b69e 100644 --- a/src/net/Packet.hpp +++ b/src/net/Packet.hpp @@ -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 PayloadType As() {