From 747f6a611c24b4a2ce6b3b1e2323604aab7f4428 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 19 Jun 2024 22:07:23 -0700 Subject: [PATCH] refactor: handle additional deprecations --- .../Conditions/Categories/BuffsDebuffs.lua | 64 +++--- .../Core/Conditions/Categories/Talents.lua | 21 +- .../CooldownSweep.lua | 1 + .../IconContainer_Masque.lua | 2 + Components/IconTypes/IconType_buff/buff.lua | 195 ++++++++---------- .../IconType_buffcheck/buffcheck.lua | 47 ++--- .../IconTypes/IconType_dotwatch/dotwatch.lua | 47 +++-- TellMeWhen.lua | 7 +- 8 files changed, 184 insertions(+), 200 deletions(-) diff --git a/Components/Core/Conditions/Categories/BuffsDebuffs.lua b/Components/Core/Conditions/Categories/BuffsDebuffs.lua index c19b53c2..27f4956d 100644 --- a/Components/Core/Conditions/Categories/BuffsDebuffs.lua +++ b/Components/Core/Conditions/Categories/BuffsDebuffs.lua @@ -24,20 +24,20 @@ local strlowerCache = TMW.strlowerCache local huge = math.huge local empty = {} -local UnitAura = UnitAura +local GetAuraDataByIndex = C_UnitAuras.GetAuraDataByIndex local GetAuras = TMW.COMMON.Auras.GetAuras function Env.AuraStacks(unit, name, filter) for i = 1, huge do - local buffName, _, count, _, _, _, _, _, _, id = UnitAura(unit, i, filter) + local data = GetAuraDataByIndex(unit, i, filter) - if not buffName then + if not data then return 0 - elseif id == name or strlowerCache[buffName] == name then - if count == 0 then + elseif data.spellId == name or strlowerCache[data.name] == name then + if data.applications == 0 then return 1 else - return count + return data.applications end end end @@ -66,10 +66,10 @@ function Env.AuraCount(units, spells, filter) for u = 1, #units do for i = 1, huge do - local buffName, _, _, _, _, _, _, _, _, id = UnitAura(units[u], i, filter) - if not buffName then + local data = GetAuraDataByIndex(units[u], i, filter) + if not data then break - elseif names[id] or names[strlowerCache[buffName]] then + elseif names[data.spellId] or names[strlowerCache[data.name]] then n = n + 1 end end @@ -100,18 +100,18 @@ function Env.AuraCountPacked(units, spells, kindKey, onlyMine) end function Env.AuraDur(unit, name, filter) - local buffName, _, duration, expirationTime, id + local data for i = 1, huge do - buffName, _, _, _, duration, expirationTime, _, _, _, id = UnitAura(unit, i, filter) - if not id or id == name or strlowerCache[buffName] == name then + data = GetAuraDataByIndex(unit, i, filter) + if not data or data.spellId == name or strlowerCache[data.name] == name then break end end - if not buffName then + if not data then return 0, 0, 0 else - return expirationTime == 0 and huge or expirationTime - TMW.time, duration, expirationTime + return data.expirationTime == 0 and huge or data.expirationTime - TMW.time, data.duration, data.expirationTime end end @@ -132,20 +132,18 @@ function Env.AuraDurPacked(unit, name, kindKey, onlyMine) end function Env.AuraPercent(unit, name, filter) - local isID = isNumber[name] - - local buffName, duration, expirationTime, id, _ + local data for i = 1, huge do - buffName, _, _, _, duration, expirationTime, _, _, _, id = UnitAura(unit, i, filter) - if not id or id == name or strlowerCache[buffName] == name then + data = GetAuraDataByIndex(unit, i, filter) + if not data or data.spellId == name or strlowerCache[data.name] == name then break end end - if not buffName then + if not data then return 0 else - return expirationTime == 0 and 1 or ((expirationTime - TMW.time) / duration) + return data.expirationTime == 0 and 1 or ((data.expirationTime - TMW.time) / data.duration) end end @@ -166,23 +164,17 @@ function Env.AuraPercentPacked(unit, name, kindKey, onlyMine) end function Env.AuraVariableNumber(unit, name, filter) - - local buffName, id, v1, v2, v3, v4, _ + local data for i = 1, huge do - buffName, _, _, _, _, _, _, _, _, id, _, _, _, _, _, v1, v2, v3, v4 = UnitAura(unit, i, filter) - if not id or id == name or strlowerCache[buffName] == name then + data = GetAuraDataByIndex(unit, i, filter) + if not data or data.spellId == name or strlowerCache[data.name] == name then break end end - if v1 and v1 > 0 then - return v1 - elseif v2 and v2 > 0 then - return v2 - elseif v3 and v3 > 0 then - return v3 - elseif v4 and v4 > 0 then - return v4 + for i = 1, #data.points do + local v = data.points[i] + if v and v > 0 then return v end end return 0 @@ -255,10 +247,10 @@ function Env.AuraTooltipNumber(...) local n for i = 1, 60 do - local buffName, _, _, _, _, _, _, _, _, id = UnitAura(unit, i, filter) - if not buffName then + local data = GetAuraDataByIndex(unit, i, filter) + if not data then break - elseif id == name or strlowerCache[buffName] == strlowerCache[name] then + elseif data.spellId == name or strlowerCache[data.name] == name then n = i break end diff --git a/Components/Core/Conditions/Categories/Talents.lua b/Components/Core/Conditions/Categories/Talents.lua index 69bf452a..fe6f285a 100644 --- a/Components/Core/Conditions/Categories/Talents.lua +++ b/Components/Core/Conditions/Categories/Talents.lua @@ -31,8 +31,8 @@ local GetSpecializationInfo, GetNumClasses = GetSpecializationInfo, GetNumClasses local GetNumBattlefieldScores, RequestBattlefieldScoreData, GetBattlefieldScore, GetNumArenaOpponents, GetArenaOpponentSpec = GetNumBattlefieldScores, RequestBattlefieldScoreData, GetBattlefieldScore, GetNumArenaOpponents, GetArenaOpponentSpec -local UnitAura, IsInJailersTower, C_SpecializationInfo, GetPvpTalentInfoByID = - UnitAura, IsInJailersTower, C_SpecializationInfo, GetPvpTalentInfoByID +local IsInJailersTower, C_SpecializationInfo, GetPvpTalentInfoByID = + IsInJailersTower, C_SpecializationInfo, GetPvpTalentInfoByID local GetSpellInfo = TMW.GetSpellInfo local GetSpellName = TMW.GetSpellName @@ -815,19 +815,24 @@ if IsInJailersTower then self.watching = false end end + + local GetAuraDataByIndex = C_UnitAuras.GetAuraDataByIndex function AnimaPowWatcher:UNIT_AURA(_, unit) if unit ~= "player" then return end for i=1, 300 do - local name, _, count, _, _, _, _, _, _, spellID = UnitAura("player", i, "MAW"); - if not spellID then return end + local data = GetAuraDataByIndex("player", i, "MAW"); + if not data then return end + + local spellId = data.spellId + local count = data.count if count == 0 then - count = 1; + count = 1 end - if currentAnimaPows[spellID] ~= count then - currentAnimaPows[spellID] = count; - currentAnimaPows[strlowerCache[name]] = count; + if currentAnimaPows[data.spellId] ~= count then + currentAnimaPows[data.spellId] = count; + currentAnimaPows[strlowerCache[data.name]] = count; TMW:Fire("TMW_ANIMA_POWER_COUNT_CHANGED") end end diff --git a/Components/IconModules/IconModule_CooldownSweep/CooldownSweep.lua b/Components/IconModules/IconModule_CooldownSweep/CooldownSweep.lua index e3981e64..beffecc7 100644 --- a/Components/IconModules/IconModule_CooldownSweep/CooldownSweep.lua +++ b/Components/IconModules/IconModule_CooldownSweep/CooldownSweep.lua @@ -19,6 +19,7 @@ local print = TMW.print local OnGCD = TMW.OnGCD +local IsAddOnLoaded = C_AddOns and C_AddOns.IsAddOnLoaded or IsAddOnLoaded local pairs, wipe = pairs, wipe diff --git a/Components/IconModules/IconModule_IconContainer_Masque/IconContainer_Masque.lua b/Components/IconModules/IconModule_IconContainer_Masque/IconContainer_Masque.lua index dd1d98b3..f12dff9e 100644 --- a/Components/IconModules/IconModule_IconContainer_Masque/IconContainer_Masque.lua +++ b/Components/IconModules/IconModule_IconContainer_Masque/IconContainer_Masque.lua @@ -17,6 +17,8 @@ local TMW = TMW local L = TMW.L local print = TMW.print +local GetAddOnInfo = C_AddOns and C_AddOns.GetAddOnInfo or GetAddOnInfo + local LMB = LibStub("Masque", true) or (LibMasque and LibMasque("Button")) diff --git a/Components/IconTypes/IconType_buff/buff.lua b/Components/IconTypes/IconType_buff/buff.lua index 42edc655..e4d30b57 100644 --- a/Components/IconTypes/IconType_buff/buff.lua +++ b/Components/IconTypes/IconType_buff/buff.lua @@ -17,7 +17,7 @@ local L = TMW.L local print = TMW.print local tonumber, pairs, type, format, select = tonumber, pairs, type, format, select -local UnitAura = UnitAura +local GetAuraDataByIndex = C_UnitAuras.GetAuraDataByIndex local GetSpellInfo = TMW.GetSpellInfo local GetSpellName = TMW.GetSpellName @@ -75,7 +75,7 @@ Type:RegisterIconDefaults{ -- Only check stealable auras. This DOES function for non-mages. Stealable = false, - -- Show variable text. This is the extra return values at the end of UnitAura. + -- Show variable text. This is the values in `points` on AuraData instances. -- It includes things like the strength of a shield spell. -- The first non-zero value from those variables will be reported as the icon's stack count. ShowTTText = false, @@ -285,7 +285,7 @@ local function Buff_OnUpdate(icon, time) local NotStealable = not icon.Stealable -- These variables will hold all the attributes that we pass to YieldInfo(). - local iconTexture, duration, expirationTime, caster, count, id, v1, v2, v3, useUnit, _ + local foundInstance, foundUnit local doesSort = DurationSort or StackSort @@ -308,63 +308,75 @@ local function Buff_OnUpdate(icon, time) local useFilter = Filter while true do - local _buffName, _iconTexture, _count, _dispelType, _duration, _expirationTime, _caster, canSteal, _, _id, _, _, _, _, _, _v1, _v2, _v3 = UnitAura(unit, index, useFilter) - index = index + 1 - - -- Bugfix: Enraged is an empty string. - if _dispelType == "" then - _dispelType = "Enraged" - end + local instance = GetAuraDataByIndex(unit, index, useFilter) - if not _buffName then + if not instance then -- If we reached the end of auras found for Filter, and icon.BuffOrDebuff == "EITHER", switch to Filterh -- iff we sort or haven't found anything yet. - if stage == 1 and Filterh and (doesSort or not id) then + if stage == 1 and Filterh and (doesSort or not foundInstance) then index, stage = 1, 2 useFilter = Filterh else - -- Break UnitAura loop (while true do ...) + -- Break GetAuraDataByIndex loop (while true do ...) break end + else + index = index + 1 - elseif (Hash[_id] or Hash[_dispelType] or Hash[strlowerCache[_buffName]]) and (NotStealable or (canSteal and not NOT_ACTUALLY_SPELLSTEALABLE[_id])) then - if DurationSort then - local remaining = (_expirationTime == 0 and huge) or _expirationTime - time + -- Bugfix: Enraged is an empty string. + local _dispelType = instance.dispelName + if _dispelType == "" then + _dispelType = "Enraged" + end - if not id or curSortDur*DurationSort < remaining*DurationSort then - -- DurationSort is either 1 or -1, so multiply by it to get the correct ordering. (multiplying by a negative flips inequalities) - -- If we haven't found anything yet, or if this aura beats the previous by sort order, then use it. - iconTexture, count, duration, expirationTime, caster, id, v1, v2, v3, useUnit, curSortDur = - _iconTexture, _count, _duration, _expirationTime, _caster, _id, _v1, _v2, _v3, unit, remaining - end - elseif StackSort then - local stack = _count or 0 + if + (Hash[instance.spellId] or Hash[_dispelType] or Hash[strlowerCache[instance.name]]) + and (NotStealable or (instance.isStealable and not NOT_ACTUALLY_SPELLSTEALABLE[instance.spellId])) + then + if DurationSort then + local remaining = (instance.expirationTime == 0 and huge) or instance.expirationTime - time - if not id or curSortStacks*StackSort < stack*StackSort then - -- StackSort is either 1 or -1, so multiply by it to get the correct ordering. (multiplying by a negative flips inequalities) - -- If we haven't found anything yet, or if this aura beats the previous by sort order, then use it. - iconTexture, count, duration, expirationTime, caster, id, v1, v2, v3, useUnit, curSortStacks = - _iconTexture, _count, _duration, _expirationTime, _caster, _id, _v1, _v2, _v3, unit, stack - end - else - -- We aren't sorting, and we haven't found anything yet, so record this - iconTexture, count, duration, expirationTime, caster, id, v1, v2, v3, useUnit = - _iconTexture, _count, _duration, _expirationTime, _caster, _id, _v1, _v2, _v3, unit + if not foundInstance or curSortDur*DurationSort < remaining*DurationSort then + -- DurationSort is either 1 or -1, so multiply by it to get the correct ordering. (multiplying by a negative flips inequalities) + -- If we haven't found anything yet, or if this aura beats the previous by sort order, then use it. + foundInstance = instance + foundUnit = unit + curSortDur = remaining + end + elseif StackSort then + local stack = instance.applications or 0 - -- We don't need to look for anything else. Stop looking. - break + if not foundInstance or curSortStacks*StackSort < stack*StackSort then + -- StackSort is either 1 or -1, so multiply by it to get the correct ordering. (multiplying by a negative flips inequalities) + -- If we haven't found anything yet, or if this aura beats the previous by sort order, then use it. + foundInstance = instance + foundUnit = unit + curSortStacks = stack + end + else + -- We aren't sorting, and we haven't found anything yet, so record this + foundInstance = instance + foundUnit = unit + + -- We don't need to look for anything else. Stop looking. + break + end end end end - if id and not doesSort then + if foundInstance and not doesSort then break -- break unit loop end end end - icon:YieldInfo(true, useUnit, iconTexture, count, duration, expirationTime, caster, id, v1, v2, v3) + if foundInstance then + icon:YieldInfo(true, foundUnit, foundInstance) + else + icon:YieldInfo(true, nil) + end end local GetAuras = TMW.COMMON.Auras.GetAuras @@ -441,21 +453,8 @@ local function Buff_OnUpdate_Packed(icon, time) end -- sourceunit may end up stale if UNIT_AURA doesnt trigger when the sourceunit gets assigned a new unitid? - -- todo: switch HandleYieldedInfo to accept an instance if foundInstance then - icon:YieldInfo( - true, - foundUnit, - foundInstance.icon, - foundInstance.applications, - foundInstance.duration, - foundInstance.expirationTime, - foundInstance.sourceUnit, - foundInstance.spellId, - foundInstance.points[1], - foundInstance.points[2], - foundInstance.points[3] - ) + icon:YieldInfo(true, foundUnit, foundInstance) else icon:YieldInfo(true, nil) end @@ -478,15 +477,9 @@ local function Buff_OnUpdate_Controller(icon, time) local filter = Filter while true do - local buffName, iconTexture, count, dispelType, duration, expirationTime, caster, canSteal, _, id, _, _, _, _, _, v1, v2, v3 = UnitAura(unit, index, filter) - index = index + 1 - - -- Bugfix: Enraged is an empty string. - if dispelType == "" then - dispelType = "Enraged" - end + local instance = GetAuraDataByIndex(unit, index, filter) - if not buffName then + if not instance then -- If we reached the end of auras found for filter, and icon.BuffOrDebuff == "EITHER", switch to Filterh -- iff we sort or haven't found anything yet. if stage == 1 and Filterh then @@ -495,14 +488,23 @@ local function Buff_OnUpdate_Controller(icon, time) else break end + else + index = index + 1 + + -- Bugfix: Enraged is an empty string. + local _dispelType = instance.dispelName + if _dispelType == "" then + _dispelType = "Enraged" + end - elseif (NameFirst == '' or Hash[id] or Hash[dispelType] or Hash[strlowerCache[buffName]]) - and (NotStealable or (canSteal and not NOT_ACTUALLY_SPELLSTEALABLE[id])) - then - - if not icon:YieldInfo(true, unit, iconTexture, count, duration, expirationTime, caster, id, v1, v2, v3) then - -- YieldInfo returns true if we need to keep harvesting data. Otherwise, it returns false. - return + if (NameFirst == '' or Hash[instance.spellId] or Hash[_dispelType] or Hash[strlowerCache[instance.name]]) + and (NotStealable or (instance.isStealable and not NOT_ACTUALLY_SPELLSTEALABLE[instance.spellId])) + then + + if not icon:YieldInfo(true, unit, instance) then + -- YieldInfo returns true if we need to keep harvesting data. Otherwise, it returns false. + return + end end end end @@ -551,19 +553,7 @@ local function Buff_OnUpdate_Controller_Packed(icon, time) for i = 1, #results do local instance = results[i] - if not icon:YieldInfo( - true, - unit, - instance.icon, - instance.applications, - instance.duration, - instance.expirationTime, - instance.sourceUnit, - instance.spellId, - instance.points[1], - instance.points[2], - instance.points[3] - ) then + if not icon:YieldInfo(true, unit, instance) then -- YieldInfo returns true if we need to keep harvesting data. Otherwise, it returns false. return end @@ -580,19 +570,7 @@ local function Buff_OnUpdate_Controller_Packed(icon, time) and (NotStealable or (instance.isStealable and not NOT_ACTUALLY_SPELLSTEALABLE[instance.spellId])) then - if not icon:YieldInfo( - true, - unit, - instance.icon, - instance.applications, - instance.duration, - instance.expirationTime, - instance.sourceUnit, - instance.spellId, - instance.points[1], - instance.points[2], - instance.points[3] - ) then + if not icon:YieldInfo(true, unit, instance) then -- YieldInfo returns true if we need to keep harvesting data. Otherwise, it returns false. return end @@ -607,26 +585,29 @@ local function Buff_OnUpdate_Controller_Packed(icon, time) icon:YieldInfo(false) end -function Type:HandleYieldedInfo(icon, iconToSet, unit, iconTexture, count, duration, expirationTime, caster, id, v1, v2, v3) +function Type:HandleYieldedInfo(icon, iconToSet, unit, instance) local Units = icon.Units -- Check that unit is defined here in order to determine if we found something. -- If icon.buffdebuff_iterateByAuraIndex == false, the code there might return a buffName -- that shouldn't actually be used because it didn't pass checks for stealable. - -- Unit is only defined there (as useUnit) once something is found that definitely matches. + -- Unit is only defined there (as foundUnit) once something is found that definitely matches. -- It is a bit bad that the code works this way, but it is nicer than manually nilling out all of the yielded info -- after determining that no matching auras were found. if unit then + local count = instance.count + if icon.ShowTTText then if icon.ShowTTText == true then - if v1 and v1 > 0 then - count = v1 - elseif v2 and v2 > 0 then - count = v2 - elseif v3 and v3 > 0 then - count = v3 - else - count = 0 + count = 0 + + local points = instance.points + for i = 1, #points do + local v = points[i] + if v and v > 0 then + count = v + break + end end else -- icon.ShowTTText is a number if it isn't false and it isn't true @@ -636,12 +617,12 @@ function Type:HandleYieldedInfo(icon, iconToSet, unit, iconTexture, count, durat iconToSet:SetInfo("state; texture; start, duration; stack, stackText; spell; unit, GUID; auraSourceUnit, auraSourceGUID", STATE_PRESENT, - iconTexture, - expirationTime - duration, duration, + instance.icon, + instance.expirationTime - instance.duration, instance.duration, count, count, - id, + instance.spellId, unit, nil, - caster, nil + instance.sourceUnit, nil ) elseif not Units[1] and icon.HideIfNoUnits then diff --git a/Components/IconTypes/IconType_buffcheck/buffcheck.lua b/Components/IconTypes/IconType_buffcheck/buffcheck.lua index feee9405..8dcd9e01 100644 --- a/Components/IconTypes/IconType_buffcheck/buffcheck.lua +++ b/Components/IconTypes/IconType_buffcheck/buffcheck.lua @@ -18,7 +18,7 @@ local print = TMW.print local tonumber, pairs = tonumber, pairs local UnitIsDeadOrGhost = UnitIsDeadOrGhost -local UnitAura = UnitAura +local GetAuraDataByIndex = C_UnitAuras.GetAuraDataByIndex local GetSpellTexture = TMW.GetSpellTexture local strlowerCache = TMW.strlowerCache @@ -139,7 +139,7 @@ local function BuffCheck_OnUpdate(icon, time) local PresentAlpha = icon.States[STATE_PRESENT].Alpha -- These variables will hold all the attributes that we pass to YieldInfo(). - local iconTexture, id, count, duration, expirationTime, caster, useUnit + local foundInstance, foundUnit local curSortDur = huge for u = 1, #Units do @@ -152,19 +152,20 @@ local function BuffCheck_OnUpdate(icon, time) local foundOnUnit = false for index = 1, huge do - local _buffName, _iconTexture, _count, _, _duration, _expirationTime, _caster, _, _, _id = UnitAura(unit, index, Filter) - if not _id then + local instance = GetAuraDataByIndex(unit, index, Filter) + if not instance then -- No more auras on the unit. Break spell loop. break - elseif Hash[_id] or Hash[strlowerCache[_buffName]] then + elseif Hash[instance.spellId] or Hash[strlowerCache[instance.name]] then foundOnUnit = true - local remaining = (_expirationTime == 0 and huge) or _expirationTime - time + local remaining = (instance.expirationTime == 0 and huge) or instance.expirationTime - time -- This icon type automatically sorts by lowest duration. - if not id or remaining < curSortDur then + if not foundInstance or remaining < curSortDur then -- If we haven't found anything yet, or if this aura beats the previous by sort order, then use it. - iconTexture, count, duration, expirationTime, caster, id, useUnit, curSortDur = - _iconTexture, _count, _duration, _expirationTime, _caster, _id, unit, remaining + foundInstance = instance + foundUnit = unit + curSortDur = remaining end if PresentAlpha == 0 then @@ -186,7 +187,7 @@ local function BuffCheck_OnUpdate(icon, time) -- We didn't find any units that were missing all the auras being checked. -- So, report the lowest duration aura that we did find. - icon:YieldInfo(false, useUnit, iconTexture, count, duration, expirationTime, caster, id) + icon:YieldInfo(false, foundUnit, foundInstance) end local GetAuras = TMW.COMMON.Auras.GetAuras @@ -262,21 +263,13 @@ local function BuffCheck_OnUpdate_Packed(icon, time) -- We didn't find any units that were missing all the auras being checked. -- So, report the lowest duration aura that we did find. if foundInstance then - icon:YieldInfo(false, - foundUnit, - foundInstance.icon, - foundInstance.applications, - foundInstance.duration, - foundInstance.expirationTime, - foundInstance.sourceUnit, - foundInstance.spellId - ) + icon:YieldInfo(false, foundUnit, foundInstance) else icon:YieldInfo(false, nil) end end -function Type:HandleYieldedInfo(icon, iconToSet, unit, iconTexture, count, duration, expirationTime, caster, id) +function Type:HandleYieldedInfo(icon, iconToSet, unit, instance) if not unit then -- Unit is nil if the icon didn't check any living units. iconToSet:SetInfo("state; texture; start, duration; stack, stackText; spell; unit, GUID; auraSourceUnit, auraSourceGUID", @@ -288,7 +281,7 @@ function Type:HandleYieldedInfo(icon, iconToSet, unit, iconTexture, count, durat nil, nil, nil, nil ) - elseif not id then + elseif not instance then -- ID is nil if we found a unit that is missing all of the auras that are being checked for. iconToSet:SetInfo("state; texture; start, duration; stack, stackText; spell; unit, GUID; auraSourceUnit, auraSourceGUID", STATE_ABSENT, @@ -299,17 +292,17 @@ function Type:HandleYieldedInfo(icon, iconToSet, unit, iconTexture, count, durat unit, nil, nil, nil ) - elseif id then + elseif instance then -- ID is defined if we didn't find any units that are missing all the auras being checked for. -- In this case, the data is for the first matching aura found on the first unit checked. iconToSet:SetInfo("state; texture; start, duration; stack, stackText; spell; unit, GUID; auraSourceUnit, auraSourceGUID", STATE_PRESENT, - iconTexture, - expirationTime - duration, duration, - count, count, - id, + instance.icon, + instance.expirationTime - instance.duration, instance.duration, + instance.applications, instance.applications, + instance.spellId, unit, nil, - caster, nil + instance.sourceUnit, nil ) end end diff --git a/Components/IconTypes/IconType_dotwatch/dotwatch.lua b/Components/IconTypes/IconType_dotwatch/dotwatch.lua index dc68f5e1..22c3ab69 100644 --- a/Components/IconTypes/IconType_dotwatch/dotwatch.lua +++ b/Components/IconTypes/IconType_dotwatch/dotwatch.lua @@ -17,9 +17,10 @@ local L = TMW.L local print = TMW.print local type, wipe, pairs, rawget, abs, min, next, GetTime = type, wipe, pairs, rawget, abs, min, next, GetTime -local UnitGUID, UnitAura, UnitName = - UnitGUID, UnitAura, UnitName +local UnitGUID, UnitName = + UnitGUID, UnitName +local GetAuraDataByIndex = C_UnitAuras.GetAuraDataByIndex local C_Timer = C_Timer local huge = math.huge @@ -155,18 +156,20 @@ local function CreateAllUnits() end local function ScanForAura(GUID, spellName, spellID) + local time = GetTime() + for i = 1, #AllUnits do local unit = AllUnits[i] if GUID == UnitGUID(unit) then - local buffName, duration, expirationTime, id, _ + local instance local index, stage = 1, 1 local filter = "HELPFUL|PLAYER" while true do - buffName, _, _, _, duration, expirationTime, _, _, _, id = UnitAura(unit, index, filter) + instance = GetAuraDataByIndex(unit, index, filter) index = index + 1 - if not id then + if not instance then if stage == 1 then -- If we reached the end of auras found for buffs, switch to debuffs index, stage = 1, 2 @@ -176,12 +179,12 @@ local function ScanForAura(GUID, spellName, spellID) end elseif -- Spell matches - (id == spellID or buffName == spellName) and + (instance.spellId == spellID or instance.name == spellName) and -- Make sure that this is an application that just happened before returning the duration. -- Or, if the duration is 0, then this effect has no duration. - duration == 0 or abs((GetTime() + duration) - expirationTime) < 0.1 + instance.duration == 0 or abs((time + instance.duration) - instance.expirationTime) < 0.1 then - return duration + return instance.duration end end @@ -203,11 +206,24 @@ local function VerifyAll() local filter = "HELPFUL|PLAYER" while true do - local buffName, _, count, _, duration, expirationTime, _, _, _, spellID = UnitAura(unit, index, filter) + local instance = GetAuraDataByIndex(unit, index, filter) index = index + 1 - if spellID then - buffName = strlowerCache[buffName] + if not instance then + -- If we reached the end of auras found for buffs, switch to debuffs + if stage == 1 then + index, stage = 1, 2 + filter = "HARMFUL|PLAYER" + else + -- Break while true loop (spell loop) + break + end + else + local buffName = strlowerCache[instance.name] + local count = instance.applications + local duration = instance.duration + local expirationTime = instance.expirationTime + local spellID = instance.spellId auras = auras or Auras[GUID] local aura = auras[spellID] @@ -241,15 +257,6 @@ local function VerifyAll() end end end - else - -- If we reached the end of auras found for buffs, switch to debuffs - if stage == 1 then - index, stage = 1, 2 - filter = "HARMFUL|PLAYER" - else - -- Break while true loop (spell loop) - break - end end end diff --git a/TellMeWhen.lua b/TellMeWhen.lua index f9291afd..a6dc345f 100644 --- a/TellMeWhen.lua +++ b/TellMeWhen.lua @@ -16,6 +16,11 @@ -- --------------------------------- local GetAddOnMetadata = C_AddOns and C_AddOns.GetAddOnMetadata or GetAddOnMetadata +local LoadAddOn = C_AddOns and C_AddOns.LoadAddOn or LoadAddOn +local EnableAddOn = C_AddOns and C_AddOns.EnableAddOn or EnableAddOn +local IsAddOnLoaded = C_AddOns and C_AddOns.IsAddOnLoaded or IsAddOnLoaded + + TELLMEWHEN_VERSION = GetAddOnMetadata("TellMeWhen", "Version") TELLMEWHEN_VERSION_MINOR = "" @@ -165,8 +170,6 @@ local InCombatLockdown, GetTalentInfo = InCombatLockdown, GetTalentInfo local IsInGuild, IsInGroup, IsInInstance = IsInGuild, IsInGroup, IsInInstance -local GetAddOnInfo, IsAddOnLoaded, LoadAddOn, EnableAddOn, GetBuildInfo = - GetAddOnInfo, IsAddOnLoaded, LoadAddOn, EnableAddOn, GetBuildInfo local tonumber, tostring, type, pairs, ipairs, tinsert, tremove, sort, select, wipe, rawget, rawset, assert, pcall, error, getmetatable, setmetatable, loadstring, unpack, debugstack = tonumber, tostring, type, pairs, ipairs, tinsert, tremove, sort, select, wipe, rawget, rawset, assert, pcall, error, getmetatable, setmetatable, loadstring, unpack, debugstack local strfind, strmatch, format, gsub, gmatch, strsub, strtrim, strsplit, strlower, strrep, strchar, strconcat, strjoin, max, ceil, floor, random =