diff options
author | SmallJoker <SmallJoker@users.noreply.github.com> | 2017-06-25 11:39:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-25 11:39:39 +0200 |
commit | c08cc0533fbf344be5243485f39a471268855149 (patch) | |
tree | f9b5c51903572e2eafa7b4781a06768b1ed554db /src/inventory.cpp | |
parent | cad10ce3b747b721fd63784915e05f12bc488128 (diff) | |
download | minetest-c08cc0533fbf344be5243485f39a471268855149.tar.gz minetest-c08cc0533fbf344be5243485f39a471268855149.tar.bz2 minetest-c08cc0533fbf344be5243485f39a471268855149.zip |
Inventory: Fix wrong stack size behaviour and item loss (#6039)
Also fix itemFits and remove constness-nonsense
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index 24eebba80..4da380a24 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -254,11 +254,8 @@ std::string ItemStack::getItemString() const } -ItemStack ItemStack::addItem(const ItemStack &newitem_, - IItemDefManager *itemdef) +ItemStack ItemStack::addItem(ItemStack newitem, IItemDefManager *itemdef) { - ItemStack newitem = newitem_; - // If the item is empty or the position invalid, bail out if(newitem.empty()) { @@ -267,7 +264,7 @@ ItemStack ItemStack::addItem(const ItemStack &newitem_, // If this is an empty item, it's an easy job. else if(empty()) { - const u16 stackMax = getStackMax(itemdef); + const u16 stackMax = newitem.getStackMax(itemdef); *this = newitem; @@ -303,11 +300,10 @@ ItemStack ItemStack::addItem(const ItemStack &newitem_, return newitem; } -bool ItemStack::itemFits(const ItemStack &newitem_, +bool ItemStack::itemFits(ItemStack newitem, ItemStack *restitem, IItemDefManager *itemdef) const { - ItemStack newitem = newitem_; // If the item is empty or the position invalid, bail out if(newitem.empty()) @@ -317,7 +313,7 @@ bool ItemStack::itemFits(const ItemStack &newitem_, // If this is an empty item, it's an easy job. else if(empty()) { - const u16 stackMax = getStackMax(itemdef); + const u16 stackMax = newitem.getStackMax(itemdef); // If the item fits fully, delete it if (newitem.count <= stackMax) { |