Fix losing custom units in GUID roster

This commit is contained in:
OldManAlpha 2025-09-02 16:44:07 -07:00
parent 119a2381c6
commit 5049852079
4 changed files with 36 additions and 12 deletions

View File

@ -262,18 +262,36 @@ function OnAddonLoaded()
-- Older versions of SuperWoW had an issue where units that aren't part of normal units wouldn't receive events,
-- so updates are done manually
local needsManualUpdates = util.SuperWoWFeatureLevel < util.SuperWoW_v1_4
local existing = {}
local nextCleanup = GetTime() + 10
customUnitUpdater:SetScript("OnUpdate", function()
if GetTime() > nextUpdate then
nextUpdate = GetTime() + 0.25
for unit, guid in pairs(CustomUnitGUIDMap) do
if needsManualUpdates or not UnitExists(guid) then
PTUnit.Get(unit):UpdateAuras()
for ui in UnitFrames(unit) do
ui:UpdateHealth()
ui:UpdatePower()
ui:UpdateAuras()
ui:UpdateIncomingHealing()
for guid, units in pairs(GUIDCustomUnitMap) do
local exists = UnitExists(guid) == 1
local needsUpdate = false
if (existing[guid] ~= nil) ~= exists then
existing[guid] = exists or nil
needsUpdate = true
end
if needsManualUpdates or needsUpdate then
PTUnit.Get(guid):UpdateAuras()
for _, unit in ipairs(units) do
for ui in UnitFrames(unit) do
ui:UpdateAll()
ui:UpdateIncomingHealing()
end
end
end
end
if GetTime() > nextCleanup then
nextCleanup = GetTime() + 10
for guid in pairs(existing) do
if not GUIDCustomUnitMap[guid] then
existing[guid] = nil
end
end
end

View File

@ -16,7 +16,7 @@ SlashCmdList["PUPPETEER"] = function(args)
elseif args == "check" then
Puppeteer.CheckGroup()
elseif args == "update" then
for _, ui in pairs(Puppeteer.AllUnitFrames) do
for _, ui in ipairs(Puppeteer.AllUnitFrames) do
ui:SizeElements()
ui:UpdateAll()
end
@ -28,7 +28,7 @@ SlashCmdList["PUPPETEER"] = function(args)
PTOptions.TestUI = not PTOptions.TestUI
Puppeteer.TestUI = PTOptions.TestUI
if PTOptions.TestUI then
for _, ui in pairs(Puppeteer.AllUnitFrames) do
for _, ui in ipairs(Puppeteer.AllUnitFrames) do
ui.fakeStats = ui.GenerateFakeStats()
ui:Show()
end

View File

@ -24,12 +24,17 @@ function ResetRoster()
end
function PopulateRoster()
for _, unit in ipairs(util.AllUnits) do
for _, unit in ipairs(util.AllRealUnits) do
local exists, guid = UnitExists(unit)
if exists then
AddUnit(guid, unit)
end
end
for guid, units in pairs(PTUnitProxy.GUIDCustomUnitMap) do
for _, unit in ipairs(units) do
AddUnit(guid, unit)
end
end
end
function AddUnit(guid, unit)

View File

@ -8,6 +8,7 @@ local _G = getfenv(0)
local util = PTUtil
local GetAuraInfo = util.GetAuraInfo
local AllUnits = util.AllUnits
local AllRealUnits = util.AllRealUnits
local AllUnitsSet = util.AllUnitsSet
local superwow = util.IsSuperWowPresent()
local canGetAuraIDs = util.CanClientGetAuraIDs()
@ -54,7 +55,7 @@ end
function UpdateGuidCaches()
local cached = PTUnit.Cached
local prevCached = PTUtil.CloneTableCompost(cached)
for _, unit in ipairs(AllUnits) do
for _, unit in ipairs(AllRealUnits) do
local exists, guid = UnitExists(unit)
if exists then
if not cached[guid] then