Skip to content

Commit

Permalink
fix(server/inventory): Inventory.GetItem adds count twice
Browse files Browse the repository at this point in the history
Bug from e3e05c3. Resolves #1384.
  • Loading branch information
thelindat committed Jun 29, 2023
1 parent ee62eff commit a318947
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions modules/inventory/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -832,13 +832,9 @@ function Inventory.GetItem(inv, item, metadata, returnsCount)
local ostime = os.time()
metadata = assertMetadata(metadata)

for k, v in pairs(inv.items) do
if v and v.name == item.name and (not metadata or table.contains(v.metadata, metadata)) then
count += v.count

if not Items.UpdateDurability(inv, v, item, nil, ostime) then
count += v.count
end
for _, v in pairs(inv.items) do
if v.name == item.name and (not metadata or table.contains(v.metadata, metadata)) and not Items.UpdateDurability(inv, v, item, nil, ostime) then
count += v.count
end
end
end
Expand Down

0 comments on commit a318947

Please sign in to comment.