Skip to content

Commit

Permalink
Added Details:GetUntitClass(unitId), this call handles the Ambiguate …
Browse files Browse the repository at this point in the history
…in combatlog's player name when calling UnitClass
  • Loading branch information
Tercioo committed Nov 8, 2023
1 parent 3b2ba40 commit 5e7df0d
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 32 deletions.
19 changes: 17 additions & 2 deletions boot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
local addonName, Details222 = ...
local version, build, date, tocversion = GetBuildInfo()

Details.build_counter = 12025
Details.alpha_build_counter = 12025 --if this is higher than the regular counter, use it instead
Details.build_counter = 12026
Details.alpha_build_counter = 12026 --if this is higher than the regular counter, use it instead
Details.dont_open_news = true
Details.game_version = version
Details.userversion = version .. " " .. Details.build_counter
Expand Down Expand Up @@ -1360,6 +1360,21 @@ if (select(4, GetBuildInfo()) >= 100000) then
end)
end

local classCacheName = Details222.ClassCache.ByName
local classCacheGUID = Details222.ClassCache.ByGUID

function Details222.ClassCache.GetClassFromCache(value)
return classCacheName[value] or classCacheGUID[value]
end

function Details222.ClassCache.AddClassToCache(value, whichCache)
if (whichCache == "name") then
classCacheName[value] = true
elseif (whichCache == "guid") then
classCacheGUID[value] = true
end
end

function Details222.ClassCache.GetClass(value)
local className = Details222.ClassCache.ByName[value] or Details222.ClassCache.ByGUID[value]
if (className) then
Expand Down
18 changes: 9 additions & 9 deletions classes/class_utility.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1514,10 +1514,10 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)

for playername, potspellid in pairs(pot_usage) do
local name, _, icon = _GetSpellInfo(potspellid)
local _, class = UnitClass(playername)
local unitClass = Details:GetUnitClass(playername)
local class_color = ""
if (class and RAID_CLASS_COLORS [class]) then
class_color = RAID_CLASS_COLORS [class].colorStr
if (unitClass and RAID_CLASS_COLORS[unitClass]) then
class_color = RAID_CLASS_COLORS[unitClass].colorStr
end
string_output = string_output .. "|c" .. class_color .. playername .. "|r |T" .. icon .. ":14:14:0:0:64:64:0:64:0:64|t "
end
Expand Down Expand Up @@ -1586,10 +1586,10 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)

for playername, potspellid in pairs(pot_usage) do
local name, _, icon = _GetSpellInfo(potspellid)
local _, class = UnitClass(playername)
local unitClass = Details:GetUnitClass(playername)
local class_color = ""
if (class and RAID_CLASS_COLORS [class]) then
class_color = RAID_CLASS_COLORS [class].colorStr
if (unitClass and RAID_CLASS_COLORS[unitClass]) then
class_color = RAID_CLASS_COLORS[unitClass].colorStr
end
string_output = string_output .. "|c" .. class_color .. playername .. "|r |T" .. icon .. ":14:14:0:0:64:64:0:64:0:64|t "
end
Expand Down Expand Up @@ -1627,10 +1627,10 @@ function _detalhes:CatchRaidBuffUptime (in_or_out)
local string_output = "pre-potion: "
for playername, potspellid in pairs(pot_usage) do
local name, _, icon = _GetSpellInfo(potspellid)
local _, class = UnitClass(playername)
local unitClass = Details:GetUnitClass(playername)
local class_color = ""
if (class and RAID_CLASS_COLORS [class]) then
class_color = RAID_CLASS_COLORS [class].colorStr
if (unitClass and RAID_CLASS_COLORS[unitClass]) then
class_color = RAID_CLASS_COLORS[unitClass].colorStr
end
string_output = string_output .. "|c" .. class_color .. playername .. "|r |T" .. icon .. ":14:14:0:0:64:64:0:64:0:64|t "
end
Expand Down
2 changes: 1 addition & 1 deletion classes/container_actors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ end
Details222.GuessSpecSchedules.Schedules[#Details222.GuessSpecSchedules.Schedules+1] = newTimer
end

local _, engClass = UnitClass(actorName or "")
local engClass = Details:GetUnitClass(actorName or "")

if (engClass) then
actorObject.classe = engClass
Expand Down
4 changes: 2 additions & 2 deletions core/gears.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ function Details.Database.StoreEncounter(combat)
player_name = player_name .. "-" .. player_realm
end

local _, _, class = UnitClass(player_name)
local _, _, class = Details:GetUnitClassFull(player_name)

local damage_actor = damage_container_pool [damage_container_hash [player_name]]
if (damage_actor) then
Expand All @@ -1771,7 +1771,7 @@ function Details.Database.StoreEncounter(combat)
player_name = player_name .. "-" .. player_realm
end

local _, _, class = UnitClass(player_name)
local _, _, class = Details:GetUnitClassFull(player_name)

local heal_actor = healing_container_pool [healing_container_hash [player_name]]
if (heal_actor) then
Expand Down
8 changes: 4 additions & 4 deletions core/plugins_raid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
else
local minute, second = _detalhes:GetCombat():GetFormatedCombatTime()

local _, class = _UnitClass(who_name)
local class = Details:GetUnitClass(who_name)
local class_color = "|cFFFF3333"

if (class) then
Expand Down Expand Up @@ -457,10 +457,10 @@
local msg
local minute, second = _detalhes:GetCombat():GetFormatedCombatTime()

local _, class = _UnitClass(who_name)
local class = Details:GetUnitClass(who_name)
local class_color = "|cFFFFFFFF"

local _, class2 = _UnitClass(alvo_name)
local class2 = Details:GetUnitClass(alvo_name)
local class_color2 = "|cFFFFFFFF"

if (class) then
Expand Down Expand Up @@ -556,7 +556,7 @@

local msg
if (where == 4) then --observer
local _, class = _UnitClass(alvo_name)
local class = Details:GetUnitClass(alvo_name)
local class_color = "|cFFFFFFFF"

if (class) then
Expand Down
3 changes: 0 additions & 3 deletions frames/window_breakdown/window_playerbreakdown_list.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ function breakdownWindowPlayerList.CreatePlayerListFrame()
self.playerName:SetText(Details:GetOnlyName(self.playerObject.nome))
self.rankText:SetText(self.index) --not in use

--set the player class name
--self.className:SetText(string.lower(_G.UnitClass(self.playerObject.nome) or self.playerObject:Class())) --not in use

--item level
self.itemLevelText:SetText(self.playerObject.ilvl or (playerGear and playerGear.ilevel) or "0")

Expand Down
22 changes: 22 additions & 0 deletions functions/classes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,28 @@ do
end
end

---return the class file name of the unit passed
local getFromCache = Details222.ClassCache.GetClassFromCache
local Ambiguate = Ambiguate
local UnitClass = UnitClass
function Details:GetUnitClass(unitId)
local class, classFileName = getFromCache(unitId)

if (not classFileName) then
unitId = Ambiguate(unitId, "none")
classFileName = select(2, UnitClass(unitId))
end

return classFileName
end

---return the class name, class file name and class id of the unit passed
function Details:GetUnitClassFull(unitId)
unitId = Ambiguate(unitId, "none")
local locClassName, classFileName, classId = UnitClass(unitId)
return locClassName, classFileName, classId
end

function Details:GetFullName(unitId)
--playerName, realmName = UnitFullName(unitId) --realm name already has spaces removed
--return playerName .. "-" .. realmName
Expand Down
2 changes: 1 addition & 1 deletion functions/dungeon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ local tickerCallback = function(tickerObject)
end
end

addPlayerDamage(UnitName ("player"))
addPlayerDamage(UnitName("player"))
end

function mythicDungeonCharts:OnBossDefeated()
Expand Down
20 changes: 10 additions & 10 deletions functions/playerclass.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,25 @@ do
---@param actorName string
---@return string className, number left, number right, number top, number bottom, number red, number green, number blue, number alpha
function Details:GetClass(actorName)
local _, class = UnitClass(actorName)
local unitClass = Details:GetUnitClass(actorName)

if (class) then
local left, right, top, bottom = unpack(Details.class_coords[class])
local r, g, b = unpack(Details.class_colors[class])
return class, left, right, top, bottom, r or 1, g or 1, b or 1, 1
if (unitClass) then
local left, right, top, bottom = unpack(Details.class_coords[unitClass])
local r, g, b = unpack(Details.class_colors[unitClass])
return unitClass, left, right, top, bottom, r or 1, g or 1, b or 1, 1
else
local overallCombatObject = Details:GetCombat(DETAILS_SEGMENTID_OVERALL)
for containerId = 1, DETAILS_COMBAT_AMOUNT_CONTAINERS do
local actorContainer = overallCombatObject:GetContainer(containerId)
local actorObject = actorContainer:GetActor(actorName)

if (actorObject) then
class = actorObject:Class()
if (class) then
unitClass = actorObject:Class()
if (unitClass) then
--found the class of the actor
local left, right, top, bottom = unpack(Details.class_coords[class] or CONST_UNKNOWN_CLASS_COORDS)
local r, g, b = unpack(Details.class_colors[class])
return class, left, right, top, bottom, r or 1, g or 1, b or 1, 1
local left, right, top, bottom = unpack(Details.class_coords[unitClass] or CONST_UNKNOWN_CLASS_COORDS)
local r, g, b = unpack(Details.class_colors[unitClass])
return unitClass, left, right, top, bottom, r or 1, g or 1, b or 1, 1
end
end
end
Expand Down

0 comments on commit 5e7df0d

Please sign in to comment.