From 08b680d58890ce896f5d57404adc84eb7b96fd79 Mon Sep 17 00:00:00 2001 From: Ekdohibs Date: Wed, 22 Mar 2017 03:25:16 +0100 Subject: 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. --- src/content_sao.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/content_sao.cpp') diff --git a/src/content_sao.cpp b/src/content_sao.cpp index ea2a4ebf6..282a6546c 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -1271,6 +1271,16 @@ std::string PlayerSAO::getWieldList() const } ItemStack PlayerSAO::getWieldedItem() const +{ + const Inventory *inv = getInventory(); + ItemStack ret; + const InventoryList *mlist = inv->getList(getWieldList()); + if (mlist && getWieldIndex() < (s32)mlist->getSize()) + ret = mlist->getItem(getWieldIndex()); + return ret; +} + +ItemStack PlayerSAO::getWieldedItemOrHand() const { const Inventory *inv = getInventory(); ItemStack ret; @@ -1291,14 +1301,6 @@ bool PlayerSAO::setWieldedItem(const ItemStack &item) if (inv) { InventoryList *mlist = inv->getList(getWieldList()); if (mlist) { - ItemStack olditem = mlist->getItem(getWieldIndex()); - if (olditem.name.empty()) { - InventoryList *hlist = inv->getList("hand"); - if (hlist) { - hlist->changeItem(0, item); - return true; - } - } mlist->changeItem(getWieldIndex(), item); return true; } -- cgit v1.2.3