From 5efe47cc349ecc4e6affd1f06bca794f88c06dd9 Mon Sep 17 00:00:00 2001 From: Brues <5278969+brues-code@users.noreply.github.com> Date: Sun, 21 Jun 2026 17:13:21 -0500 Subject: [PATCH] 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). --- AddOns/!!!ClassicAPI/Util/ColorUtil.lua | 10 ++++++++++ AddOns/!!!ClassicAPI/Util/Constants.lua | 9 ++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/AddOns/!!!ClassicAPI/Util/ColorUtil.lua b/AddOns/!!!ClassicAPI/Util/ColorUtil.lua index 11c1dd12..d6e13434 100644 --- a/AddOns/!!!ClassicAPI/Util/ColorUtil.lua +++ b/AddOns/!!!ClassicAPI/Util/ColorUtil.lua @@ -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 diff --git a/AddOns/!!!ClassicAPI/Util/Constants.lua b/AddOns/!!!ClassicAPI/Util/Constants.lua index 8b0a1383..bcc6ff4a 100644 --- a/AddOns/!!!ClassicAPI/Util/Constants.lua +++ b/AddOns/!!!ClassicAPI/Util/Constants.lua @@ -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;