From 319f70fb7612f2b25943b7f823da16eb80cde1a3 Mon Sep 17 00:00:00 2001 From: megamage Date: Mon, 16 Feb 2009 20:10:04 -0600 Subject: [7283] Use map for trainer spells for fast find data by spell id. Author: zhenya --HG-- branch : trunk --- src/game/ObjectMgr.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'src/game/ObjectMgr.cpp') diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index b7dafe9a55a..dae60a230f1 100644 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -7100,36 +7100,34 @@ void ObjectMgr::LoadTrainerSpell() continue; } - TrainerSpell* pTrainerSpell = new TrainerSpell(); - pTrainerSpell->spell = spell; - pTrainerSpell->spellCost = fields[2].GetUInt32(); - pTrainerSpell->reqSkill = fields[3].GetUInt32(); - pTrainerSpell->reqSkillValue = fields[4].GetUInt32(); - pTrainerSpell->reqLevel = fields[5].GetUInt32(); + TrainerSpellData& data = m_mCacheTrainerSpellMap[entry]; + + if(SpellMgr::IsProfessionSpell(spell)) + data.trainerType = 2; + + TrainerSpell& trainerSpell = data.spellList[spell]; + trainerSpell.spell = spell; + trainerSpell.spellCost = fields[2].GetUInt32(); + trainerSpell.reqSkill = fields[3].GetUInt32(); + trainerSpell.reqSkillValue = fields[4].GetUInt32(); + trainerSpell.reqLevel = fields[5].GetUInt32(); - if(!pTrainerSpell->reqLevel) - pTrainerSpell->reqLevel = spellinfo->spellLevel; + if(!trainerSpell.reqLevel) + trainerSpell.reqLevel = spellinfo->spellLevel; // calculate learned spell for profession case when stored cast-spell - pTrainerSpell->learnedSpell = spell; + trainerSpell.learnedSpell = spell; for(int i = 0; i <3; ++i) { - if(spellinfo->Effect[i]!=SPELL_EFFECT_LEARN_SPELL) + if(spellinfo->Effect[i] != SPELL_EFFECT_LEARN_SPELL) continue; - if(SpellMgr::IsProfessionOrRidingSpell(spellinfo->EffectTriggerSpell[i])) { - pTrainerSpell->learnedSpell = spellinfo->EffectTriggerSpell[i]; + trainerSpell.learnedSpell = spellinfo->EffectTriggerSpell[i]; break; } } - TrainerSpellData& data = m_mCacheTrainerSpellMap[entry]; - - if(SpellMgr::IsProfessionSpell(spell)) - data.trainerType = 2; - - data.spellList.push_back(pTrainerSpell); ++count; } while (result->NextRow()); -- cgit v1.2.3