mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[8426] Use upper/lower iterator pairs as result instead 2 function calls.
This commit is contained in:
parent
fdb2842f60
commit
5d50bb16b8
9 changed files with 139 additions and 173 deletions
|
|
@ -2999,7 +2999,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
|
||||
// cast talents with SPELL_EFFECT_LEARN_SPELL (other dependent spells will learned later as not auto-learned)
|
||||
// note: all spells with SPELL_EFFECT_LEARN_SPELL isn't passive
|
||||
if( talentCost > 0 && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_LEARN_SPELL) )
|
||||
if (talentCost > 0 && IsSpellHaveEffect(spellInfo,SPELL_EFFECT_LEARN_SPELL))
|
||||
{
|
||||
// ignore stance requirement for talent learn spell (stance set for spell only for client spell description show)
|
||||
CastSpell(this, spell_id, true);
|
||||
|
|
@ -3007,10 +3007,10 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
// also cast passive spells (including all talents without SPELL_EFFECT_LEARN_SPELL) with additional checks
|
||||
else if (IsPassiveSpell(spell_id))
|
||||
{
|
||||
if(IsNeedCastPassiveSpellAtLearn(spellInfo))
|
||||
if (IsNeedCastPassiveSpellAtLearn(spellInfo))
|
||||
CastSpell(this, spell_id, true);
|
||||
}
|
||||
else if( IsSpellHaveEffect(spellInfo,SPELL_EFFECT_SKILL_STEP) )
|
||||
else if (IsSpellHaveEffect(spellInfo,SPELL_EFFECT_SKILL_STEP))
|
||||
{
|
||||
CastSpell(this, spell_id, true);
|
||||
return false;
|
||||
|
|
@ -3020,7 +3020,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
m_usedTalentCount += talentCost;
|
||||
|
||||
// update free primary prof.points (if any, can be none in case GM .learn prof. learning)
|
||||
if(uint32 freeProfs = GetFreePrimaryProfessionPoints())
|
||||
if (uint32 freeProfs = GetFreePrimaryProfessionPoints())
|
||||
{
|
||||
if(spellmgr.IsPrimaryProfessionFirstRankSpell(spell_id))
|
||||
SetFreePrimaryProfessions(freeProfs-1);
|
||||
|
|
@ -3031,20 +3031,19 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
|
||||
SpellLearnSkillNode const* spellLearnSkill = spellmgr.GetSpellLearnSkill(spell_id);
|
||||
|
||||
SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id);
|
||||
SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id);
|
||||
SkillLineAbilityMapBounds skill_bounds = spellmgr.GetSkillLineAbilityMapBounds(spell_id);
|
||||
|
||||
if(spellLearnSkill)
|
||||
if (spellLearnSkill)
|
||||
{
|
||||
uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill);
|
||||
uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill);
|
||||
|
||||
if(skill_value < spellLearnSkill->value)
|
||||
if (skill_value < spellLearnSkill->value)
|
||||
skill_value = spellLearnSkill->value;
|
||||
|
||||
uint32 new_skill_max_value = spellLearnSkill->maxvalue == 0 ? maxskill : spellLearnSkill->maxvalue;
|
||||
|
||||
if(skill_max_value < new_skill_max_value)
|
||||
if (skill_max_value < new_skill_max_value)
|
||||
skill_max_value = new_skill_max_value;
|
||||
|
||||
SetSkill(spellLearnSkill->skill,skill_value,skill_max_value);
|
||||
|
|
@ -3052,16 +3051,16 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
else
|
||||
{
|
||||
// not ranked skills
|
||||
for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx)
|
||||
for(SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx)
|
||||
{
|
||||
SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId);
|
||||
if(!pSkill)
|
||||
if (!pSkill)
|
||||
continue;
|
||||
|
||||
if(HasSkill(pSkill->id))
|
||||
if (HasSkill(pSkill->id))
|
||||
continue;
|
||||
|
||||
if(_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL ||
|
||||
if (_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL ||
|
||||
// lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL
|
||||
(pSkill->id==SKILL_LOCKPICKING || pSkill->id==SKILL_RUNEFORGING) && _spell_idx->second->max_value==0 )
|
||||
{
|
||||
|
|
@ -3084,24 +3083,23 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
}
|
||||
|
||||
// learn dependent spells
|
||||
SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id);
|
||||
SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id);
|
||||
SpellLearnSpellMapBounds spell_bounds = spellmgr.GetSpellLearnSpellMapBounds(spell_id);
|
||||
|
||||
for(SpellLearnSpellMap::const_iterator itr2 = spell_begin; itr2 != spell_end; ++itr2)
|
||||
for(SpellLearnSpellMap::const_iterator itr2 = spell_bounds.first; itr2 != spell_bounds.second; ++itr2)
|
||||
{
|
||||
if(!itr2->second.autoLearned)
|
||||
if (!itr2->second.autoLearned)
|
||||
{
|
||||
if(!IsInWorld() || !itr2->second.active) // at spells loading, no output, but allow save
|
||||
if (!IsInWorld() || !itr2->second.active) // at spells loading, no output, but allow save
|
||||
addSpell(itr2->second.spell,itr2->second.active,true,true,false);
|
||||
else // at normal learning
|
||||
learnSpell(itr2->second.spell,true);
|
||||
}
|
||||
}
|
||||
|
||||
if(!GetSession()->PlayerLoading())
|
||||
if (!GetSession()->PlayerLoading())
|
||||
{
|
||||
// not ranked skills
|
||||
for(SkillLineAbilityMap::const_iterator _spell_idx = lower; _spell_idx != upper; ++_spell_idx)
|
||||
for(SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx)
|
||||
{
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE,_spell_idx->second->skillId);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS,_spell_idx->second->skillId);
|
||||
|
|
@ -3236,19 +3234,19 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
|
|||
prevSkill = spellmgr.GetSpellLearnSkill(spellmgr.GetFirstSpellInChain(prev_spell));
|
||||
}
|
||||
|
||||
if(!prevSkill) // not found prev skill setting, remove skill
|
||||
if (!prevSkill) // not found prev skill setting, remove skill
|
||||
SetSkill(spellLearnSkill->skill,0,0);
|
||||
else // set to prev. skill setting values
|
||||
{
|
||||
uint32 skill_value = GetPureSkillValue(prevSkill->skill);
|
||||
uint32 skill_max_value = GetPureMaxSkillValue(prevSkill->skill);
|
||||
|
||||
if(skill_value > prevSkill->value)
|
||||
if (skill_value > prevSkill->value)
|
||||
skill_value = prevSkill->value;
|
||||
|
||||
uint32 new_skill_max_value = prevSkill->maxvalue == 0 ? GetMaxSkillValueForLevel() : prevSkill->maxvalue;
|
||||
|
||||
if(skill_max_value > new_skill_max_value)
|
||||
if (skill_max_value > new_skill_max_value)
|
||||
skill_max_value = new_skill_max_value;
|
||||
|
||||
SetSkill(prevSkill->skill,skill_value,skill_max_value);
|
||||
|
|
@ -3259,22 +3257,21 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
|
|||
else
|
||||
{
|
||||
// not ranked skills
|
||||
SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id);
|
||||
SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id);
|
||||
SkillLineAbilityMapBounds bounds = spellmgr.GetSkillLineAbilityMapBounds(spell_id);
|
||||
|
||||
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)
|
||||
{
|
||||
SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId);
|
||||
if(!pSkill)
|
||||
if (!pSkill)
|
||||
continue;
|
||||
|
||||
if(_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL ||
|
||||
if (_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL ||
|
||||
// lockpicking/runeforging special case, not have ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL
|
||||
(pSkill->id==SKILL_LOCKPICKING || pSkill->id==SKILL_RUNEFORGING) && _spell_idx->second->max_value==0 )
|
||||
{
|
||||
// not reset skills for professions and racial abilities
|
||||
if( (pSkill->categoryId==SKILL_CATEGORY_SECONDARY || pSkill->categoryId==SKILL_CATEGORY_PROFESSION) &&
|
||||
(IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask!=0) )
|
||||
if ((pSkill->categoryId==SKILL_CATEGORY_SECONDARY || pSkill->categoryId==SKILL_CATEGORY_PROFESSION) &&
|
||||
(IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask!=0))
|
||||
continue;
|
||||
|
||||
SetSkill(pSkill->id, 0, 0 );
|
||||
|
|
@ -3283,43 +3280,42 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
|
|||
}
|
||||
|
||||
// remove dependent spells
|
||||
SpellLearnSpellMap::const_iterator spell_begin = spellmgr.GetBeginSpellLearnSpell(spell_id);
|
||||
SpellLearnSpellMap::const_iterator spell_end = spellmgr.GetEndSpellLearnSpell(spell_id);
|
||||
SpellLearnSpellMapBounds spell_bounds = spellmgr.GetSpellLearnSpellMapBounds(spell_id);
|
||||
|
||||
for(SpellLearnSpellMap::const_iterator itr2 = spell_begin; itr2 != spell_end; ++itr2)
|
||||
for(SpellLearnSpellMap::const_iterator itr2 = spell_bounds.first; itr2 != spell_bounds.second; ++itr2)
|
||||
removeSpell(itr2->second.spell, disabled);
|
||||
|
||||
// activate lesser rank in spellbook/action bar, and cast it if need
|
||||
bool prev_activate = false;
|
||||
|
||||
if(uint32 prev_id = spellmgr.GetPrevSpellInChain (spell_id))
|
||||
if (uint32 prev_id = spellmgr.GetPrevSpellInChain (spell_id))
|
||||
{
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
|
||||
|
||||
// if talent then lesser rank also talent and need learn
|
||||
if(talentCosts)
|
||||
if (talentCosts)
|
||||
{
|
||||
if(learn_low_rank)
|
||||
learnSpell (prev_id,false);
|
||||
}
|
||||
// if ranked non-stackable spell: need activate lesser rank and update dendence state
|
||||
else if(cur_active && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0)
|
||||
else if (cur_active && !SpellMgr::canStackSpellRanks(spellInfo) && spellmgr.GetSpellRank(spellInfo->Id) != 0)
|
||||
{
|
||||
// need manually update dependence state (learn spell ignore like attempts)
|
||||
PlayerSpellMap::iterator prev_itr = m_spells.find(prev_id);
|
||||
if (prev_itr != m_spells.end())
|
||||
{
|
||||
if(prev_itr->second->dependent != cur_dependent)
|
||||
if (prev_itr->second->dependent != cur_dependent)
|
||||
{
|
||||
prev_itr->second->dependent = cur_dependent;
|
||||
if(prev_itr->second->state != PLAYERSPELL_NEW)
|
||||
if (prev_itr->second->state != PLAYERSPELL_NEW)
|
||||
prev_itr->second->state = PLAYERSPELL_CHANGED;
|
||||
}
|
||||
|
||||
// now re-learn if need re-activate
|
||||
if(cur_active && !prev_itr->second->active && learn_low_rank)
|
||||
if (cur_active && !prev_itr->second->active && learn_low_rank)
|
||||
{
|
||||
if(addSpell(prev_id,true,false,prev_itr->second->dependent,prev_itr->second->disabled))
|
||||
if (addSpell(prev_id,true,false,prev_itr->second->dependent,prev_itr->second->disabled))
|
||||
{
|
||||
// downgrade spell ranks in spellbook and action bar
|
||||
WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4);
|
||||
|
|
@ -5043,20 +5039,19 @@ bool Player::UpdateCraftSkill(uint32 spellid)
|
|||
{
|
||||
sLog.outDebug("UpdateCraftSkill spellid %d", spellid);
|
||||
|
||||
SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spellid);
|
||||
SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spellid);
|
||||
SkillLineAbilityMapBounds bounds = spellmgr.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)
|
||||
{
|
||||
if(_spell_idx->second->skillId)
|
||||
if (_spell_idx->second->skillId)
|
||||
{
|
||||
uint32 SkillValue = GetPureSkillValue(_spell_idx->second->skillId);
|
||||
|
||||
// Alchemy Discoveries here
|
||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(spellid);
|
||||
if(spellEntry && spellEntry->Mechanic==MECHANIC_DISCOVERY)
|
||||
if (spellEntry && spellEntry->Mechanic==MECHANIC_DISCOVERY)
|
||||
{
|
||||
if(uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->skillId, spellid, this))
|
||||
if (uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->skillId, spellid, this))
|
||||
learnSpell(discoveredSpell,false);
|
||||
}
|
||||
|
||||
|
|
@ -18584,19 +18579,18 @@ bool Player::IsSpellFitByClassAndRace( uint32 spell_id ) const
|
|||
uint32 racemask = getRaceMask();
|
||||
uint32 classmask = getClassMask();
|
||||
|
||||
SkillLineAbilityMap::const_iterator lower = spellmgr.GetBeginSkillLineAbilityMap(spell_id);
|
||||
SkillLineAbilityMap::const_iterator upper = spellmgr.GetEndSkillLineAbilityMap(spell_id);
|
||||
if(lower==upper)
|
||||
SkillLineAbilityMapBounds bounds = spellmgr.GetSkillLineAbilityMapBounds(spell_id);
|
||||
if (bounds.first==bounds.second)
|
||||
return true;
|
||||
|
||||
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)
|
||||
{
|
||||
// skip wrong race skills
|
||||
if( _spell_idx->second->racemask && (_spell_idx->second->racemask & racemask) == 0)
|
||||
if (_spell_idx->second->racemask && (_spell_idx->second->racemask & racemask) == 0)
|
||||
continue;
|
||||
|
||||
// skip wrong class skills
|
||||
if( _spell_idx->second->classmask && (_spell_idx->second->classmask & classmask) == 0)
|
||||
if (_spell_idx->second->classmask && (_spell_idx->second->classmask & classmask) == 0)
|
||||
continue;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue