refactor: consolidate small compatibility layers

This commit is contained in:
Dusk-92
2026-09-06 08:54:46 +02:00
parent e096ba2d90
commit cadf154d0f
18 changed files with 757 additions and 727 deletions
+49
View File
@@ -480,3 +480,52 @@ function BagScanner:Initialize()
addon:Debug("Bag scanner initialized with ClassicAPI incremental cache")
end
--=====================================================
-- Consolidated from Data/ItemCategoryOverrides.lua
--=====================================================
-- Turtle WoW item category corrections for stale server-side item classifications.
-- Keep this list intentionally small and explicit to avoid affecting real quest items.
-- Lua 5.0 compatible.
local addon = Guda
if not addon or not addon.Modules or not addon.Modules.BagScanner then return end
local CATEGORY_OVERRIDES = {
[730] = "Trade Goods", -- Murloc Eye: no longer a quest item on Turtle WoW
}
-- ItemDetection checks this table at runtime before treating API/tooltip data as
-- authoritative quest metadata. Extend the existing exclusions rather than
-- replacing them so the Juju fixes remain intact.
if addon.Constants then
addon.Constants.QUEST_CATEGORY_EXCLUSIONS = addon.Constants.QUEST_CATEGORY_EXCLUSIONS or {}
for itemID in pairs(CATEGORY_OVERRIDES) do
addon.Constants.QUEST_CATEGORY_EXCLUSIONS[itemID] = true
end
end
local BagScanner = addon.Modules.BagScanner
local OriginalScanSlot = BagScanner.ScanSlot
if OriginalScanSlot then
function BagScanner:ScanSlot(bagID, slotID)
local itemData = OriginalScanSlot(self, bagID, slotID)
if not itemData then return nil end
local itemID = tonumber(itemData.itemID)
if not itemID and itemData.link and addon.Modules.Utils then
itemID = addon.Modules.Utils:ExtractItemID(itemData.link)
end
local category = itemID and CATEGORY_OVERRIDES[itemID] or nil
if category then
itemData.class = category
itemData.type = category
end
return itemData
end
end
addon:Debug("Turtle WoW item category overrides enabled")
+79
View File
@@ -363,3 +363,82 @@ end
function BankScanner:IsBankOpen()
return bankOpen
end
--=====================================================
-- Consolidated from Data/CacheLifecycleSafety.lua
--=====================================================
-- Guda ClassicAPI cache lifecycle safety
-- Whole-cache invalidation is deferred to in-place dirty refreshes while the
-- corresponding UI is visible. This prevents pooled item tables still held by
-- visible buttons from being cleared/reused before their redraw runs.
-- Lua 5.0 compatible.
local addon = Guda
local BagScanner = addon.Modules.BagScanner
local BankScanner = addon.Modules.BankScanner
if not BagScanner or not BankScanner then return end
local oldBagClearCache = BagScanner.ClearCache
local oldBagInvalidateCache = BagScanner.InvalidateCache
local oldBankClearCache = BankScanner.ClearCache
local oldBankInvalidateCache = BankScanner.InvalidateCache
local function IsShown(name)
local frame = getglobal(name)
return frame and frame.IsShown and frame:IsShown()
end
local function MarkAllBagsDirty()
if addon.Constants and addon.Constants.BAGS then
for _, bagID in ipairs(addon.Constants.BAGS) do
BagScanner:InvalidateBag(bagID)
end
else
for bagID = 0, 4 do
BagScanner:InvalidateBag(bagID)
end
end
BagScanner:InvalidateBag(-2)
end
local function MarkAllBankBagsDirty()
if addon.Constants and addon.Constants.BANK_BAGS then
for _, bagID in ipairs(addon.Constants.BANK_BAGS) do
BankScanner:InvalidateBag(bagID)
end
end
end
function BagScanner:ClearCache()
if IsShown("Guda_BagFrame") then
MarkAllBagsDirty()
return
end
return oldBagClearCache(self)
end
function BagScanner:InvalidateCache()
if IsShown("Guda_BagFrame") then
MarkAllBagsDirty()
return
end
return oldBagInvalidateCache(self)
end
function BankScanner:ClearCache()
if BankScanner:IsBankOpen() and IsShown("Guda_BankFrame") then
MarkAllBankBagsDirty()
return
end
return oldBankClearCache(self)
end
function BankScanner:InvalidateCache()
if BankScanner:IsBankOpen() and IsShown("Guda_BankFrame") then
MarkAllBankBagsDirty()
return
end
return oldBankInvalidateCache(self)
end
addon:Debug("ClassicAPI cache lifecycle safety enabled")
-75
View File
@@ -1,75 +0,0 @@
-- Guda ClassicAPI cache lifecycle safety
-- Whole-cache invalidation is deferred to in-place dirty refreshes while the
-- corresponding UI is visible. This prevents pooled item tables still held by
-- visible buttons from being cleared/reused before their redraw runs.
-- Lua 5.0 compatible.
local addon = Guda
local BagScanner = addon.Modules.BagScanner
local BankScanner = addon.Modules.BankScanner
if not BagScanner or not BankScanner then return end
local oldBagClearCache = BagScanner.ClearCache
local oldBagInvalidateCache = BagScanner.InvalidateCache
local oldBankClearCache = BankScanner.ClearCache
local oldBankInvalidateCache = BankScanner.InvalidateCache
local function IsShown(name)
local frame = getglobal(name)
return frame and frame.IsShown and frame:IsShown()
end
local function MarkAllBagsDirty()
if addon.Constants and addon.Constants.BAGS then
for _, bagID in ipairs(addon.Constants.BAGS) do
BagScanner:InvalidateBag(bagID)
end
else
for bagID = 0, 4 do
BagScanner:InvalidateBag(bagID)
end
end
BagScanner:InvalidateBag(-2)
end
local function MarkAllBankBagsDirty()
if addon.Constants and addon.Constants.BANK_BAGS then
for _, bagID in ipairs(addon.Constants.BANK_BAGS) do
BankScanner:InvalidateBag(bagID)
end
end
end
function BagScanner:ClearCache()
if IsShown("Guda_BagFrame") then
MarkAllBagsDirty()
return
end
return oldBagClearCache(self)
end
function BagScanner:InvalidateCache()
if IsShown("Guda_BagFrame") then
MarkAllBagsDirty()
return
end
return oldBagInvalidateCache(self)
end
function BankScanner:ClearCache()
if BankScanner:IsBankOpen() and IsShown("Guda_BankFrame") then
MarkAllBankBagsDirty()
return
end
return oldBankClearCache(self)
end
function BankScanner:InvalidateCache()
if BankScanner:IsBankOpen() and IsShown("Guda_BankFrame") then
MarkAllBankBagsDirty()
return
end
return oldBankInvalidateCache(self)
end
addon:Debug("ClassicAPI cache lifecycle safety enabled")
-45
View File
@@ -1,45 +0,0 @@
-- Turtle WoW item category corrections for stale server-side item classifications.
-- Keep this list intentionally small and explicit to avoid affecting real quest items.
-- Lua 5.0 compatible.
local addon = Guda
if not addon or not addon.Modules or not addon.Modules.BagScanner then return end
local CATEGORY_OVERRIDES = {
[730] = "Trade Goods", -- Murloc Eye: no longer a quest item on Turtle WoW
}
-- ItemDetection checks this table at runtime before treating API/tooltip data as
-- authoritative quest metadata. Extend the existing exclusions rather than
-- replacing them so the Juju fixes remain intact.
if addon.Constants then
addon.Constants.QUEST_CATEGORY_EXCLUSIONS = addon.Constants.QUEST_CATEGORY_EXCLUSIONS or {}
for itemID in pairs(CATEGORY_OVERRIDES) do
addon.Constants.QUEST_CATEGORY_EXCLUSIONS[itemID] = true
end
end
local BagScanner = addon.Modules.BagScanner
local OriginalScanSlot = BagScanner.ScanSlot
if OriginalScanSlot then
function BagScanner:ScanSlot(bagID, slotID)
local itemData = OriginalScanSlot(self, bagID, slotID)
if not itemData then return nil end
local itemID = tonumber(itemData.itemID)
if not itemID and itemData.link and addon.Modules.Utils then
itemID = addon.Modules.Utils:ExtractItemID(itemData.link)
end
local category = itemID and CATEGORY_OVERRIDES[itemID] or nil
if category then
itemData.class = category
itemData.type = category
end
return itemData
end
end
addon:Debug("Turtle WoW item category overrides enabled")