This commit is contained in:
Salikh Gurgenidze
2026-01-24 00:38:03 +04:00
parent 21efe4c1cc
commit 75e4d83fc0
2 changed files with 45 additions and 30 deletions
+10
View File
@@ -52,8 +52,11 @@ function BagScanner:GetBagData()
if cacheValid and bagCache then if cacheValid and bagCache then
-- Process any dirty slots incrementally -- Process any dirty slots incrementally
for bagID, slots in pairs(dirtySlots) do for bagID, slots in pairs(dirtySlots) do
if bagID ~= nil and type(slots) == "table" then
if bagCache[bagID] then if bagCache[bagID] then
for slotID in pairs(slots) do for slotID in pairs(slots) do
-- Validate slotID is a valid number
if type(slotID) == "number" and slotID >= 1 then
local oldData = bagCache[bagID].slots[slotID] local oldData = bagCache[bagID].slots[slotID]
local newData = self:ScanSlot(bagID, slotID) local newData = self:ScanSlot(bagID, slotID)
bagCache[bagID].slots[slotID] = newData bagCache[bagID].slots[slotID] = newData
@@ -67,11 +70,13 @@ function BagScanner:GetBagData()
bagCache[bagID].freeSlots = bagCache[bagID].freeSlots + 1 bagCache[bagID].freeSlots = bagCache[bagID].freeSlots + 1
end end
end end
end
else else
-- Bag not in cache, scan it -- Bag not in cache, scan it
bagCache[bagID] = self:ScanBag(bagID) bagCache[bagID] = self:ScanBag(bagID)
end end
end end
end
dirtySlots = {} dirtySlots = {}
return bagCache return bagCache
end end
@@ -139,6 +144,11 @@ end
-- Scan a single slot -- Scan a single slot
function BagScanner:ScanSlot(bagID, slot) function BagScanner:ScanSlot(bagID, slot)
-- Validate parameters to prevent API errors
if bagID == nil or slot == nil or slot < 1 then
return nil
end
local texture, itemCount, locked, quality, readable, lootable = GetContainerItemInfo(bagID, slot) local texture, itemCount, locked, quality, readable, lootable = GetContainerItemInfo(bagID, slot)
if not texture then if not texture then
+5
View File
@@ -52,8 +52,11 @@ function BankScanner:GetBankData()
if cacheValid and bankCache then if cacheValid and bankCache then
-- Process any dirty slots incrementally -- Process any dirty slots incrementally
for bagID, slots in pairs(dirtySlots) do for bagID, slots in pairs(dirtySlots) do
if bagID ~= nil and type(slots) == "table" then
if bankCache[bagID] then if bankCache[bagID] then
for slotID in pairs(slots) do for slotID in pairs(slots) do
-- Validate slotID is a valid number
if type(slotID) == "number" and slotID >= 1 then
local oldData = bankCache[bagID].slots[slotID] local oldData = bankCache[bagID].slots[slotID]
local newData = addon.Modules.BagScanner:ScanSlot(bagID, slotID) local newData = addon.Modules.BagScanner:ScanSlot(bagID, slotID)
bankCache[bagID].slots[slotID] = newData bankCache[bagID].slots[slotID] = newData
@@ -67,11 +70,13 @@ function BankScanner:GetBankData()
bankCache[bagID].freeSlots = bankCache[bagID].freeSlots + 1 bankCache[bagID].freeSlots = bankCache[bagID].freeSlots + 1
end end
end end
end
else else
-- Bag not in cache, scan it -- Bag not in cache, scan it
bankCache[bagID] = self:ScanBankBag(bagID) bankCache[bagID] = self:ScanBankBag(bagID)
end end
end end
end
dirtySlots = {} dirtySlots = {}
return bankCache return bankCache
end end