mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +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
|
||||
learnDefaultSpells(true);
|
||||
learnDefaultSpells();
|
||||
|
||||
// original action bar
|
||||
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);
|
||||
if (!spellInfo)
|
||||
{
|
||||
// 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);
|
||||
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))
|
||||
{
|
||||
// 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);
|
||||
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;
|
||||
|
||||
// loading && !learning == explicitly load from DB and then exist in it already and set correctly
|
||||
if(loading && !learning)
|
||||
// !IsInWorld() && !learning == explicitly load from DB and then exist in it already and set correctly
|
||||
if(!IsInWorld() && !learning)
|
||||
itr->second->state = PLAYERSPELL_UNCHANGED;
|
||||
else if(itr->second->state != PLAYERSPELL_NEW)
|
||||
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)
|
||||
{
|
||||
// can be in case spell loading but learned at some previous spell loading
|
||||
if(loading && !learning)
|
||||
if(!IsInWorld() && !learning)
|
||||
itr->second->state = PLAYERSPELL_UNCHANGED;
|
||||
|
||||
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)
|
||||
else if(uint32 prev_spell = spellmgr.GetPrevSpellInChain(spell_id))
|
||||
{
|
||||
if(loading) // at spells loading, no output, but allow save
|
||||
addSpell(prev_spell,active,true,loading,disabled);
|
||||
if(!IsInWorld()) // at spells loading, no output, but allow save
|
||||
addSpell(prev_spell,active,true,disabled);
|
||||
else // at normal learning
|
||||
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(!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));
|
||||
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))
|
||||
{
|
||||
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));
|
||||
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(loading || !itr->second.active) // at spells loading, no output, but allow save
|
||||
addSpell(itr->second.spell,itr->second.active,true,loading);
|
||||
if(!IsInWorld() || !itr->second.active) // at spells loading, no output, but allow save
|
||||
addSpell(itr->second.spell,itr->second.active,true,false);
|
||||
else // at normal learning
|
||||
learnSpell(itr->second.spell);
|
||||
}
|
||||
}
|
||||
|
||||
if(!loading)
|
||||
if(IsInWorld())
|
||||
{
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SPELL);
|
||||
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 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)
|
||||
SpellChainMapNext const& nextMap = spellmgr.GetSpellChainNext();
|
||||
|
|
@ -2857,8 +2857,8 @@ void Player::learnSpell(uint32 spell_id)
|
|||
learnSpell(i->second);
|
||||
}
|
||||
|
||||
// prevent duplicated entires in spell book
|
||||
if(!learning)
|
||||
// prevent duplicated entires in spell book, also not send if not in world (loading)
|
||||
if(!learning || !IsInWorld ())
|
||||
return;
|
||||
|
||||
WorldPacket data(SMSG_LEARNED_SPELL, 4);
|
||||
|
|
@ -14157,6 +14157,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
|||
// after spell load
|
||||
InitTalentForLevel();
|
||||
learnSkillRewardedSpells();
|
||||
learnDefaultSpells();
|
||||
|
||||
|
||||
// after spell load, learn rewarded spell if need also
|
||||
_LoadQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS));
|
||||
|
|
@ -14932,7 +14934,7 @@ void Player::_LoadSpells(QueryResult *result)
|
|||
{
|
||||
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() );
|
||||
|
||||
|
|
@ -17904,7 +17906,7 @@ void Player::resetSpells()
|
|||
learnQuestRewardedSpells();
|
||||
}
|
||||
|
||||
void Player::learnDefaultSpells(bool loading)
|
||||
void Player::learnDefaultSpells()
|
||||
{
|
||||
// learn default race/class spells
|
||||
PlayerInfo const *info = objmgr.GetPlayerInfo(getRace(),getClass());
|
||||
|
|
@ -17912,8 +17914,8 @@ void Player::learnDefaultSpells(bool loading)
|
|||
{
|
||||
uint32 tspell = *itr;
|
||||
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
|
||||
addSpell(tspell,true);
|
||||
if(!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add
|
||||
addSpell(tspell,true,true,false);
|
||||
else // but send in normal spell in game learn case
|
||||
learnSpell(tspell);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1467,11 +1467,11 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
|
||||
void SendProficiency(uint8 pr1, uint32 pr2);
|
||||
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 removeSpell(uint32 spell_id, bool disabled = false);
|
||||
void resetSpells();
|
||||
void learnDefaultSpells(bool loading = false);
|
||||
void learnDefaultSpells();
|
||||
void learnQuestRewardedSpells();
|
||||
void learnQuestRewardedSpells(Quest const* quest);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7069"
|
||||
#define REVISION_NR "7070"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue