diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2023-07-08 21:41:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-08 21:41:27 +0200 |
commit | a68f48ad526d0843eb451af0be7f119db5ff794e (patch) | |
tree | 3c539c9e7de841c6616f532dadb7c8c1ef552d95 /src/GameState.cpp | |
parent | Merge pull request #80 from LaG1924/ftr/better-water (diff) | |
parent | Fixed some errors detected by static analysis (diff) | |
download | AltCraft-master.tar AltCraft-master.tar.gz AltCraft-master.tar.bz2 AltCraft-master.tar.lz AltCraft-master.tar.xz AltCraft-master.tar.zst AltCraft-master.zip |
Diffstat (limited to '')
-rw-r--r-- | src/GameState.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/GameState.cpp b/src/GameState.cpp index 89743e4..e6f988d 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -512,6 +512,10 @@ void GameState::UpdatePacket(std::shared_ptr<Packet> ptr) { break; case EntityEffect: break; + + default: + LOG(WARNING) << "Server sent unknown packet"; + break; } while (!playerInventory.pendingTransactions.empty()) { @@ -642,7 +646,7 @@ void GameState::CancelDigging() { PUSH_EVENT("SendPacket", packet); } -BlockFacing detectHitFace(VectorF raycastHit, Vector selectedBlock) { +BlockFacing detectHitFace(const VectorF& raycastHit, const Vector& selectedBlock) { auto vec = VectorF(selectedBlock.x + .5, selectedBlock.y + .5, selectedBlock.z + .5) - raycastHit; // TODO: move these vectors to Vector.hpp @@ -658,15 +662,15 @@ BlockFacing detectHitFace(VectorF raycastHit, Vector selectedBlock) { const double backward = -forward; const double min_cos = _min(up, down, right, left, forward, backward); - if (min_cos == down) + if (std::abs(min_cos - down) < DBL_EPSILON) return BlockFacing::Bottom; - else if (min_cos == up) + else if (std::abs(min_cos - up) < DBL_EPSILON) return BlockFacing::Top; - else if (min_cos == forward) + else if (std::abs(min_cos - forward) < DBL_EPSILON) return BlockFacing::North; - else if (min_cos == backward) + else if (std::abs(min_cos - backward) < DBL_EPSILON) return BlockFacing::South; - else if (min_cos == left) + else if (std::abs(min_cos - left) < DBL_EPSILON) return BlockFacing::West; else return BlockFacing::East; } |