Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 53 additions & 15 deletions EllesmereUICooldownManager/EllesmereUICdmHooks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -961,10 +961,10 @@ local _cdidRouteMap = {}

local _divertedSpellsBuff = {}
local _divertedSpellsCD = {}
-- cooldownID-level buff diversions: a collided buff (two viewer slots sharing one
-- canonical spellID) is tracked on a custom bar by cooldownID (cd-claim marker in
-- assignedSpells, ns.CdClaimMarker); checked BEFORE the sid map, so it outranks a pair claim.
local _divertedBuffCdIDs = {}
-- CooldownID-level diversions: collided Buff or CD/Utility viewer slots are
-- tracked by cooldownID (cd-claim marker in assignedSpells, ns.CdClaimMarker).
-- Checked before the sid maps so one family claim never captures its sibling.
local _divertedCdIDs = {}
--- Equipment-slot diversions, inventory slot -> barKey. Blizzard's own equipment
--- cooldown entry carries an equipSlot and NO spell of its own, so the slot is its
--- only routing key; a bar listing that slot (-13/-14 et al) claims the frame the
Expand Down Expand Up @@ -1151,15 +1151,29 @@ local _routeMapBuilt = false
--- overwrite via preserveExisting=false. Family split: each bar writes
--- _divertedSpellsBuff or _divertedSpellsCD so buff/CD bars claiming the same
--- spellID (e.g. Divine Shield 642) never clobber each other.
function ns.RefreshRedundantOverrideClaims()
local updated = ns.GetRedundantOverrideClaims
and ns.GetRedundantOverrideClaims(_divertedCdIDs) or {}
local previous = ns._redundantOverrideClaims or {}
local changed = false
for cdID in pairs(updated) do if not previous[cdID] then changed = true; break end end
if not changed then
for cdID in pairs(previous) do if not updated[cdID] then changed = true; break end end
end
ns._redundantOverrideClaims = updated
if changed then wipe(_cdidRouteMap) end
end

function ns.RebuildSpellRouteMap()
wipe(_cdidRouteMap)
ns._redundantOverrideClaims = nil
wipe(_divertedSpellsBuff)
wipe(_divertedSpellsCD)
wipe(_divertedDirectBuff)
wipe(_divertedDirectCD)
wipe(_divertedVarBaseBuff)
wipe(_divertedVarBaseCD)
wipe(_divertedBuffCdIDs)
wipe(_divertedCdIDs)
wipe(ns._divertedSlotCD)
wipe(ns._buffReplaceTarget)
wipe(ns._buffReplaceTargetCd)
Expand Down Expand Up @@ -1244,7 +1258,7 @@ function ns.RebuildSpellRouteMap()
local claims = sd and ns.CollectCdClaimSet(sd)
if claims then
for cdID in pairs(claims) do
_divertedBuffCdIDs[cdID] = bd.key
_divertedCdIDs[cdID] = bd.key
end
end
end
Expand Down Expand Up @@ -1291,12 +1305,12 @@ function ns.RebuildSpellRouteMap()
end
-- Cd-claimed hosted buffs (collided slots hosted by cd-claim marker instead
-- of the sid-keyed hostedBuffSpellIDs flag): claim the cooldownID in
-- _divertedBuffCdIDs, same map/priority as Pass 1. ResolveCDIDToBar checks
-- _divertedCdIDs, same map/priority as Pass 1. ResolveCDIDToBar checks
-- it before any sid map, so it works for any target bar type.
local claims = sd and ns.CollectCdClaimSet(sd)
if claims then
for cdID in pairs(claims) do
_divertedBuffCdIDs[cdID] = bd.key
_divertedCdIDs[cdID] = bd.key
end
end
end
Expand Down Expand Up @@ -1379,9 +1393,15 @@ function ns.RebuildSpellRouteMap()
for _, bd in ipairs(p.cdmBars.bars) do
if bd.enabled and bd.isGhostBar then
CollectDiversionsFor(bd, ghostAliasSkip)
local claims = ns.GetBarSpellData(bd.key)
claims = claims and ns.CollectCdClaimSet(claims)
if claims then
for cdID in pairs(claims) do _divertedCdIDs[cdID] = bd.key end
end
end
end

ns.RefreshRedundantOverrideClaims()
_routeMapBuilt = true
end

Expand All @@ -1405,14 +1425,20 @@ local function ResolveCDIDToBar(cdID, viewerDefaultBar)
local cached = _cdidRouteMap[cdID]
if cached then return cached end

-- cooldownID-level claim first (collided buffs tracked by slot). Needs no
-- Transiently suppress only the overridden base. Its saved bar and order
-- remain intact, and rebuilding after a talent swap restores its route.
if ns._redundantOverrideClaims and ns._redundantOverrideClaims[cdID] then
local hiddenBar = ns.GHOST_CD_BAR_KEY or "__ghost_cd"
_cdidRouteMap[cdID] = hiddenBar
return hiddenBar
end

-- cooldownID-level claim first (collided Buff or CD/Utility slot). Needs no
-- cooldownInfo read, so it also works while every sid field is secret.
if viewerDefaultBar == "buffs" then
local cdRoute = _divertedBuffCdIDs[cdID]
if cdRoute then
_cdidRouteMap[cdID] = cdRoute
return cdRoute
end
local cdRoute = _divertedCdIDs[cdID]
if cdRoute then
_cdidRouteMap[cdID] = cdRoute
return cdRoute
end

local RVV = ns.ResolveVariantValue
Expand Down Expand Up @@ -6638,6 +6664,8 @@ local function CollectAndReanchor()
-- diversions) and NOT _cdidRouteMap (lazy cache, empty post-build).
if not _routeMapBuilt and ns.RebuildSpellRouteMap then
ns.RebuildSpellRouteMap()
else
ns.RefreshRedundantOverrideClaims()
end

wipe(_scratch_usedFrames)
Expand Down Expand Up @@ -8669,6 +8697,16 @@ local function CollectAndReanchor()
if ns.QueueReanchor then ns.QueueReanchor() end
end
end
-- Live-only compatibility pass: when two CD/Utility cooldownIDs share
-- one spell family, replace a legacy positive family claim with one
-- exact slot marker. The sibling then keeps its Blizzard viewer home.
if prof and prof._barFilterModelV6 and ns.MigrateCollidedCDAssignments then
local migrated = ns.MigrateCollidedCDAssignments()
if migrated and migrated > 0 then
if ns.RebuildSpellRouteMap then ns.RebuildSpellRouteMap() end
if ns.QueueReanchor then ns.QueueReanchor() end
end
end
-- Automatic base-bar materialization (once per spec+layout per session):
-- untouched default-bar spells render through the frames-as-truth fallback
-- without ever being recorded in assignedSpells, so export strings shipped
Expand Down
Loading