From d635b2f08a2c3fe483d095dae04ad7ed5bd968d8 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 22 Sep 2015 08:44:15 +0200 Subject: [PATCH] fix EntityUpdate packet length --- src/net/Packet.hpp | 2 +- src/net/net.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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); } -- 2.39.2