summaryrefslogtreecommitdiffstats
path: root/src/GameState.cpp
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2023-07-08 20:30:25 +0200
committerLaG1924 <lag1924@gmail.com>2023-07-08 21:24:04 +0200
commitc984afdf47ef31511024c6b70bd4b4c4e64f56a6 (patch)
tree3c539c9e7de841c6616f532dadb7c8c1ef552d95 /src/GameState.cpp
parentMerge pull request #80 from LaG1924/ftr/better-water (diff)
downloadAltCraft-c984afdf47ef31511024c6b70bd4b4c4e64f56a6.tar
AltCraft-c984afdf47ef31511024c6b70bd4b4c4e64f56a6.tar.gz
AltCraft-c984afdf47ef31511024c6b70bd4b4c4e64f56a6.tar.bz2
AltCraft-c984afdf47ef31511024c6b70bd4b4c4e64f56a6.tar.lz
AltCraft-c984afdf47ef31511024c6b70bd4b4c4e64f56a6.tar.xz
AltCraft-c984afdf47ef31511024c6b70bd4b4c4e64f56a6.tar.zst
AltCraft-c984afdf47ef31511024c6b70bd4b4c4e64f56a6.zip
Diffstat (limited to 'src/GameState.cpp')
-rw-r--r--src/GameState.cpp16
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;
}