Fix a possible "table index is nil" error that can happen while zoning in Test Mode.
This commit is contained in:
@@ -1230,6 +1230,7 @@ function Omen:UpdateBars()
|
||||
|
||||
-- TODO: Put a update throtle on this function
|
||||
|
||||
local myGUID = UnitGUID("player")
|
||||
local dbBar = db.Bar
|
||||
local mob, mobGUID, mobTargetGUID
|
||||
topthreat = -1
|
||||
@@ -1239,8 +1240,8 @@ function Omen:UpdateBars()
|
||||
local classes = self.Options.args.ShowClasses.args.Classes.values
|
||||
local key = next(classes)
|
||||
for i = 1, 25 do
|
||||
if i == 22 then
|
||||
threatTable[UnitGUID("player")] = i*5000
|
||||
if i == 22 and myGUID then -- Because I've got myGUID == nil before
|
||||
threatTable[myGUID] = i*5000
|
||||
else
|
||||
threatTable[i] = i*5000
|
||||
guidNameLookup[i] = classes[key]
|
||||
@@ -1349,7 +1350,6 @@ function Omen:UpdateBars()
|
||||
topthreat = threatTable[sortTable[1]]
|
||||
if topthreat == 0 then topthreat = 1 end -- To avoid 0/0 division
|
||||
local showSelfYet = true
|
||||
local myGUID = UnitGUID("player")
|
||||
|
||||
if dbBar.AlwaysShowSelf then
|
||||
-- Check if we're one of the bars to be displayed
|
||||
@@ -1443,16 +1443,15 @@ function Omen:UpdateBars()
|
||||
-- Threat warnings
|
||||
if testMode then
|
||||
threatTable = delTable(threatTable)
|
||||
else
|
||||
local pGUID = UnitGUID("player")
|
||||
local pClass = guidClassLookup[pGUID]
|
||||
local myThreatPercent = threatTable[pGUID] / tankThreat * 100
|
||||
elseif myGUID then
|
||||
local myClass = guidClassLookup[myGUID]
|
||||
local myThreatPercent = threatTable[myGUID] / tankThreat * 100
|
||||
local t = db.Warnings
|
||||
if lastWarn.mobGUID == mobGUID and myThreatPercent >= t.Threshold and t.Threshold > lastWarn.threatpercent then
|
||||
if not t.DisableWhileTanking or not (pClass == "WARRIOR" and GetBonusBarOffset() == 2 or
|
||||
pClass == "DRUID" and GetBonusBarOffset() == 3 or
|
||||
pClass == "PALADIN" and UnitAura("player", GetSpellInfo(25780)) or
|
||||
pClass == "DEATHKNIGHT" and GetShapeshiftFormInfo(GetShapeshiftForm()) == "Interface\\Icons\\Spell_Deathknight_FrostPresence") then
|
||||
if not t.DisableWhileTanking or not (myClass == "WARRIOR" and GetBonusBarOffset() == 2 or
|
||||
myClass == "DRUID" and GetBonusBarOffset() == 3 or
|
||||
myClass == "PALADIN" and UnitAura("player", GetSpellInfo(25780)) or
|
||||
myClass == "DEATHKNIGHT" and GetShapeshiftFormInfo(GetShapeshiftForm()) == "Interface\\Icons\\Spell_Deathknight_FrostPresence") then
|
||||
self:Warn(t.Sound, t.Flash, t.Shake, t.Message and L["Passed %s%% of %s's threat!"]:format(t.Threshold, guidNameLookup[tankGUID or mobTargetGUID or sortTable[1]]))
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user