From 756e8840afe1d494f788c17be67bc0a9133c59b7 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Mon, 20 Jul 2026 14:12:07 -0500 Subject: [PATCH] Keep the rangecheck scanner alive across zones and roster changes PLAYER_LEAVING_WORLD fires on every loading screen, not just logout, but librange treated it as terminal: it latched librange_isLoggingOut and tore OnUpdate off the frame, neither of which was ever restored. So the first zone (into a BG, dungeon, etc.) permanently killed the distance scan -- unitdata stopped updating and UnitInSpellRange defaulted every unit to in-range until /reload, which the next loading screen then undid. Only PLAYER_LOGOUT is terminal now; PLAYER_LEAVING_WORLD just hides for the loading screen and PLAYER_ENTERING_WORLD re-shows it. Also invalidate on RAID_ROSTER_UPDATE / PARTY_MEMBERS_CHANGED: the range state is cached per unit token, so a roster re-index leaves each unitN mapped to a different player with stale data. Clear the token cache and restart the sweep so shifted/joined slots are re-evaluated within one pass instead of inheriting the previous occupant's range. --- libs/librange.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libs/librange.lua b/libs/librange.lua index ef3ef5c7..71f11fe4 100644 --- a/libs/librange.lua +++ b/libs/librange.lua @@ -61,14 +61,30 @@ librange:RegisterEvent("ACTIONBAR_SLOT_CHANGED") librange:RegisterEvent("PLAYER_ENTERING_WORLD") librange:RegisterEvent("PLAYER_LOGOUT") librange:RegisterEvent("PLAYER_LEAVING_WORLD") +librange:RegisterEvent("RAID_ROSTER_UPDATE") +librange:RegisterEvent("PARTY_MEMBERS_CHANGED") librange:SetScript("OnEvent", function() - if event == "PLAYER_LOGOUT" or event == "PLAYER_LEAVING_WORLD" then + if event == "PLAYER_LOGOUT" then librange_isLoggingOut = true - this:SetScript("OnUpdate", nil) this:Hide() return end + if event == "PLAYER_LEAVING_WORLD" then + this:Hide() + return + end + + if event == "RAID_ROSTER_UPDATE" or event == "PARTY_MEMBERS_CHANGED" then + -- Roster re-index: unitN tokens now map to different players, so the + -- token->realunit cache is stale. Clear it and restart the sweep from + -- the top so shifted/joined slots are re-evaluated within one pass + -- instead of inheriting the previous occupant's cached range. + for k in pairs(unitcache) do unitcache[k] = nil end + this.id = 1 + return + end + if pfUI_config.unitframes.rangecheck == "0" then this:Hide() return