Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gamemode/core/meta/sh_item.lua
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,13 @@ function ITEM:SetData(key, value, receivers, noSave, noCheckEntity)

local inventory = ix.item.inventories[self.invID]

if (receivers != false and (receivers or inventory and inventory.GetReceivers and inventory:GetReceivers() or self:GetOwner())) then
local target = receivers or inventory and inventory.GetReceivers and inventory:GetReceivers() or self:GetOwner()
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target is computed unconditionally. In the previous code, when receivers == false the and short-circuit prevented evaluating the receiver expression (including potentially expensive inventory:GetReceivers() / self:GetOwner() calls). With this refactor, those calls can still happen even though networking is disabled, which is a behavior/perf change. Consider moving the target computation inside the if (receivers != false ...) block (or guard it with if receivers != false then ... end) so the expression is only evaluated when it will be used.

Suggested change
local target = receivers or inventory and inventory.GetReceivers and inventory:GetReceivers() or self:GetOwner()
local target
if (receivers != false) then
target = receivers or inventory and inventory.GetReceivers and inventory:GetReceivers() or self:GetOwner()
end

Copilot uses AI. Check for mistakes.
if (receivers != false and target) then
Comment on lines +343 to +344
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says there is no logic change, but computing target before the receivers != false check changes evaluation order and can trigger inventory:GetReceivers() / self:GetOwner() calls even when receivers == false. Either adjust the code to preserve the original short-circuit behavior, or update the PR description to reflect the behavioral change.

Copilot uses AI. Check for mistakes.
net.Start("ixInventoryData")
net.WriteUInt(self:GetID(), 32)
net.WriteString(key)
net.WriteType(value)
net.Send(receivers or inventory and inventory.GetReceivers and inventory:GetReceivers() or self:GetOwner())
net.Send(target)
end

if (!noSave and ix.db) then
Expand Down
Loading