Fix itemGetQuantity

This commit is contained in:
Alexander Batalov 2022-10-05 15:44:00 +03:00
parent 93a341bbaa
commit 7ddd8f2894
1 changed files with 5 additions and 1 deletions

View File

@ -1029,11 +1029,15 @@ int itemGetQuantity(Object* obj, Object* item)
InventoryItem* inventoryItem = &(inventory->items[index]); InventoryItem* inventoryItem = &(inventory->items[index]);
if (inventoryItem->item == item) { if (inventoryItem->item == item) {
quantity = inventoryItem->quantity; quantity = inventoryItem->quantity;
// SFALL: Fix incorrect value being returned if there is a container
// item in the inventory.
break;
} else { } else {
if (itemGetType(inventoryItem->item) == ITEM_TYPE_CONTAINER) { if (itemGetType(inventoryItem->item) == ITEM_TYPE_CONTAINER) {
quantity = itemGetQuantity(inventoryItem->item, item); quantity = itemGetQuantity(inventoryItem->item, item);
if (quantity > 0) { if (quantity > 0) {
return quantity; break;
} }
} }
} }