Skip to content

Commit

Permalink
Clean up deprecated API compat
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg committed Aug 23, 2024
1 parent fdca7ca commit 3bf0fd5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 34 deletions.
30 changes: 9 additions & 21 deletions modulePrototype.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,20 @@ do
end

do
local UnitAura = C_UnitAuras and C_UnitAuras.GetAuraDataByIndex or UnitAura
local UnitAura = C_UnitAuras.GetAuraDataByIndex
--- Get the buff info of a unit.
-- @string unit unit token or unit name
-- @string list the table full of buff names to scan for
-- @return spellName, expirationTime, spellId
function prototype:UnitBuffByNames(unit, list)
local name, expirationTime, spellId, _
local num = #list
for i = 1, 100 do
name, _, _, _, _, expirationTime, _, _, _, spellId = UnitAura(unit, i, "HELPFUL")
if type(name) == "table" then
expirationTime = name.expirationTime
spellId = name.spellId
name = name.name
end
if not spellId then return end
local aura = UnitAura(unit, i, "HELPFUL")
if not aura then return end

for j = 1, num do
if list[j] == name then
return name, expirationTime, spellId
if list[j] == aura.name then
return aura.name, aura.expirationTime, aura.spellId
end
end
end
Expand All @@ -81,20 +75,14 @@ do
-- @string list the table full of spell IDs to scan for
-- @return spellName, expirationTime, spellId
function prototype:UnitBuffByIDs(unit, list)
local name, expirationTime, spellId, _
local num = #list
for i = 1, 100 do
name, _, _, _, _, expirationTime, _, _, _, spellId = UnitAura(unit, i, "HELPFUL")
if type(name) == "table" then
expirationTime = name.expirationTime
spellId = name.spellId
name = name.name
end
if not spellId then return end
local aura = UnitAura(unit, i, "HELPFUL")
if not aura then return end

for j = 1, num do
if list[j] == spellId then
return name, expirationTime, spellId
if list[j] == aura.spellId then
return aura.name, aura.expirationTime, aura.spellId
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion modules/BattleRes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ do
brez.remaining:SetTextColor(0,1,0)
end
if next(hasEngineer) then
local count = 1 -- GetItemCount(engineerItem)
local count = 1 -- C_Item.GetItemCount(engineerItem)
if count > 0 then
brez.engineerIcon:SetVertexColor(1, 1, 1)
else
Expand Down
3 changes: 1 addition & 2 deletions modules/Gear.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ function module:OnCommReceived(_, sender, prefix, ilvl, gems, enchants)
end

do
local GetItemStats = C_Item and C_Item.GetItemStats or GetItemStats
local enchantableItems = {
false, -- INVSLOT_HEAD -- 1
false, -- INVSLOT_NECK -- 2
Expand Down Expand Up @@ -153,7 +152,7 @@ do
-- Handle missing gems
local totalItemSockets = 0

local statsTable = GetItemStats(itemLink)
local statsTable = C_Item.GetItemStats(itemLink)
if statsTable then
for k, v in next, statsTable do
if k:find("EMPTY_SOCKET_", nil, true) then
Expand Down
11 changes: 4 additions & 7 deletions modules/ReadyCheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -213,21 +213,18 @@ local function shouldShowBuffs()
return false
end

local UnitAura = C_UnitAuras and C_UnitAuras.GetAuraDataByIndex or UnitAura
local UnitAura = C_UnitAuras.GetAuraDataByIndex
local function Frame_Tooltip(self)
if self.name then
GameTooltip:SetOwner(self, "ANCHOR_TOPLEFT")
local unit = self:GetParent().player
for i = 1, 100 do
local name = UnitAura(unit, i, "HELPFUL")
if type(name) == "table" then
name = name.name
end
if not name then
local aura = UnitAura(unit, i, "HELPFUL")
if not aura then
GameTooltip:SetText(self.name) -- we're out of sync
break
end
if name == self.name then
if aura.name == self.name then
GameTooltip:SetUnitBuff(unit, i)
break
end
Expand Down
5 changes: 2 additions & 3 deletions oRA3.lua
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,15 @@ function addon:OnInitialize()
end
end
RaidFrame:HookScript("OnHide", OnRaidHide)
local IsAddOnLoaded = C_AddOns.IsAddOnLoaded or IsAddOnLoaded
if not IsAddOnLoaded("Blizzard_RaidUI") then
if not C_AddOns.IsAddOnLoaded("Blizzard_RaidUI") then
self.rehookAfterRaidUILoad = true
end

RaidFrame:HookScript("OnShow", function()
if addon:IsEnabled() and db.toggleWithRaid then
addon:ShowUIPanel()
end
if addon.rehookAfterRaidUILoad and IsAddOnLoaded("Blizzard_RaidUI") then
if addon.rehookAfterRaidUILoad and C_AddOns.IsAddOnLoaded("Blizzard_RaidUI") then
-- Blizzard_RaidUI overwrites the RaidFrame "OnHide" script squashing the hook registered above, so re-hook.
addon.rehookAfterRaidUILoad = nil
RaidFrame:HookScript("OnHide", OnRaidHide)
Expand Down

0 comments on commit 3bf0fd5

Please sign in to comment.