end |
|
|
local function ProcessPet(unitid) |
if not unitid then return nil end |
local changed |
|
if not UnitExists(unitid) then |
unknownUnits[unitid] = nil |
-- find the pet in the roster we need to delete |
for _,u in pairs(roster) do |
if u.unitid == unitid then |
AloftRoster:RemoveUnit(u.name) |
changed = true |
end |
end |
else |
changed = select(2, AloftRoster:CreateOrUpdateUnit(unitid)) |
end |
AloftRoster:ProcessRoster() |
|
return changed |
end |
|
function AloftRoster:ScanPet(owner_list) |
local changed |
for owner in pairs(owner_list) do |
local unitid = self:GetPetFromOwner(owner) |
if not unitid then return end |
|
if not UnitExists(unitid) then |
unknownUnits[unitid] = nil |
-- find the pet in the roster we need to delete |
for _,u in pairs(roster) do |
if u.unitid == unitid then |
self:RemoveUnit(u.name) |
changed = true |
end |
if owner_list then |
if type(owner_list) == "string" then |
local unitid = self:GetPetFromOwner(owner_list) |
changed = ProcessPet(unitid) |
elseif type(owner_list) == "table" then |
for owner in pairs(owner_list) do |
local unitid = self:GetPetFromOwner(owner) |
changed = ProcessPet(unitid) |
end |
else |
changed = select(2, self:CreateOrUpdateUnit(unitid)) |
end |
self:ProcessRoster() |
end |
if changed then |
self:SendMessage("AloftRoster_RosterUpdated") |