73e3077 - Move extra action/zone ability again
[wowui.git] / OmaRF / Indicators.lua
index 49f3ba1..abd52ec 100644 (file)
@@ -2,6 +2,7 @@
 local pairs, ipairs = pairs, ipairs;
 local floor = math.floor;
 local GetTime = GetTime;
+local UnitExists = UnitExists;
 local UnitAura = UnitAura;
 local CreateFrame = CreateFrame;
 local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected;
@@ -54,7 +55,9 @@ function M.SetupIndicators(frame, class)
 
     frame.throttle = function()
         frame.throttled = nil;
-        updateAuras(frame, frame.displayed);
+        if UnitExists(frame.displayed) then
+            return updateAuras(frame, frame.displayed);
+        end
     end;
 end
 
@@ -128,13 +131,13 @@ end
 function M.UpdateAuras(frame, unit)
     local current = GetTime();
     if frame.throttled then
-        print("updateAuras throttled for ", unit); -- TODO debug print
         return;
-    elseif frame.prevUpdate - current < 0.1 then
+    elseif frame.prevUpdate and current - frame.prevUpdate < 0.2 then
         frame.throttled = true;
-        return CTimerAfter(0.1, frame.throttle);
+        return CTimerAfter(0.2, frame.throttle);
     end
 
+    frame.prevUpdate = current;
     for _, ind in pairs(frame.inds) do
         hideInd(ind);
     end
@@ -142,7 +145,7 @@ function M.UpdateAuras(frame, unit)
     local showInds, needUpdate = false, false;
     local i = 1;
     while true do
-        _, _, icon, count, _, _, expires, _, _, _, id = UnitAura(unit, i, "PLAYER HELPFUL");
+        _, icon, count, _, _, expires, _, _, _, id = UnitAura(unit, i, "PLAYER HELPFUL");
         if not id then break end
         local pos = watchedAuras[id];
         if pos then
@@ -174,19 +177,22 @@ function M.UpdateMajorAuras(frame, unit)
     for _, ind in pairs(frame.majors) do
         hideInd(ind);
     end
-    local icon, count, expires, id;
+    if UnitIsDeadOrGhost(unit) then return end
+    local name, icon, count, expires, id;
     local showMajors, needUpdate = false, false;
     local majorPos = 1;
     local alert = false; -- color the whole bar
     local current = GetTime();
     local i = 1;
     while true do
-        _, _, icon, count, _, _, expires, _, _, _, id = UnitAura(unit, i, "HARMFUL");
+        name, icon, count, _, _, expires, _, _, _, id = UnitAura(unit, i, "HARMFUL");
         if not id or majorPos > 3 then break end
-        local major = majorAuras[id];
+        local major = majorAuras[id] or majorAuras[name];
         if major then
-            needUpdate = showInd(frame.majors[majorPos], expires, current, count, icon) or needUpdate;
-            if major.bar then alert = true end
+            if not major.noicon then
+                needUpdate = showInd(frame.majors[majorPos], expires, current, count, icon) or needUpdate;
+            end
+            if major.bar then alert = major.bar end
             showMajors = true;
             majorPos = majorPos + 1;
         end