aboutsummaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorEkdohibs <nathanael.courant@laposte.net>2017-03-22 03:25:16 +0100
committerAuke Kok <sofar+github@foo-projects.org>2017-04-06 21:27:29 -0700
commit08b680d58890ce896f5d57404adc84eb7b96fd79 (patch)
treeaad96d77674cf963e4857d67c671e5169e348020 /src/network
parentbce0d458d8cda70c10d78ea9ec476474f0a6f01a (diff)
downloadminetest-08b680d58890ce896f5d57404adc84eb7b96fd79.tar.gz
minetest-08b680d58890ce896f5d57404adc84eb7b96fd79.tar.bz2
minetest-08b680d58890ce896f5d57404adc84eb7b96fd79.zip
Fix problems when overriding the hand:
- If the hand can dig a node the item wielded can't, allow to dig it anyway. - Fix the API callbacks from setting the hand instead of the wielded item.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/serverpackethandler.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index 95df6fc4f..740096bf1 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -1382,7 +1382,10 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
const ItemDefinition &playeritem_def =
playersao->getWieldedItem().getDefinition(m_itemdef);
float max_d = BS * playeritem_def.range;
- float max_d_hand = BS * m_itemdef->get("").range;
+ InventoryList *hlist = playersao->getInventory()->getList("hand");
+ const ItemDefinition &hand_def =
+ hlist?(hlist->getItem(0).getDefinition(m_itemdef)):(m_itemdef->get(""));
+ float max_d_hand = BS * hand_def.range;
if (max_d < 0 && max_d_hand >= 0)
max_d = max_d_hand;
else if (max_d < 0)
@@ -1443,7 +1446,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
<<pointed.object_id<<": "
<<pointed_object->getDescription()<<std::endl;
- ItemStack punchitem = playersao->getWieldedItem();
+ ItemStack punchitem = playersao->getWieldedItemOrHand();
ToolCapabilities toolcap =
punchitem.getToolCapabilities(m_itemdef);
v3f dir = (pointed_object->getBasePosition() -
@@ -1510,7 +1513,7 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
m_script->on_cheat(playersao, "finished_unknown_dig");
}
// Get player's wielded item
- ItemStack playeritem = playersao->getWieldedItem();
+ ItemStack playeritem = playersao->getWieldedItemOrHand();
ToolCapabilities playeritem_toolcap =
playeritem.getToolCapabilities(m_itemdef);
// Get diggability and expected digging time
@@ -1518,7 +1521,9 @@ void Server::handleCommand_Interact(NetworkPacket* pkt)
&playeritem_toolcap);
// If can't dig, try hand
if (!params.diggable) {
- const ItemDefinition &hand = m_itemdef->get("");
+ InventoryList *hlist = playersao->getInventory()->getList("hand");
+ const ItemDefinition &hand =
+ hlist?hlist->getItem(0).getDefinition(m_itemdef):m_itemdef->get("");
const ToolCapabilities *tp = hand.tool_capabilities;
if (tp)
params = getDigParams(m_nodedef->get(n).groups, tp);