From 89fec7abdcd7b3bc1f0a116540c5f86cb5873d74 Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 30 Aug 2019 19:57:45 +0200 Subject: [PATCH] castbar: prefer unitstrings over names --- libs/libcast.lua | 6 ++++++ modules/castbar.lua | 10 ++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libs/libcast.lua b/libs/libcast.lua index c2290ce3..50fc254f 100644 --- a/libs/libcast.lua +++ b/libs/libcast.lua @@ -51,6 +51,9 @@ local libcast = CreateFrame("Frame", "pfEnemyCast") local player = UnitName("player") UnitChannelInfo = _G.UnitChannelInfo or function(unit) + -- convert to name if unitstring was given + unit = pfValidUnits[unit] and UnitName(unit) or unit + local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill local db = libcast.db[unit] @@ -77,6 +80,9 @@ UnitChannelInfo = _G.UnitChannelInfo or function(unit) end UnitCastingInfo = _G.UnitCastingInfo or function(unit) + -- convert to name if unitstring was given + unit = pfValidUnits[unit] and UnitName(unit) or unit + local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill local db = libcast.db[unit] diff --git a/modules/castbar.lua b/modules/castbar.lua index b92f5de1..ff59e1da 100644 --- a/modules/castbar.lua +++ b/modules/castbar.lua @@ -92,10 +92,10 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function () local name = this.unitstr and UnitName(this.unitstr) or this.unitname if not name then return end - local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(name) + local cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(this.unitstr or this.unitname) if not cast then -- scan for channel spells if no cast was found - cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(name) + cast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitChannelInfo(this.unitstr or this.unitname) end if cast then @@ -167,13 +167,11 @@ pfUI:RegisterModule("castbar", "vanilla:tbc", function () if this.unitstr and not UnitIsUnit(this.unitstr, "player") then return end if event == CASTBAR_EVENT_CAST_DELAY then - local name = this.unitstr and UnitName(this.unitstr) or this.unitname - local isCast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(name) + local isCast, nameSubtext, text, texture, startTime, endTime, isTradeSkill = UnitCastingInfo(this.unitstr or this.unitname) if not isCast then return end this.delay = this.delay + (endTime - this.endTime) / 1000 elseif event == CASTBAR_EVENT_CHANNEL_DELAY then - local name = this.unitstr and UnitName(this.unitstr) or this.unitname - local isChannel, _, _, _, startTime, endTime = UnitChannelInfo(name) + local isChannel, _, _, _, startTime, endTime = UnitChannelInfo(this.unitstr or this.unitname) if not isChannel then return end this.delay = ( this.delay or 0 ) + this.bar:GetValue() - (endTime/1000 - GetTime()) end