summaryrefslogtreecommitdiff
path: root/src/content_sao.cpp
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/content_sao.cpp
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/content_sao.cpp')
-rw-r--r--src/content_sao.cpp18
1 files changed, 10 insertions, 8 deletions
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
@@ -1277,6 +1277,16 @@ ItemStack PlayerSAO::getWieldedItem() const
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;
+ const InventoryList *mlist = inv->getList(getWieldList());
+ if (mlist && getWieldIndex() < (s32)mlist->getSize())
+ ret = mlist->getItem(getWieldIndex());
if (ret.name.empty()) {
const InventoryList *hlist = inv->getList("hand");
if (hlist)
@@ -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;
}