feat: show spell tooltip text instead of name in item spell effects

Item "Equip:" and "Use:" spell effects now display the spell's
description text from Spell.dbc (e.g. "Increases your Spell Power by 30.")
rather than the internal spell name (e.g. "Mana Spring Totem").
Falls back to the name when description is unavailable (e.g. older DBCs).
Adds getSpellDescription() to GameHandler, backed by the existing
loadSpellNameCache() pass which now reads the Tooltip field.
This commit is contained in:
Kelsi 2026-03-12 13:08:41 -07:00
parent ed2b50af26
commit a10139284d
3 changed files with 35 additions and 8 deletions

View file

@ -17161,6 +17161,13 @@ void GameHandler::loadSpellNameCache() {
if (f != 0xFFFFFFFF && f < dbc->getFieldCount()) { dispelField = f; hasDispelField = true; }
}
// Tooltip/description field
uint32_t tooltipField = 0xFFFFFFFF;
if (spellL) {
uint32_t f = spellL->field("Tooltip");
if (f != 0xFFFFFFFF && f < dbc->getFieldCount()) tooltipField = f;
}
uint32_t count = dbc->getRecordCount();
for (uint32_t i = 0; i < count; ++i) {
uint32_t id = dbc->getUInt32(i, spellL ? (*spellL)["ID"] : 0);
@ -17168,7 +17175,10 @@ void GameHandler::loadSpellNameCache() {
std::string name = dbc->getString(i, spellL ? (*spellL)["Name"] : 136);
std::string rank = dbc->getString(i, spellL ? (*spellL)["Rank"] : 153);
if (!name.empty()) {
SpellNameEntry entry{std::move(name), std::move(rank), 0, 0};
SpellNameEntry entry{std::move(name), std::move(rank), {}, 0, 0};
if (tooltipField != 0xFFFFFFFF) {
entry.description = dbc->getString(i, tooltipField);
}
if (hasSchoolMask) {
entry.schoolMask = dbc->getUInt32(i, schoolMaskField);
} else if (hasSchoolEnum) {
@ -17373,6 +17383,12 @@ const std::string& GameHandler::getSpellRank(uint32_t spellId) const {
return (it != spellNameCache_.end()) ? it->second.rank : EMPTY_STRING;
}
const std::string& GameHandler::getSpellDescription(uint32_t spellId) const {
const_cast<GameHandler*>(this)->loadSpellNameCache();
auto it = spellNameCache_.find(spellId);
return (it != spellNameCache_.end()) ? it->second.description : EMPTY_STRING;
}
uint8_t GameHandler::getSpellDispelType(uint32_t spellId) const {
const_cast<GameHandler*>(this)->loadSpellNameCache();
auto it = spellNameCache_.find(spellId);