From a331b67244f00ad9d4e1369f3a519e2877e5d31c Mon Sep 17 00:00:00 2001 From: QAston Date: Sat, 30 Jan 2010 19:25:04 +0100 Subject: *Add error checks at spell_required table loading *Allow spell_required table to store more than 1 spell learn requirement for a spell *spell_required table data is removed from world.sql and since this commit the data for it should be maintained by db project you're using. --HG-- branch : trunk --- src/game/NPCHandler.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/game/NPCHandler.cpp') diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp index 9e674e74706..cba689d0a76 100644 --- a/src/game/NPCHandler.cpp +++ b/src/game/NPCHandler.cpp @@ -164,7 +164,6 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle ) bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(tSpell->learnedSpell); SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(tSpell->learnedSpell); - uint32 req_spell = spellmgr.GetSpellRequired(tSpell->spell); TrainerSpellState state = _player->GetTrainerSpellState(tSpell); data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case) @@ -178,9 +177,23 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle ) data << uint32(tSpell->reqSkill); data << uint32(tSpell->reqSkillValue); //prev + req or req + 0 - data << uint32(!tSpell->IsCastable() && chain_node && chain_node->prev ? chain_node->prev : req_spell); - data << uint32(!tSpell->IsCastable() && chain_node && chain_node->prev ? req_spell : 0); - data << uint32(0); + uint8 maxReq = 0; + if (!tSpell->IsCastable() && chain_node && chain_node->prev) + { + data << uint32(chain_node->prev); + ++maxReq; + } + SpellsRequiringSpellMapBounds spellsRequired = spellmgr.GetSpellsRequiredForSpellBounds(tSpell->spell); + for (SpellsRequiringSpellMap::const_iterator itr2 = spellsRequired.first; itr2 != spellsRequired.second && maxReq < 3; ++itr2) + { + data << uint32(itr2->second); + ++maxReq; + } + while (maxReq < 3) + { + data << uint32(0); + ++maxReq; + } ++count; } -- cgit v1.2.3