fix(Core/Trainers): add new column ReqSpell to npc_trainer table (#9490)

Prevent learning gnomish and goblin engineering recipes at same time.
Fixes #5390

Co-authored-by: Skjalf <47818697+Nyeriah@users.noreply.github.com>
This commit is contained in:
UltraNix
2021-12-16 11:18:21 +01:00
committed by GitHub
parent c822ef969b
commit 0f83d52f43
6 changed files with 75 additions and 4 deletions

View File

@@ -8295,7 +8295,7 @@ void ObjectMgr::LoadMailLevelRewards()
LOG_INFO("server.loading", " ");
}
void ObjectMgr::AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel)
void ObjectMgr::AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost, uint32 reqSkill, uint32 reqSkillValue, uint32 reqLevel, uint32 reqSpell)
{
if (entry >= ACORE_TRAINER_START_REF)
return;
@@ -8332,6 +8332,12 @@ void ObjectMgr::AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost,
return;
}
if (reqSpell && !sSpellMgr->GetSpellInfo(reqSpell))
{
LOG_ERROR("sql.sql", "Table `npc_trainer` contains an entry (Entry: %u) for a non-existing reqSpell (Spell: %u), ignoring", entry, reqSpell);
return;
}
TrainerSpellData& data = _cacheTrainerSpellStore[entry];
TrainerSpell& trainerSpell = data.spellList[spell];
@@ -8340,6 +8346,7 @@ void ObjectMgr::AddSpellToTrainer(uint32 entry, uint32 spell, uint32 spellCost,
trainerSpell.reqSkill = reqSkill;
trainerSpell.reqSkillValue = reqSkillValue;
trainerSpell.reqLevel = reqLevel;
trainerSpell.reqSpell = reqSpell;
if (!trainerSpell.reqLevel)
trainerSpell.reqLevel = spellinfo->SpellLevel;
@@ -8380,7 +8387,7 @@ void ObjectMgr::LoadTrainerSpell()
// For reload case
_cacheTrainerSpellStore.clear();
QueryResult result = WorldDatabase.Query("SELECT b.ID, a.SpellID, a.MoneyCost, a.ReqSkillLine, a.ReqSkillRank, a.ReqLevel FROM npc_trainer AS a "
QueryResult result = WorldDatabase.Query("SELECT b.ID, a.SpellID, a.MoneyCost, a.ReqSkillLine, a.ReqSkillRank, a.ReqLevel, a.ReqSpell FROM npc_trainer AS a "
"INNER JOIN npc_trainer AS b ON a.ID = -(b.SpellID) "
"UNION SELECT * FROM npc_trainer WHERE SpellID > 0");
@@ -8403,8 +8410,9 @@ void ObjectMgr::LoadTrainerSpell()
uint32 reqSkill = fields[3].GetUInt16();
uint32 reqSkillValue = fields[4].GetUInt16();
uint32 reqLevel = fields[5].GetUInt8();
uint32 reqSpell = fields[6].GetUInt32();
AddSpellToTrainer(entry, spell, spellCost, reqSkill, reqSkillValue, reqLevel);
AddSpellToTrainer(entry, spell, spellCost, reqSkill, reqSkillValue, reqLevel, reqSpell);
++count;
} while (result->NextRow());