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.
This commit is contained in:
Brues
2026-06-21 17:10:56 -05:00
parent edab1d1e2a
commit 241a5befd2
2 changed files with 12 additions and 4 deletions
+3 -3
View File
@@ -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
+9 -1
View File
@@ -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,
};