Fix spellbook tabs race condition with DBC lazy loading

lookupSpellName() (called by action bar tooltips) was triggering
loadSpellDBC() early, setting dbcLoadAttempted=true before the
spellbook opened. This caused loadSkillLineDBCs() to be skipped,
so all spells were categorized into "General". Fixed by checking
each DBC's own loaded flag independently and re-categorizing when
skill line data becomes available.
This commit is contained in:
Kelsi 2026-02-26 01:21:51 -08:00
parent c919477e74
commit c2b271df6f
2 changed files with 9 additions and 2 deletions

View file

@ -71,6 +71,7 @@ private:
// Categorized spell tabs
std::vector<SpellTabInfo> spellTabs;
size_t lastKnownSpellCount = 0;
bool categorizedWithSkillLines = false;
// Search filter
char searchFilter_[128] = "";

View file

@ -300,6 +300,7 @@ void SpellbookScreen::categorizeSpells(const std::unordered_set<uint32_t>& known
}
lastKnownSpellCount = knownSpells.size();
categorizedWithSkillLines = !spellToSkillLine.empty();
}
VkDescriptorSet SpellbookScreen::getSpellIcon(uint32_t iconId, pipeline::AssetManager* assetManager) {
@ -399,13 +400,18 @@ void SpellbookScreen::render(game::GameHandler& gameHandler, pipeline::AssetMana
// Lazy-load DBC data on first open
if (!dbcLoadAttempted) {
loadSpellDBC(assetManager);
}
if (!iconDbLoaded) {
loadSpellIconDBC(assetManager);
}
if (!skillLineDbLoaded) {
loadSkillLineDBCs(assetManager);
}
// Rebuild categories if spell list changed
// Rebuild categories if spell list changed or skill line data became available
const auto& spells = gameHandler.getKnownSpells();
if (spells.size() != lastKnownSpellCount) {
bool skillLinesNowAvailable = !spellToSkillLine.empty() && !categorizedWithSkillLines;
if (spells.size() != lastKnownSpellCount || skillLinesNowAvailable) {
categorizeSpells(spells);
}