From 6d1038669a9a188015f7a19aed41084d8752891c Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sat, 20 Jan 2018 13:40:13 +0500 Subject: Fixed some UB detected by GCC UB-sanitizer --- src/GameState.cpp | 4 ++-- src/Section.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/GameState.cpp b/src/GameState.cpp index a2f7d87..de9f1d7 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -52,11 +52,11 @@ void GameState::UpdatePacket(std::shared_ptr ptr) case SpawnGlobalEntity: break; case SpawnMob: { - auto packet = std::static_pointer_cast(ptr); + auto packet = std::static_pointer_cast(ptr); Entity entity; entity.entityId = packet->EntityId; entity.pos = VectorF(packet->X, packet->Y, packet->Z); - entity.uuid = packet->ObjectUuid; + entity.uuid = packet->EntityUuid; entity.vel = Entity::DecodeVelocity(packet->VelocityX, packet->VelocityY, packet->VelocityZ); entity.yaw = packet->Yaw / 256.0; entity.pitch = packet->Pitch / 256.0; diff --git a/src/Section.cpp b/src/Section.cpp index 1083538..2f72411 100644 --- a/src/Section.cpp +++ b/src/Section.cpp @@ -4,6 +4,12 @@ #include void Section::CalculateHash() const { + if (block.empty()) { + hash = 0; + return; + } + + size_t offset = 0; std::vector rawData; -- cgit v1.2.3