mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[9731] Cleanup in skil steps code.
* Move step arg in SetSkill to end for make possible for it default value. * Merge GetSkillStep function to SetSkill, base at fact that old GetSkillStep code can be != 0 only for already known spell, so at update
This commit is contained in:
parent
c64a2e8c84
commit
c7095fb3ed
7 changed files with 25 additions and 38 deletions
|
|
@ -3183,7 +3183,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
if (skill_max_value < new_skill_max_value)
|
||||
skill_max_value = new_skill_max_value;
|
||||
|
||||
SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value);
|
||||
SetSkill(spellLearnSkill->skill, skill_value, skill_max_value, spellLearnSkill->step);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3204,13 +3204,13 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
switch(GetSkillRangeType(pSkill, _spell_idx->second->racemask != 0))
|
||||
{
|
||||
case SKILL_RANGE_LANGUAGE:
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 300, 300 );
|
||||
SetSkill(pSkill->id, 300, 300 );
|
||||
break;
|
||||
case SKILL_RANGE_LEVEL:
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 1, GetMaxSkillValueForLevel() );
|
||||
SetSkill(pSkill->id, 1, GetMaxSkillValueForLevel() );
|
||||
break;
|
||||
case SKILL_RANGE_MONO:
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 1, 1 );
|
||||
SetSkill(pSkill->id, 1, 1 );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -3374,7 +3374,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
{
|
||||
uint32 prev_spell = sSpellMgr.GetPrevSpellInChain(spell_id);
|
||||
if(!prev_spell) // first rank, remove skill
|
||||
SetSkill(spellLearnSkill->skill, 0, 0, 0);
|
||||
SetSkill(spellLearnSkill->skill, 0, 0);
|
||||
else
|
||||
{
|
||||
// search prev. skill setting by spell ranks chain
|
||||
|
|
@ -3386,7 +3386,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
}
|
||||
|
||||
if (!prevSkill) // not found prev skill setting, remove skill
|
||||
SetSkill(spellLearnSkill->skill, 0, 0, 0);
|
||||
SetSkill(spellLearnSkill->skill, 0, 0);
|
||||
else // set to prev. skill setting values
|
||||
{
|
||||
uint32 skill_value = GetPureSkillValue(prevSkill->skill);
|
||||
|
|
@ -3400,7 +3400,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
if (skill_max_value > new_skill_max_value)
|
||||
skill_max_value = new_skill_max_value;
|
||||
|
||||
SetSkill(prevSkill->skill, prevSkill->step, skill_value, skill_max_value);
|
||||
SetSkill(prevSkill->skill, skill_value, skill_max_value, prevSkill->step);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3426,7 +3426,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
(IsProfessionSkill(pSkill->id) || _spell_idx->second->racemask != 0))
|
||||
continue;
|
||||
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 0, 0);
|
||||
SetSkill(pSkill->id, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5518,7 +5518,7 @@ void Player::UpdateSkillsToMaxSkillsForLevel()
|
|||
|
||||
// This functions sets a skill line value (and adds if doesn't exist yet)
|
||||
// To "remove" a skill line, set it's values to zero
|
||||
void Player::SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
|
||||
void Player::SetSkill(uint16 id, uint16 currVal, uint16 maxVal, uint16 step /*=0*/)
|
||||
{
|
||||
if(!id)
|
||||
return;
|
||||
|
|
@ -5530,8 +5530,8 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
|
|||
{
|
||||
if(currVal)
|
||||
{
|
||||
// update step
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), MAKE_PAIR32(id, step));
|
||||
if (step) // need update step
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), MAKE_PAIR32(id, step));
|
||||
// update value
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_SKILL_VALUE(currVal, maxVal));
|
||||
if(itr->second.uState != SKILL_NEW)
|
||||
|
|
@ -5619,18 +5619,6 @@ bool Player::HasSkill(uint32 skill) const
|
|||
return (itr != mSkillStatus.end() && itr->second.uState != SKILL_DELETED);
|
||||
}
|
||||
|
||||
uint16 Player::GetSkillStep(uint16 skill) const
|
||||
{
|
||||
if(!skill)
|
||||
return 0;
|
||||
|
||||
SkillStatusMap::const_iterator itr = mSkillStatus.find(skill);
|
||||
if(itr == mSkillStatus.end() || itr->second.uState == SKILL_DELETED)
|
||||
return 0;
|
||||
|
||||
return PAIR32_HIPART(GetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos)));
|
||||
}
|
||||
|
||||
uint16 Player::GetSkillValue(uint32 skill) const
|
||||
{
|
||||
if(!skill)
|
||||
|
|
@ -20978,21 +20966,21 @@ void Player::_LoadSkills(QueryResult *result)
|
|||
base_skill = 1; // skill mast be known and then > 0 in any case
|
||||
|
||||
if(GetPureSkillValue (SKILL_FIRST_AID) < base_skill)
|
||||
SetSkill(SKILL_FIRST_AID, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_FIRST_AID, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_AXES) < base_skill)
|
||||
SetSkill(SKILL_AXES, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_AXES, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_DEFENSE) < base_skill)
|
||||
SetSkill(SKILL_DEFENSE, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_DEFENSE, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_POLEARMS) < base_skill)
|
||||
SetSkill(SKILL_POLEARMS, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_POLEARMS, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_SWORDS) < base_skill)
|
||||
SetSkill(SKILL_SWORDS, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_SWORDS, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_2H_AXES) < base_skill)
|
||||
SetSkill(SKILL_2H_AXES, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_2H_AXES, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_2H_SWORDS) < base_skill)
|
||||
SetSkill(SKILL_2H_SWORDS, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_2H_SWORDS, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_UNARMED) < base_skill)
|
||||
SetSkill(SKILL_UNARMED, 0, base_skill, base_skill);
|
||||
SetSkill(SKILL_UNARMED, base_skill, base_skill);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue