summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorSmallJoker <SmallJoker@users.noreply.github.com>2019-09-02 19:30:36 +0200
committerGitHub <noreply@github.com>2019-09-02 19:30:36 +0200
commitf3acdd3914c977f0c9129a8691287a87d822ee0f (patch)
tree09330338b53dedc7598f0dd09652cb64e713fad2 /src/inventory.cpp
parentcd1d01b8b444b7f07a48cea57aa6f789d8bb54ef (diff)
downloadminetest-f3acdd3914c977f0c9129a8691287a87d822ee0f.tar.gz
minetest-f3acdd3914c977f0c9129a8691287a87d822ee0f.tar.bz2
minetest-f3acdd3914c977f0c9129a8691287a87d822ee0f.zip
Inventory: Handle removeItem leftovers (#8884)
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 02e122416..2a7c32a44 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -680,7 +680,11 @@ ItemStack InventoryList::removeItem(const ItemStack &item)
for (auto i = m_items.rbegin(); i != m_items.rend(); ++i) {
if (i->name == item.name) {
u32 still_to_remove = item.count - removed.count;
- removed.addItem(i->takeItem(still_to_remove), m_itemdef);
+ ItemStack leftover = removed.addItem(i->takeItem(still_to_remove),
+ m_itemdef);
+ // Allow oversized stacks
+ removed.count += leftover.count;
+
if (removed.count == item.count)
break;
}