Skip to content

Commit

Permalink
fix 11.0.2 deprecated/removed api functions
Browse files Browse the repository at this point in the history
  • Loading branch information
wardz committed Sep 7, 2024
1 parent d78eaee commit d4baf0a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,6 @@ read_globals = {
"UnitChannelInfo",
"UnitIsFriend",
"strsplit",
"C_AddOns",
"C_Spell",
}
8 changes: 7 additions & 1 deletion ClassicCastbars/ClassicCastbars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ function ClassicCastbars:BindCurrentCastData(castbar, unitID, isChanneled, chann

-- HACK: UnitChannelInfo is bugged for classic era, tmp fallback method
if channelSpellID and not spellName then
spellName, _, iconTexturePath = GetSpellInfo(channelSpellID)
if C_Spell.GetSpellInfo then
local info = C_Spell.GetSpellInfo(channelSpellID)
spellName = info and info.name
iconTexturePath = info and info.iconID
else
spellName, _, iconTexturePath = GetSpellInfo(channelSpellID)
end
local channelCastTime = spellName and channeledSpells[spellName]
if not channelCastTime then return end

Expand Down
2 changes: 2 additions & 0 deletions ClassicCastbars/core/ClassicSpellData.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ local CLIENT_IS_CLASSIC_ERA = (WOW_PROJECT_ID == WOW_PROJECT_CLASSIC)

if not CLIENT_IS_TBC and not CLIENT_IS_CLASSIC_ERA then return end

local GetSpellInfo = C_Spell and C_Spell.GetSpellName or _G.GetSpellInfo

local physicalClasses = {
["WARRIOR"] = true,
["ROGUE"] = true,
Expand Down
8 changes: 4 additions & 4 deletions ClassicCastbars/core/LoadOptionsOnDemand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ SLASH_CLASSICCASTBARS6 = "/classicastbars"
local isLoaded = false

GameMenuFrame:HookScript("OnShow", function()
if not isLoaded and not IsAddOnLoaded("ClassicCastbars_Options") then
local loaded, reason = LoadAddOn("ClassicCastbars_Options")
if not isLoaded and not C_AddOns.IsAddOnLoaded("ClassicCastbars_Options") then
local loaded, reason = C_AddOns.LoadAddOn("ClassicCastbars_Options")
if not loaded and reason == "DISABLED" then
isLoaded = true -- disabled, dont attempt to load it anymore
return
Expand All @@ -20,9 +20,9 @@ GameMenuFrame:HookScript("OnShow", function()
end)

SlashCmdList["CLASSICCASTBARS"] = function()
if not IsAddOnLoaded("ClassicCastbars_Options") then
if not C_AddOns.IsAddOnLoaded("ClassicCastbars_Options") then
if not isLoaded then
local loaded, reason = LoadAddOn("ClassicCastbars_Options")
local loaded, reason = C_AddOns.LoadAddOn("ClassicCastbars_Options")
if not loaded and reason == "DISABLED" then
isLoaded = true -- disabled, dont attempt to load it anymore
return print(string.format(_G.ADDON_LOAD_FAILED, "ClassicCastbars_Options", _G["ADDON_" .. reason] or _G.ADDON_UNKNOWN_ERROR)) -- luacheck: ignore
Expand Down
2 changes: 2 additions & 0 deletions ClassicCastbars_Options/ClassicCastbars_Options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,8 @@ local function CreateUnitTabGroup(unitID, localizedUnit, order)
}
end

local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or _G.GetAddOnMetadata

local function GetOptionsTable()
return { -- only create table on demand
type = "group",
Expand Down
5 changes: 4 additions & 1 deletion ClassicCastbars_Options/TestMode.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ local L = LibStub("AceLocale-3.0"):GetLocale("ClassicCastbars")
local TestMode = CreateFrame("Frame", "ClassicCastbars_TestMode")
TestMode.isTesting = {}

local GetSpellName = C_Spell and C_Spell.GetSpellName or _G.GetSpellInfo
local GetSpellTexture = C_Spell and C_Spell.GetSpellTexture or _G.GetSpellTexture

local dummySpellData = {
spellName = GetSpellInfo(118),
spellName = GetSpellName(118),
icon = GetSpellTexture(118),
spellID = 118,
maxValue = 10,
Expand Down

0 comments on commit d4baf0a

Please sign in to comment.