From 241a5befd2fef80de2d3fa18de1a3ff17faccda6 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun, 21 Jun 2026 17:05:40 -0500 Subject: [PATCH] Constants: define PLAYER_FACTION_GROUP (tag -> index map) GetFactionColor needs the FrameXML PLAYER_FACTION_GROUP global (faction tag -> 0/1 index) to pair with our PLAYER_FACTION_COLORS, but we only shipped the latter, so the lookup always returned nil. Add PLAYER_FACTION_GROUP next to it, matching Blizzard SharedConstants ({[0]="Horde",[1]="Alliance",Horde=0,Alliance=1}); `or`-guarded so a native definition wins if present. --- AddOns/!!!ClassicAPI/Util/ColorUtil.lua | 6 +++--- AddOns/!!!ClassicAPI/Util/Constants.lua | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/AddOns/!!!ClassicAPI/Util/ColorUtil.lua b/AddOns/!!!ClassicAPI/Util/ColorUtil.lua index 2059d3c1..0e916dc6 100644 --- a/AddOns/!!!ClassicAPI/Util/ColorUtil.lua +++ b/AddOns/!!!ClassicAPI/Util/ColorUtil.lua @@ -74,9 +74,9 @@ function GetClassColoredTextForUnit(unit, text) end function GetFactionColor(factionGroupTag) - -- PLAYER_FACTION_COLORS lives in our Constants.lua; PLAYER_FACTION_GROUP - -- is the FrameXML faction-tag -> index map. Guarded so a missing table - -- yields nil rather than erroring. + -- Both PLAYER_FACTION_GROUP (tag -> index) and PLAYER_FACTION_COLORS + -- (index -> color) live in our Constants.lua. Guarded defensively in + -- case a client variant leaves one unset. local group = PLAYER_FACTION_GROUP and PLAYER_FACTION_GROUP[factionGroupTag]; return PLAYER_FACTION_COLORS and PLAYER_FACTION_COLORS[group]; end diff --git a/AddOns/!!!ClassicAPI/Util/Constants.lua b/AddOns/!!!ClassicAPI/Util/Constants.lua index 1a2dc8d7..a344fb61 100644 --- a/AddOns/!!!ClassicAPI/Util/Constants.lua +++ b/AddOns/!!!ClassicAPI/Util/Constants.lua @@ -106,8 +106,16 @@ BAG_ITEM_QUALITY_COLORS = }; -- faction +PLAYER_FACTION_GROUP = PLAYER_FACTION_GROUP or +{ + [0] = "Horde", + [1] = "Alliance", + Horde = 0, + Alliance = 1, +}; + PLAYER_FACTION_COLORS = -{ +{ [0] = PLAYER_FACTION_COLOR_HORDE, [1] = PLAYER_FACTION_COLOR_ALLIANCE, };