Fix empty PLAYER_FACTION_COLORS (load-order bug)

PLAYER_FACTION_COLORS was built in Constants.lua (loads early), but it
references the PLAYER_FACTION_COLOR_HORDE/ALLIANCE color objects that
Color.lua only materializes from C_UIColor at a later load step. So the
table captured nils -> ended up {}, and GetFactionColor always returned
nil. (Can't just reorder the TOC: Color.lua depends on ITEM_QUALITY_COLORS
from Constants.lua, so it's circular.)

Move the PLAYER_FACTION_COLORS construction to ColorUtil.lua, which loads
after Color.lua (and is where its only consumer, GetFactionColor, lives),
so the color objects exist by then. PLAYER_FACTION_GROUP stays in
Constants.lua (no such dependency).
This commit is contained in:
Brues
2026-06-21 17:14:16 -05:00
parent aacbc0d92c
commit 5efe47cc34
2 changed files with 14 additions and 5 deletions
+10
View File
@@ -7,6 +7,16 @@ do
end
end
-- Built here (not in Constants.lua) because it references the
-- PLAYER_FACTION_COLOR_* objects, which Color.lua materializes from
-- C_UIColor — and ColorUtil.lua loads after Color.lua, so they exist by
-- now. (Constants.lua loads earlier, where they were still nil.)
PLAYER_FACTION_COLORS =
{
[0] = PLAYER_FACTION_COLOR_HORDE,
[1] = PLAYER_FACTION_COLOR_ALLIANCE,
};
function ExtractColorValueFromHex(str, index)
return tonumber(string.sub(str, index, index + 1), 16) / 255;
end
+4 -5
View File
@@ -118,11 +118,10 @@ FACTION_LABELS_FROM_STRING = {
["Alliance"] = FACTION_ALLIANCE,
}
PLAYER_FACTION_COLORS =
{
[0] = PLAYER_FACTION_COLOR_HORDE,
[1] = PLAYER_FACTION_COLOR_ALLIANCE,
};
-- PLAYER_FACTION_COLORS is built in Util/ColorUtil.lua, not here: it
-- references the PLAYER_FACTION_COLOR_* color objects, which Color.lua
-- only materializes (from C_UIColor) at a later load step. Defining it
-- here captured nils and produced an empty table.
WOW_PROJECT_MAINLINE = 1;
WOW_PROJECT_CLASSIC = 2;