From a31894729f1d4cb82471ce40538c818f7a7ab8f4 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 29 Jun 2023 10:43:12 +1000 Subject: [PATCH] fix(server/inventory): Inventory.GetItem adds count twice Bug from e3e05c3. Resolves #1384. --- modules/inventory/server.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/modules/inventory/server.lua b/modules/inventory/server.lua index 3ad5b89895..2c08add11e 100644 --- a/modules/inventory/server.lua +++ b/modules/inventory/server.lua @@ -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