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.
This commit is contained in:
Kelsi 2026-03-11 05:26:38 -07:00
parent 593f06bdf7
commit 79c8d93c45

View file

@ -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);
}
}