From 79c8d93c4537f281d891e9eb286f7236bd4f51f8 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 11 Mar 2026 05:26:38 -0700 Subject: [PATCH] fix: use expansion-aware field indices for spell icon loading The spell icon loader was incorrectly assuming WotLK field 133 (IconID) for any DBC with >= 200 fields. This breaks Classic/TBC where IconID is at different fields: - Classic: field 117 - TBC: field 124 - WotLK: field 133 Now always uses expansion-aware layout (spellL) when available, falling back to hardcoded field 133 only if the layout is missing. Fixes missing spell icons on Classic and TBC expansions. --- src/ui/game_screen.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 52e056fb..a139f15f 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -4059,7 +4059,7 @@ VkDescriptorSet GameScreen::getSpellIcon(uint32_t spellId, pipeline::AssetManage const auto* spellL = pipeline::getActiveDBCLayout() ? pipeline::getActiveDBCLayout()->getLayout("Spell") : nullptr; if (spellDbc && spellDbc->isLoaded()) { uint32_t fieldCount = spellDbc->getFieldCount(); - // Try expansion layout first + // Helper to load icons for a given field layout auto tryLoadIcons = [&](uint32_t idField, uint32_t iconField) { spellIconIds_.clear(); if (iconField >= fieldCount) return; @@ -4071,16 +4071,16 @@ VkDescriptorSet GameScreen::getSpellIcon(uint32_t spellId, pipeline::AssetManage } } }; - // If the DBC has WotLK-range field count (≥200 fields), it's the binary - // WotLK Spell.dbc (CSV fallback). Use WotLK layout regardless of expansion, - // since Turtle/Classic CSV files are garbled and fall back to WotLK binary. - if (fieldCount >= 200) { - tryLoadIcons(0, 133); // WotLK IconID field - } else if (spellL) { + + // Always use expansion-aware layout if available + // Field indices vary by expansion: Classic=117, TBC=124, WotLK=133 + if (spellL) { tryLoadIcons((*spellL)["ID"], (*spellL)["IconID"]); } - // Fallback to WotLK field 133 if expansion layout yielded nothing - if (spellIconIds_.empty() && fieldCount > 133) { + + // Fallback if expansion layout missing or yielded nothing + // Only use WotLK field 133 as last resort if we have no layout + if (spellIconIds_.empty() && !spellL && fieldCount > 133) { tryLoadIcons(0, 133); } }