[8426] Use upper/lower iterator pairs as result instead 2 function calls.

This commit is contained in:
VladimirMangos 2009-08-27 10:51:23 +04:00
parent fdb2842f60
commit 5d50bb16b8
9 changed files with 139 additions and 173 deletions

View file

@ -1693,16 +1693,15 @@ bool SpellMgr::IsPrimaryProfessionFirstRankSpell(uint32 spellId) const
bool SpellMgr::IsSkillBonusSpell(uint32 spellId) const
{
SkillLineAbilityMap::const_iterator lower = GetBeginSkillLineAbilityMap(spellId);
SkillLineAbilityMap::const_iterator upper = GetEndSkillLineAbilityMap(spellId);
SkillLineAbilityMapBounds bounds = GetSkillLineAbilityMapBounds(spellId);
for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx)
for(SkillLineAbilityMap::const_iterator _spell_idx = bounds.first; _spell_idx != bounds.second; ++_spell_idx)
{
SkillLineAbilityEntry const *pAbility = _spell_idx->second;
if (!pAbility || pAbility->learnOnGetSkill != ABILITY_LEARNED_ON_GET_PROFESSION_SKILL)
continue;
if(pAbility->req_skill_value > 0)
if (pAbility->req_skill_value > 0)
return true;
}
@ -1964,7 +1963,7 @@ void SpellMgr::LoadSpellLearnSpells()
// 0 1 2
QueryResult *result = WorldDatabase.Query("SELECT entry, SpellID, Active FROM spell_learn_spell");
if(!result)
if (!result)
{
barGoLink bar( 1 );
bar.step();
@ -1990,19 +1989,19 @@ void SpellMgr::LoadSpellLearnSpells()
node.active = fields[2].GetBool();
node.autoLearned= false;
if(!sSpellStore.LookupEntry(spell_id))
if (!sSpellStore.LookupEntry(spell_id))
{
sLog.outErrorDb("Spell %u listed in `spell_learn_spell` does not exist",spell_id);
continue;
}
if(!sSpellStore.LookupEntry(node.spell))
if (!sSpellStore.LookupEntry(node.spell))
{
sLog.outErrorDb("Spell %u listed in `spell_learn_spell` learning not existed spell %u",spell_id,node.spell);
continue;
}
if(GetTalentSpellCost(node.spell))
if (GetTalentSpellCost(node.spell))
{
sLog.outErrorDb("Spell %u listed in `spell_learn_spell` attempt learning talent spell %u, skipped",spell_id,node.spell);
continue;
@ -2021,7 +2020,7 @@ void SpellMgr::LoadSpellLearnSpells()
{
SpellEntry const* entry = sSpellStore.LookupEntry(spell);
if(!entry)
if (!entry)
continue;
for(int i = 0; i < 3; ++i)
@ -2033,7 +2032,7 @@ void SpellMgr::LoadSpellLearnSpells()
dbc_node.active = true; // all dbc based learned spells is active (show in spell book or hide by client itself)
// ignore learning not existed spells (broken/outdated/or generic learnig spell 483
if(!sSpellStore.LookupEntry(dbc_node.spell))
if (!sSpellStore.LookupEntry(dbc_node.spell))
continue;
// talent or passive spells or skill-step spells auto-casted and not need dependent learning,
@ -2041,13 +2040,12 @@ void SpellMgr::LoadSpellLearnSpells()
// other required explicit dependent learning
dbc_node.autoLearned = entry->EffectImplicitTargetA[i]==TARGET_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(spell) || IsSpellHaveEffect(entry,SPELL_EFFECT_SKILL_STEP);
SpellLearnSpellMap::const_iterator db_node_begin = GetBeginSpellLearnSpell(spell);
SpellLearnSpellMap::const_iterator db_node_end = GetEndSpellLearnSpell(spell);
SpellLearnSpellMapBounds db_node_bounds = GetSpellLearnSpellMapBounds(spell);
bool found = false;
for(SpellLearnSpellMap::const_iterator itr = db_node_begin; itr != db_node_end; ++itr)
for(SpellLearnSpellMap::const_iterator itr = db_node_bounds.first; itr != db_node_bounds.second; ++itr)
{
if(itr->second.spell == dbc_node.spell)
if (itr->second.spell == dbc_node.spell)
{
sLog.outErrorDb("Spell %u auto-learn spell %u in spell.dbc then the record in `spell_learn_spell` is redundant, please fix DB.",
spell,dbc_node.spell);
@ -2056,7 +2054,7 @@ void SpellMgr::LoadSpellLearnSpells()
}
}
if(!found) // add new spell-spell pair if not found
if (!found) // add new spell-spell pair if not found
{
mSpellLearnSpells.insert(SpellLearnSpellMap::value_type(spell,dbc_node));
++dbc_count;