aboutsummaryrefslogtreecommitdiff
path: root/src/game/NPCHandler.cpp
diff options
context:
space:
mode:
authorQAston <none@none>2010-01-30 19:25:04 +0100
committerQAston <none@none>2010-01-30 19:25:04 +0100
commita331b67244f00ad9d4e1369f3a519e2877e5d31c (patch)
tree9f6d176681ba8e4d53384a0835513d10ba7bc083 /src/game/NPCHandler.cpp
parent6b9914f0d7e55e3fdce1d9eefcc8bb857f922016 (diff)
*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
Diffstat (limited to 'src/game/NPCHandler.cpp')
-rw-r--r--src/game/NPCHandler.cpp21
1 files changed, 17 insertions, 4 deletions
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;
}