From: Daniel Karbach Date: Tue, 22 Sep 2015 06:44:15 +0000 (+0200) Subject: fix EntityUpdate packet length X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=d635b2f08a2c3fe483d095dae04ad7ed5bd968d8;p=blank.git fix EntityUpdate packet length --- diff --git a/src/net/Packet.hpp b/src/net/Packet.hpp index 09db0df..e32621c 100644 --- a/src/net/Packet.hpp +++ b/src/net/Packet.hpp @@ -137,7 +137,7 @@ struct Packet { static constexpr std::uint32_t MAX_ENTITIES = 7; static constexpr std::size_t GetSize(std::uint32_t num) noexcept { - return 4 + (num * 64); + return 4 + (num * 68); } void WriteEntityCount(std::uint32_t) noexcept; diff --git a/src/net/net.cpp b/src/net/net.cpp index 0f8aa21..fa9c381 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -351,18 +351,19 @@ void Packet::EntityUpdate::ReadEntityCount(uint32_t &count) const noexcept { } void Packet::EntityUpdate::WriteEntity(const Entity &entity, uint32_t num) noexcept { - uint32_t off = 4 + (num * 64); + uint32_t off = GetSize(num);; Write(entity.ID(), off); Write(entity.GetState(), off + 4); } void Packet::EntityUpdate::ReadEntityID(uint32_t &id, uint32_t num) const noexcept { - Read(id, 4 + (num * 64)); + uint32_t off = GetSize(num);; + Read(id, off); } void Packet::EntityUpdate::ReadEntityState(EntityState &state, uint32_t num) const noexcept { - uint32_t off = 4 + (num * 64); + uint32_t off = GetSize(num);; Read(state, off + 4); }