Skip to content

Commit

Permalink
Inventory: Handle removeItem leftovers (#8884)
Browse files Browse the repository at this point in the history
  • Loading branch information
SmallJoker authored Sep 2, 2019
1 parent cd1d01b commit f3acdd3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit f3acdd3

Please sign in to comment.