mirror of
https://github.com/OldManAlpha/Puppeteer.git
synced 2025-11-28 23:48:35 +00:00
Fix losing custom units in GUID roster
This commit is contained in:
parent
119a2381c6
commit
5049852079
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user