mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
[7070] Use IsInWorld() check instead explcit loading args in spell learning code. Learn default spells at loading also.
At player loading known spells (full list) send to client at adding player to map, so !IsInWorld() is most correct way check when spell learn packets not need send and wait seniding full spell list.
This commit is contained in:
parent
22db1a3d39
commit
8b87829099
3 changed files with 26 additions and 24 deletions
|
|
@ -653,7 +653,7 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
// original spells
|
// original spells
|
||||||
learnDefaultSpells(true);
|
learnDefaultSpells();
|
||||||
|
|
||||||
// original action bar
|
// original action bar
|
||||||
std::list<uint16>::const_iterator action_itr[4];
|
std::list<uint16>::const_iterator action_itr[4];
|
||||||
|
|
@ -2528,13 +2528,13 @@ void Player::AddNewMailDeliverTime(time_t deliver_time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading, bool disabled)
|
bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool disabled)
|
||||||
{
|
{
|
||||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
|
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id);
|
||||||
if (!spellInfo)
|
if (!spellInfo)
|
||||||
{
|
{
|
||||||
// do character spell book cleanup (all characters)
|
// do character spell book cleanup (all characters)
|
||||||
if(loading && !learning) // spell load case
|
if(!IsInWorld() && !learning) // spell load case
|
||||||
{
|
{
|
||||||
sLog.outError("Player::addSpell: Non-existed in SpellStore spell #%u request, deleting for all characters in `character_spell`.",spell_id);
|
sLog.outError("Player::addSpell: Non-existed in SpellStore spell #%u request, deleting for all characters in `character_spell`.",spell_id);
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id);
|
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id);
|
||||||
|
|
@ -2548,7 +2548,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading,
|
||||||
if(!SpellMgr::IsSpellValid(spellInfo,this,false))
|
if(!SpellMgr::IsSpellValid(spellInfo,this,false))
|
||||||
{
|
{
|
||||||
// do character spell book cleanup (all characters)
|
// do character spell book cleanup (all characters)
|
||||||
if(loading && !learning) // spell load case
|
if(!IsInWorld() && !learning) // spell load case
|
||||||
{
|
{
|
||||||
sLog.outError("Player::addSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.",spell_id);
|
sLog.outError("Player::addSpell: Broken spell #%u learning not allowed, deleting for all characters in `character_spell`.",spell_id);
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id);
|
CharacterDatabase.PExecute("DELETE FROM character_spell WHERE spell = '%u'",spell_id);
|
||||||
|
|
@ -2572,8 +2572,8 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading,
|
||||||
{
|
{
|
||||||
itr->second->active = active;
|
itr->second->active = active;
|
||||||
|
|
||||||
// loading && !learning == explicitly load from DB and then exist in it already and set correctly
|
// !IsInWorld() && !learning == explicitly load from DB and then exist in it already and set correctly
|
||||||
if(loading && !learning)
|
if(!IsInWorld() && !learning)
|
||||||
itr->second->state = PLAYERSPELL_UNCHANGED;
|
itr->second->state = PLAYERSPELL_UNCHANGED;
|
||||||
else if(itr->second->state != PLAYERSPELL_NEW)
|
else if(itr->second->state != PLAYERSPELL_NEW)
|
||||||
itr->second->state = PLAYERSPELL_CHANGED;
|
itr->second->state = PLAYERSPELL_CHANGED;
|
||||||
|
|
@ -2612,7 +2612,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading,
|
||||||
default: // known not saved yet spell (new or modified)
|
default: // known not saved yet spell (new or modified)
|
||||||
{
|
{
|
||||||
// can be in case spell loading but learned at some previous spell loading
|
// can be in case spell loading but learned at some previous spell loading
|
||||||
if(loading && !learning)
|
if(!IsInWorld() && !learning)
|
||||||
itr->second->state = PLAYERSPELL_UNCHANGED;
|
itr->second->state = PLAYERSPELL_UNCHANGED;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -2645,8 +2645,8 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading,
|
||||||
// non talent spell: learn low ranks (recursive call)
|
// non talent spell: learn low ranks (recursive call)
|
||||||
else if(uint32 prev_spell = spellmgr.GetPrevSpellInChain(spell_id))
|
else if(uint32 prev_spell = spellmgr.GetPrevSpellInChain(spell_id))
|
||||||
{
|
{
|
||||||
if(loading) // at spells loading, no output, but allow save
|
if(!IsInWorld()) // at spells loading, no output, but allow save
|
||||||
addSpell(prev_spell,active,true,loading,disabled);
|
addSpell(prev_spell,active,true,disabled);
|
||||||
else // at normal learning
|
else // at normal learning
|
||||||
learnSpell(prev_spell);
|
learnSpell(prev_spell);
|
||||||
}
|
}
|
||||||
|
|
@ -2671,7 +2671,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading,
|
||||||
{
|
{
|
||||||
if(spellmgr.IsHighRankOfSpell(spell_id,itr->first))
|
if(spellmgr.IsHighRankOfSpell(spell_id,itr->first))
|
||||||
{
|
{
|
||||||
if(!loading) // not send spell (re-/over-)learn packets at loading
|
if(IsInWorld()) // not send spell (re-/over-)learn packets at loading
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
|
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
|
||||||
data << uint16(itr->first);
|
data << uint16(itr->first);
|
||||||
|
|
@ -2686,7 +2686,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading,
|
||||||
}
|
}
|
||||||
else if(spellmgr.IsHighRankOfSpell(itr->first,spell_id))
|
else if(spellmgr.IsHighRankOfSpell(itr->first,spell_id))
|
||||||
{
|
{
|
||||||
if(!loading) // not send spell (re-/over-)learn packets at loading
|
if(IsInWorld()) // not send spell (re-/over-)learn packets at loading
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
|
WorldPacket data(SMSG_SUPERCEDED_SPELL, (4));
|
||||||
data << uint16(spell_id);
|
data << uint16(spell_id);
|
||||||
|
|
@ -2822,14 +2822,14 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool loading,
|
||||||
{
|
{
|
||||||
if(!itr->second.autoLearned)
|
if(!itr->second.autoLearned)
|
||||||
{
|
{
|
||||||
if(loading || !itr->second.active) // at spells loading, no output, but allow save
|
if(!IsInWorld() || !itr->second.active) // at spells loading, no output, but allow save
|
||||||
addSpell(itr->second.spell,itr->second.active,true,loading);
|
addSpell(itr->second.spell,itr->second.active,true,false);
|
||||||
else // at normal learning
|
else // at normal learning
|
||||||
learnSpell(itr->second.spell);
|
learnSpell(itr->second.spell);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!loading)
|
if(IsInWorld())
|
||||||
{
|
{
|
||||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL);
|
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL);
|
||||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS);
|
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS);
|
||||||
|
|
@ -2846,7 +2846,7 @@ void Player::learnSpell(uint32 spell_id)
|
||||||
bool disabled = (itr != m_spells.end()) ? itr->second->disabled : false;
|
bool disabled = (itr != m_spells.end()) ? itr->second->disabled : false;
|
||||||
bool active = disabled ? itr->second->active : true;
|
bool active = disabled ? itr->second->active : true;
|
||||||
|
|
||||||
bool learning = addSpell(spell_id,active);
|
bool learning = addSpell(spell_id,active,true,false);
|
||||||
|
|
||||||
// learn all disabled higher ranks (recursive)
|
// learn all disabled higher ranks (recursive)
|
||||||
SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext();
|
SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext();
|
||||||
|
|
@ -2857,8 +2857,8 @@ void Player::learnSpell(uint32 spell_id)
|
||||||
learnSpell(i->second);
|
learnSpell(i->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
// prevent duplicated entires in spell book
|
// prevent duplicated entires in spell book, also not send if not in world (loading)
|
||||||
if(!learning)
|
if(!learning || !IsInWorld ())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
WorldPacket data(SMSG_LEARNED_SPELL, 4);
|
WorldPacket data(SMSG_LEARNED_SPELL, 4);
|
||||||
|
|
@ -14157,6 +14157,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||||
// after spell load
|
// after spell load
|
||||||
InitTalentForLevel();
|
InitTalentForLevel();
|
||||||
learnSkillRewardedSpells();
|
learnSkillRewardedSpells();
|
||||||
|
learnDefaultSpells();
|
||||||
|
|
||||||
|
|
||||||
// after spell load, learn rewarded spell if need also
|
// after spell load, learn rewarded spell if need also
|
||||||
_LoadQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS));
|
_LoadQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS));
|
||||||
|
|
@ -14932,7 +14934,7 @@ void Player::_LoadSpells(QueryResult *result)
|
||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
|
|
||||||
addSpell(fields[0].GetUInt16(), fields[1].GetBool(), false, true, fields[2].GetBool());
|
addSpell(fields[0].GetUInt16(), fields[1].GetBool(), false, fields[2].GetBool());
|
||||||
}
|
}
|
||||||
while( result->NextRow() );
|
while( result->NextRow() );
|
||||||
|
|
||||||
|
|
@ -17904,7 +17906,7 @@ void Player::resetSpells()
|
||||||
learnQuestRewardedSpells();
|
learnQuestRewardedSpells();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::learnDefaultSpells(bool loading)
|
void Player::learnDefaultSpells()
|
||||||
{
|
{
|
||||||
// learn default race/class spells
|
// learn default race/class spells
|
||||||
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(),getClass());
|
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(),getClass());
|
||||||
|
|
@ -17912,8 +17914,8 @@ void Player::learnDefaultSpells(bool loading)
|
||||||
{
|
{
|
||||||
uint32 tspell = *itr;
|
uint32 tspell = *itr;
|
||||||
sLog.outDebug("PLAYER (Class: %u Race: %u): Adding initial spell, id = %u",uint32(getClass()),uint32(getRace()), tspell);
|
sLog.outDebug("PLAYER (Class: %u Race: %u): Adding initial spell, id = %u",uint32(getClass()),uint32(getRace()), tspell);
|
||||||
if(loading) // will send in INITIAL_SPELLS in list anyway
|
if(!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add
|
||||||
addSpell(tspell,true);
|
addSpell(tspell,true,true,false);
|
||||||
else // but send in normal spell in game learn case
|
else // but send in normal spell in game learn case
|
||||||
learnSpell(tspell);
|
learnSpell(tspell);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1467,11 +1467,11 @@ class MANGOS_DLL_SPEC Player : public Unit
|
||||||
|
|
||||||
void SendProficiency(uint8 pr1, uint32 pr2);
|
void SendProficiency(uint8 pr1, uint32 pr2);
|
||||||
void SendInitialSpells();
|
void SendInitialSpells();
|
||||||
bool addSpell(uint32 spell_id, bool active, bool learning = true, bool loading = false, bool disabled = false);
|
bool addSpell(uint32 spell_id, bool active, bool learning, bool disabled);
|
||||||
void learnSpell(uint32 spell_id);
|
void learnSpell(uint32 spell_id);
|
||||||
void removeSpell(uint32 spell_id, bool disabled = false);
|
void removeSpell(uint32 spell_id, bool disabled = false);
|
||||||
void resetSpells();
|
void resetSpells();
|
||||||
void learnDefaultSpells(bool loading = false);
|
void learnDefaultSpells();
|
||||||
void learnQuestRewardedSpells();
|
void learnQuestRewardedSpells();
|
||||||
void learnQuestRewardedSpells(Quest const* quest);
|
void learnQuestRewardedSpells(Quest const* quest);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "7069"
|
#define REVISION_NR "7070"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue