libunitscan: cache levels only, classes come from C_PlayerCache

This commit is contained in:
Brues
2026-11-03 01:17:04 -06:00
parent df7c13651b
commit ee9bd9e31a
4 changed files with 55 additions and 88 deletions
+2 -14
View File
@@ -701,12 +701,6 @@ pfUI:RegisterModule("chat", function ()
local r,g,b = GetStringColor(C.chat.text.unknowncolor)
local unknowncolorhex = rgbhex(r,g,b)
local function GetPlayerLevel(name)
if not pfUI_playerDB then return nil end
if not pfUI_playerDB[name] then return nil end
return pfUI_playerDB[name].level
end
-- the sender of the line AddMessage is reading, from its chat event
local lineSender, lineSenderClass, lineSenderRace, lineSenderSex
@@ -727,10 +721,7 @@ pfUI:RegisterModule("chat", function ()
else
_, class, _, raceKey, sex = C_PlayerCache.GetPlayerInfoByName(real)
end
if not class then
class = GetUnitInfo(real)
end
if class and class ~= UNKNOWN then
if class then
color = "|c" .. PFUI_CLASS_COLORS[class].colorStr
if C.chat.text.factionicons == "1" then
icon = GetFactionIcon(raceKey)
@@ -745,11 +736,8 @@ pfUI:RegisterModule("chat", function ()
local suffix = ""
local level = C.chat.text.playerlevel == "1" and GetPlayerLevel(real)
if level and level > 0 then
if level then
suffix = " " .. rgbhex(GetDifficultyColor(level)) .. level .. "|r"
elseif level then
-- Show ?? for unknown levels (e.g. -1 from UnitLevel)
suffix = " |cffff0000??|r"
end
if color == "" and suffix == "" then return link end
+1 -2
View File
@@ -492,8 +492,7 @@ pfUI:RegisterModule("nameplates", function ()
local elite = UnitClassification(unit)
if level <= 0 then
if plate.player then
local _, dblevel = GetUnitInfo(plate.rawname)
if dblevel and dblevel > 0 then level = dblevel end
level = GetPlayerLevel(plate.rawname) or level
else
-- UnitLevel answers -1 exactly where the engine shows the skull: a
-- world boss, or a hostile ten or more levels above the player
+7 -6
View File
@@ -5,7 +5,7 @@ pfUI:RegisterModule("socialmod", function ()
pfUI.socialmod:SetScript("OnEvent", function()
local name = cmatch(arg1, _G.ERR_FRIEND_ONLINE_SS)
name = name or cmatch(arg1, _G.ERR_FRIEND_OFFLINE_S)
if name and playerdb[name] and playerdb[name].cname then
if name and playerdb[name] then
playerdb[name].lastseen = date("%a %d-%b-%Y")
end
end)
@@ -92,7 +92,6 @@ pfUI:RegisterModule("socialmod", function ()
local cname = ccolor:WrapTextInColorCode(name)
if playerdb[name] then
playerdb[name].lastseen = date("%a %d-%b-%Y")
playerdb[name].cname = cname
end
if friendName then
@@ -106,11 +105,13 @@ pfUI:RegisterModule("socialmod", function ()
caption:SetVertexColor(1,1,1,.9)
friendInfo:SetVertexColor(1,1,1,.9)
else
if playerdb[name] and playerdb[name].cname and playerdb[name].level and playerdb[name].lastseen then
caption:SetFormattedText(TEXT(FRIENDS_LIST_OFFLINE_TEMPLATE), playerdb[name].cname)
friendInfo:SetFormattedText(TEXT(FRIENDS_LEVEL_TEMPLATE), playerdb[name].level, playerdb[name].lastseen)
local _, class = C_PlayerCache.GetPlayerInfoByName(name)
caption:SetFormattedText(TEXT(FRIENDS_LIST_OFFLINE_TEMPLATE), class and PFUI_CLASS_COLORS[class]:WrapTextInColorCode(name) or name.."|r")
local entry = playerdb[name]
if entry and entry.level and entry.lastseen then
friendInfo:SetFormattedText(TEXT(FRIENDS_LEVEL_TEMPLATE), entry.level, entry.lastseen)
else
caption:SetFormattedText(TEXT(FRIENDS_LIST_OFFLINE_TEMPLATE), name.."|r")
friendInfo:SetText(TEXT(UNKNOWN))
end