From f132bb1861c1e7ab6cda7abb7f35cdf146a5972b Mon Sep 17 00:00:00 2001 From: Florian Berthold Date: Fri, 15 May 2026 19:53:49 +0200 Subject: [PATCH] fix(items): also handle first-render-under-lag empty slots MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous grace-window fix only kicked in when self.hasItem was already set, so first-render-under-lag (login/reloadui while bag data is in flight) still drew empty. Arm a single re-verify on any nil read so a late-arriving item gets redrawn; the verifyArmed flag prevents re-scheduling on genuinely empty slots — it only clears when we see a valid link. --- Bagnon/components/item.lua | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Bagnon/components/item.lua b/Bagnon/components/item.lua index 9bded9a..7016d31 100644 --- a/Bagnon/components/item.lua +++ b/Bagnon/components/item.lua @@ -286,17 +286,26 @@ function ItemSlot:Update() if not self:IsVisible() then return end local texture, count, locked, quality, readable, lootable, link = self:GetItemSlotInfo() + local now = GetTime() - -- If the slot was occupied at our last good draw and the live read just - -- returned nil within the grace window, keep the previous draw and queue - -- a single re-check. No retry storm. - if (not link) and self.hasItem and (self.lastGoodTime or 0) + GRACE_WINDOW > GetTime() then - scheduleVerify(self) - return - end - - if link then - self.lastGoodTime = GetTime() + -- Any nil read might be a lag race (server hasn't delivered item data + -- yet). Arm a single re-check so a late arrival redraws correctly. The + -- flag stays armed until we see a valid link, so a genuinely empty slot + -- doesn't keep re-scheduling. + if not link then + if not self.verifyArmed then + self.verifyArmed = true + scheduleVerify(self) + end + -- If we had a confirmed item recently, also suppress the empty draw + -- so the slot doesn't flash. After the grace window we let the empty + -- through (genuine moves still resolve at ~0.5s). + if self.hasItem and (self.lastGoodTime or 0) + GRACE_WINDOW > now then + return + end + else + self.lastGoodTime = now + self.verifyArmed = nil end self:SetItem(link)