summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-01-06 10:24:44 +0100
committerLoïc Blot <nerzhul@users.noreply.github.com>2019-01-06 10:24:44 +0100
commita122ba0ef4af865d225adbe22a55b8001af04c61 (patch)
tree9e8e6097621396e4bab22e5aa21a70900a502878 /src/network
parent70bf3439ab9f3cb826d76111552dcc38678fcf3d (diff)
downloadminetest-a122ba0ef4af865d225adbe22a55b8001af04c61.tar.gz
minetest-a122ba0ef4af865d225adbe22a55b8001af04c61.tar.bz2
minetest-a122ba0ef4af865d225adbe22a55b8001af04c61.zip
Fix various bugs (Anticheat, Lua helpers) (#8013)
* Fix various bugs (Anticheat, Lua helpers) Anticheat: Use camera position instead of player position for shoot line calculations Lua helpers: Increase 'i' to not overwrite earlier added table values * Remove lag compensation * * 1.5 for larger selection boxes
Diffstat (limited to 'src/network')
-rw-r--r--src/network/serverpackethandler.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index 329b38765..138cf3edb 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -627,7 +627,7 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
// Check for out-of-range interaction
if (remote->type == InventoryLocation::NODEMETA) {
v3f node_pos = intToFloat(remote->p, BS);
- v3f player_pos = player->getPlayerSAO()->getBasePosition();
+ v3f player_pos = player->getPlayerSAO()->getEyePosition();
f32 d = player_pos.getDistanceFrom(node_pos);
if (!checkInteractDistance(player, d, "inventory"))
return;
@@ -969,8 +969,9 @@ bool Server::checkInteractDistance(RemotePlayer *player, const f32 d, const std:
else if (max_d < 0)
max_d = BS * 4.0f;
- // cube diagonal: sqrt(3) = 1.732
- if (d > max_d * 1.732) {
+ // Cube diagonal * 1.5 for maximal supported node extents:
+ // sqrt(3) * 1.5 ≅ 2.6
+ if (d > max_d + 2.6f * BS) {
actionstream << "Player " << player->getName()
<< " tried to access " << what
<< " from too far: "
@@ -1109,7 +1110,9 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
if ((action == 0 || action == 2 || action == 3 || action == 4) &&
enable_anticheat && !isSingleplayer()) {
- float d = player_pos.getDistanceFrom(pointed_pos_under);
+ float d = playersao->getEyePosition()
+ .getDistanceFrom(pointed_pos_under);
+
if (!checkInteractDistance(player, d, pointed.dump())) {
// Re-send block to revert change on client-side
RemoteClient *client = getClient(pkt->getPeerId());