mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 01:37:00 +00:00
Fixed bug with professions in trainer list not being marked as known until trainer list re-opened.
This commit is contained in:
parent
112046718a
commit
b99f51a984
13 changed files with 108 additions and 91 deletions
|
|
@ -3036,7 +3036,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
if(!IsInWorld() || disabled) // at spells loading, no output, but allow save
|
||||
addSpell(prev_spell, active, true, true, disabled);
|
||||
else // at normal learning
|
||||
learnSpell(prev_spell, 0, true);
|
||||
learnSpell(prev_spell, true);
|
||||
}
|
||||
|
||||
PlayerSpell newspell;
|
||||
|
|
@ -3133,7 +3133,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
}
|
||||
|
||||
// add dependent skills
|
||||
uint16 maxskill = GetMaxSkillValueForLevel();
|
||||
uint16 maxskill = GetMaxSkillValueForLevel();
|
||||
|
||||
SpellLearnSkillNode const* spellLearnSkill = sSpellMgr.GetSpellLearnSkill(spell_id);
|
||||
|
||||
|
|
@ -3152,7 +3152,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,skill_value,skill_max_value);
|
||||
SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3170,16 +3170,16 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
// 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))
|
||||
{
|
||||
switch(GetSkillRangeType(pSkill,_spell_idx->second->racemask!=0))
|
||||
switch(GetSkillRangeType(pSkill, _spell_idx->second->racemask != 0))
|
||||
{
|
||||
case SKILL_RANGE_LANGUAGE:
|
||||
SetSkill(pSkill->id, 300, 300 );
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 300, 300 );
|
||||
break;
|
||||
case SKILL_RANGE_LEVEL:
|
||||
SetSkill(pSkill->id, 1, GetMaxSkillValueForLevel() );
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 1, GetMaxSkillValueForLevel() );
|
||||
break;
|
||||
case SKILL_RANGE_MONO:
|
||||
SetSkill(pSkill->id, 1, 1 );
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 1, 1 );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -3198,7 +3198,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
|
|||
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, 0, true);
|
||||
learnSpell(itr2->second.spell, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3228,7 +3228,7 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const
|
|||
return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraState(spellInfo->CasterAuraState)));
|
||||
}
|
||||
|
||||
void Player::learnSpell(uint32 spell_id, uint32 triggeredBySpell, bool dependent)
|
||||
void Player::learnSpell(uint32 spell_id, bool dependent)
|
||||
{
|
||||
PlayerSpellMap::iterator itr = m_spells.find(spell_id);
|
||||
|
||||
|
|
@ -3245,7 +3245,7 @@ void Player::learnSpell(uint32 spell_id, uint32 triggeredBySpell, bool dependent
|
|||
{
|
||||
PlayerSpellMap::iterator iter = m_spells.find(i->second);
|
||||
if (iter != m_spells.end() && iter->second.disabled)
|
||||
learnSpell(i->second, 0, false);
|
||||
learnSpell(i->second, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3254,8 +3254,8 @@ void Player::learnSpell(uint32 spell_id, uint32 triggeredBySpell, bool dependent
|
|||
return;
|
||||
|
||||
WorldPacket data(SMSG_LEARNED_SPELL, 6);
|
||||
data << uint32((triggeredBySpell == 0) ? spell_id : triggeredBySpell);
|
||||
data << uint16(0);
|
||||
data << uint32(spell_id);
|
||||
data << uint16(0); // 3.3.3 unk
|
||||
GetSession()->SendPacket(&data);
|
||||
}
|
||||
|
||||
|
|
@ -3272,7 +3272,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
SpellChainMapNext const& nextMap = sSpellMgr.GetSpellChainNext();
|
||||
for(SpellChainMapNext::const_iterator itr2 = nextMap.lower_bound(spell_id); itr2 != nextMap.upper_bound(spell_id); ++itr2)
|
||||
if(HasSpell(itr2->second) && !GetTalentSpellPos(itr2->second))
|
||||
removeSpell(itr2->second,disabled,false);
|
||||
removeSpell(itr2->second, disabled, false);
|
||||
|
||||
// re-search, it can be corrupted in prev loop
|
||||
itr = m_spells.find(spell_id);
|
||||
|
|
@ -3327,7 +3327,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);
|
||||
SetSkill(spellLearnSkill->skill, 0, 0, 0);
|
||||
else
|
||||
{
|
||||
// search prev. skill setting by spell ranks chain
|
||||
|
|
@ -3339,7 +3339,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);
|
||||
SetSkill(spellLearnSkill->skill, 0, 0, 0);
|
||||
else // set to prev. skill setting values
|
||||
{
|
||||
uint32 skill_value = GetPureSkillValue(prevSkill->skill);
|
||||
|
|
@ -3353,7 +3353,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,skill_value,skill_max_value);
|
||||
SetSkill(prevSkill->skill, prevSkill->step, skill_value, skill_max_value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3372,14 +3372,14 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
if(_spell_idx->second->learnOnGetSkill == ABILITY_LEARNED_ON_GET_RACE_OR_CLASS_SKILL &&
|
||||
pSkill->categoryId != SKILL_CATEGORY_CLASS ||// not unlearn class skills (spellbook/talent pages)
|
||||
// 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))
|
||||
((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 );
|
||||
SetSkill(pSkill->id, GetSkillStep(pSkill->id), 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3401,7 +3401,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
if (talentCosts)
|
||||
{
|
||||
if(learn_low_rank)
|
||||
learnSpell(prev_id, 0, false);
|
||||
learnSpell(prev_id, false);
|
||||
}
|
||||
// if ranked non-stackable spell: need activate lesser rank and update dendence state
|
||||
else if (cur_active && !SpellMgr::canStackSpellRanks(spellInfo) && sSpellMgr.GetSpellRank(spellInfo->Id) != 0)
|
||||
|
|
@ -3420,7 +3420,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank, bo
|
|||
// now re-learn if need re-activate
|
||||
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);
|
||||
|
|
@ -5169,7 +5169,7 @@ bool Player::UpdateCraftSkill(uint32 spellid)
|
|||
if (spellEntry && spellEntry->Mechanic == MECHANIC_DISCOVERY)
|
||||
{
|
||||
if (uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->skillId, spellid, this))
|
||||
learnSpell(discoveredSpell, 0, false);
|
||||
learnSpell(discoveredSpell, false);
|
||||
}
|
||||
|
||||
uint32 craft_skill_gain = sWorld.getConfig(CONFIG_UINT32_SKILL_GAIN_CRAFTING);
|
||||
|
|
@ -5454,7 +5454,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(uint32 id, uint16 currVal, uint16 maxVal)
|
||||
void Player::SetSkill(uint16 id, uint16 step, uint16 currVal, uint16 maxVal)
|
||||
{
|
||||
if(!id)
|
||||
return;
|
||||
|
|
@ -5466,19 +5466,19 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
|
|||
{
|
||||
if(currVal)
|
||||
{
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos),MAKE_SKILL_VALUE(currVal,maxVal));
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_SKILL_VALUE(currVal, maxVal));
|
||||
if(itr->second.uState != SKILL_NEW)
|
||||
itr->second.uState = SKILL_CHANGED;
|
||||
learnSkillRewardedSpells(id, currVal);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL,id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id);
|
||||
}
|
||||
else //remove
|
||||
{
|
||||
// clear skill fields
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos),0);
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos),0);
|
||||
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos),0);
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(itr->second.pos), 0);
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), 0);
|
||||
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(itr->second.pos), 0);
|
||||
|
||||
// mark as deleted or simply remove from map if not saved yet
|
||||
if(itr->second.uState != SKILL_NEW)
|
||||
|
|
@ -5487,9 +5487,9 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
|
|||
mSkillStatus.erase(itr);
|
||||
|
||||
// remove all spells that related to this skill
|
||||
for (uint32 j=0; j<sSkillLineAbilityStore.GetNumRows(); ++j)
|
||||
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
|
||||
if(SkillLineAbilityEntry const *pAbility = sSkillLineAbilityStore.LookupEntry(j))
|
||||
if (pAbility->skillId==id)
|
||||
if (pAbility->skillId == id)
|
||||
removeSpell(sSpellMgr.GetFirstSpellInChain(pAbility->spellId));
|
||||
}
|
||||
}
|
||||
|
|
@ -5504,14 +5504,11 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
|
|||
sLog.outError("Skill not found in SkillLineStore: skill #%u", id);
|
||||
return;
|
||||
}
|
||||
// enable unlearn button for primary professions only
|
||||
if (pSkill->categoryId == SKILL_CATEGORY_PROFESSION)
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,1));
|
||||
else
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id,0));
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal,maxVal));
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL,id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL,id);
|
||||
|
||||
SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id, step));
|
||||
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i),MAKE_SKILL_VALUE(currVal, maxVal));
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id);
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id);
|
||||
|
||||
// insert new entry or update if not deleted old entry yet
|
||||
if(itr != mSkillStatus.end())
|
||||
|
|
@ -5523,7 +5520,7 @@ void Player::SetSkill(uint32 id, uint16 currVal, uint16 maxVal)
|
|||
mSkillStatus.insert(SkillStatusMap::value_type(id, SkillStatusData(i, SKILL_NEW)));
|
||||
|
||||
// apply skill bonuses
|
||||
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i),0);
|
||||
SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i), 0);
|
||||
|
||||
// temporary bonuses
|
||||
AuraList const& mModSkill = GetAurasByType(SPELL_AURA_MOD_SKILL);
|
||||
|
|
@ -5553,6 +5550,18 @@ 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)
|
||||
|
|
@ -19214,7 +19223,7 @@ void Player::learnDefaultSpells()
|
|||
if(!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add
|
||||
addSpell(tspell, true, true, true, false);
|
||||
else // but send in normal spell in game learn case
|
||||
learnSpell(tspell, 0, true);
|
||||
learnSpell(tspell, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -19331,7 +19340,7 @@ void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value )
|
|||
else if (!IsInWorld())
|
||||
addSpell(pAbility->spellId, true, true, true, false);
|
||||
else
|
||||
learnSpell(pAbility->spellId, 0, true);
|
||||
learnSpell(pAbility->spellId, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -20618,13 +20627,13 @@ bool Player::IsKnowHowFlyIn(uint32 mapid, uint32 zone) const
|
|||
struct DoPlayerLearnSpell
|
||||
{
|
||||
DoPlayerLearnSpell(Player& _player) : player(_player) {}
|
||||
void operator() (uint32 spell_id) { player.learnSpell(spell_id, 0, false); }
|
||||
void operator() (uint32 spell_id) { player.learnSpell(spell_id, false); }
|
||||
Player& player;
|
||||
};
|
||||
|
||||
void Player::learnSpellHighRank(uint32 spellid)
|
||||
{
|
||||
learnSpell(spellid, 0, false);
|
||||
learnSpell(spellid, false);
|
||||
|
||||
DoPlayerLearnSpell worker(*this);
|
||||
sSpellMgr.doForHighRanks(spellid, worker);
|
||||
|
|
@ -20715,21 +20724,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,base_skill, base_skill);
|
||||
SetSkill(SKILL_FIRST_AID, 0, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_AXES) < base_skill)
|
||||
SetSkill(SKILL_AXES, base_skill,base_skill);
|
||||
SetSkill(SKILL_AXES, 0, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_DEFENSE) < base_skill)
|
||||
SetSkill(SKILL_DEFENSE, base_skill,base_skill);
|
||||
SetSkill(SKILL_DEFENSE, 0, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_POLEARMS) < base_skill)
|
||||
SetSkill(SKILL_POLEARMS, base_skill,base_skill);
|
||||
SetSkill(SKILL_POLEARMS, 0, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_SWORDS) < base_skill)
|
||||
SetSkill(SKILL_SWORDS, base_skill,base_skill);
|
||||
SetSkill(SKILL_SWORDS, 0, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_2H_AXES) < base_skill)
|
||||
SetSkill(SKILL_2H_AXES, base_skill,base_skill);
|
||||
SetSkill(SKILL_2H_AXES, 0, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_2H_SWORDS) < base_skill)
|
||||
SetSkill(SKILL_2H_SWORDS, base_skill,base_skill);
|
||||
SetSkill(SKILL_2H_SWORDS, 0, base_skill, base_skill);
|
||||
if(GetPureSkillValue (SKILL_UNARMED) < base_skill)
|
||||
SetSkill(SKILL_UNARMED, base_skill,base_skill);
|
||||
SetSkill(SKILL_UNARMED, 0, base_skill, base_skill);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20975,7 +20984,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
|
|||
return;
|
||||
|
||||
// learn! (other talent ranks will unlearned at learning)
|
||||
learnSpell(spellid, 0, false);
|
||||
learnSpell(spellid, false);
|
||||
sLog.outDetail("TalentID: %u Rank: %u Spell: %u\n", talentId, talentRank, spellid);
|
||||
|
||||
// update free talent points
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue