[10074] Add IsPassive(SpellEntry*) function and use in cases wjern entry already known.

Some other small code cleanups
This commit is contained in:
VladimirMangos 2010-06-18 02:16:29 +04:00
parent 6ca609629c
commit 07a931e141
12 changed files with 35 additions and 33 deletions

View file

@ -2832,7 +2832,7 @@ void ChatHandler::ShowSpellListHelper(Player* target, SpellEntry const* spellInf
uint32 talentCost = GetTalentSpellCost(id);
bool talent = (talentCost > 0);
bool passive = IsPassiveSpell(id);
bool passive = IsPassiveSpell(spellInfo);
bool active = target && target->HasAura(id);
// unit32 used to prevent interpreting uint8 as char at output

View file

@ -1084,9 +1084,8 @@ void Object::BuildUpdateData( UpdateDataMapType& /*update_players */)
}
WorldObject::WorldObject()
: m_currMap(NULL), m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f),
m_isActiveObject(false)
: m_isActiveObject(false), m_currMap(NULL), m_mapId(0), m_InstanceId(0), m_phaseMask(PHASEMASK_NORMAL),
m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f)
{
}

View file

@ -1313,7 +1313,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
if(active == ACT_DECIDE) //active was not used before, so we save it's autocast/passive state here
{
if(IsPassiveSpell(spell_id))
if(IsPassiveSpell(spellInfo))
newspell.active = ACT_PASSIVE;
else
newspell.active = ACT_DISABLED;
@ -1369,7 +1369,7 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel
m_spells[spell_id] = newspell;
if (IsPassiveSpell(spell_id))
if (IsPassiveSpell(spellInfo))
CastSpell(this, spell_id, true);
else
m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active));

View file

@ -191,7 +191,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
}
// do not cast not learned spells
if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
if(!pet->HasSpell(spellid) || IsPassiveSpell(spellInfo))
return;
pet->clearUnitState(UNIT_STAT_MOVING);
@ -626,7 +626,7 @@ void WorldSession::HandlePetCastSpellOpcode( WorldPacket& recvPacket )
}
// do not cast not learned spells
if (!pet->HasSpell(spellid) || IsPassiveSpell(spellid))
if (!pet->HasSpell(spellid) || IsPassiveSpell(spellInfo))
return;
SpellCastTargets targets;

View file

@ -3063,7 +3063,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
if(active)
{
if (IsPassiveSpell(spell_id) && IsNeedCastPassiveSpellAtLearn(spellInfo))
if (IsPassiveSpell(spellInfo) && IsNeedCastPassiveSpellAtLearn(spellInfo))
CastSpell (this, spell_id, true);
}
else if(IsInWorld())
@ -3254,7 +3254,7 @@ bool Player::addSpell(uint32 spell_id, bool active, bool learning, bool dependen
CastSpell(this, spell_id, true);
}
// also cast passive spells (including all talents without SPELL_EFFECT_LEARN_SPELL) with additional checks
else if (IsPassiveSpell(spell_id))
else if (IsPassiveSpell(spellInfo))
{
if (IsNeedCastPassiveSpellAtLearn(spellInfo))
CastSpell(this, spell_id, true);

View file

@ -4253,7 +4253,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// auto selection spell rank implemented in WorldSession::HandleCastSpellOpcode
// this case can be triggered if rank not found (too low-level target for first rank)
if (m_caster->GetTypeId() == TYPEID_PLAYER && !IsPassiveSpell(m_spellInfo->Id) && !m_CastItem)
if (m_caster->GetTypeId() == TYPEID_PLAYER && !IsPassiveSpell(m_spellInfo) && !m_CastItem)
{
for(int i = 0; i < MAX_EFFECT_INDEX; ++i)
{
@ -4448,7 +4448,7 @@ SpellCastResult Spell::CheckCast(bool strict)
// not let players cast spells at mount (and let do it to creatures)
if (m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell &&
!IsPassiveSpell(m_spellInfo->Id) && !(m_spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED))
!IsPassiveSpell(m_spellInfo) && !(m_spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED))
{
if (m_caster->isInFlight())
return SPELL_FAILED_NOT_ON_TAXI;
@ -4457,7 +4457,7 @@ SpellCastResult Spell::CheckCast(bool strict)
}
// always (except passive spells) check items (focus object can be required for any type casts)
if (!IsPassiveSpell(m_spellInfo->Id))
if (!IsPassiveSpell(m_spellInfo))
{
SpellCastResult castResult = CheckItems();
if(castResult != SPELL_CAST_OK)

View file

@ -386,7 +386,7 @@ m_isRemovedOnShapeLost(true), m_in_use(0), m_deleted(false)
m_currentBasePoints = currentBasePoints ? *currentBasePoints : m_spellProto->CalculateSimpleValue(eff);
m_isPassive = IsPassiveSpell(GetId());
m_isPassive = IsPassiveSpell(GetSpellProto());
m_positive = IsPositiveEffect(GetId(), m_effIndex);
m_isSingleTargetAura = IsSingleTargetSpell(m_spellProto);
@ -633,7 +633,7 @@ void Aura::Update(uint32 diff)
Unit* caster = GetCaster();
if(!caster)
{
m_target->RemoveAura(GetId(), GetEffIndex());
m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
return;
}
@ -648,7 +648,7 @@ void Aura::Update(uint32 diff)
if(!caster->IsWithinDistInMap(m_target, max_range))
{
m_target->RemoveAura(GetId(), GetEffIndex());
m_target->RemoveAurasByCasterSpell(GetId(), GetEffIndex(), GetCasterGUID());
return;
}
}

View file

@ -332,7 +332,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
if (mover->GetTypeId()==TYPEID_PLAYER)
{
// not have spell in spellbook or spell passive and not casted by client
if (!((Player*)mover)->HasActiveSpell (spellId) || IsPassiveSpell(spellId) )
if (!((Player*)mover)->HasActiveSpell (spellId) || IsPassiveSpell(spellInfo))
{
sLog.outError("World: Player %u casts spell %u which he shouldn't have", mover->GetGUIDLow(), spellId);
//cheater? kick? ban?
@ -343,7 +343,7 @@ void WorldSession::HandleCastSpellOpcode(WorldPacket& recvPacket)
else
{
// not have spell in spellbook or spell passive and not casted by client
if (!((Creature*)mover)->HasSpell(spellId) || IsPassiveSpell(spellId) )
if (!((Creature*)mover)->HasSpell(spellId) || IsPassiveSpell(spellInfo))
{
//cheater? kick? ban?
recvPacket.rpos(recvPacket.wpos()); // prevent spam at ignore packet

View file

@ -283,6 +283,11 @@ bool IsPassiveSpell(uint32 spellId)
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);
if (!spellInfo)
return false;
return IsPassiveSpell(spellInfo);
}
bool IsPassiveSpell(SpellEntry const *spellInfo)
{
return (spellInfo->Attributes & SPELL_ATTR_PASSIVE) != 0;
}
@ -1607,7 +1612,7 @@ bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellI
bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo)
{
if(IsPassiveSpell(spellInfo->Id)) // ranked passive spell
if(IsPassiveSpell(spellInfo)) // ranked passive spell
return false;
if(spellInfo->powerType != POWER_MANA && spellInfo->powerType != POWER_HEALTH)
return false;
@ -2214,7 +2219,7 @@ bool SpellMgr::IsSkillBonusSpell(uint32 spellId) const
SpellEntry const* SpellMgr::SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const
{
// ignore passive spells
if(IsPassiveSpell(spellInfo->Id))
if(IsPassiveSpell(spellInfo))
return spellInfo;
bool needRankSelection = false;
@ -2588,7 +2593,7 @@ void SpellMgr::LoadSpellLearnSpells()
// talent or passive spells or skill-step spells auto-casted and not need dependent learning,
// pet teaching spells don't must be dependent learning (casted)
// other required explicit dependent learning
dbc_node.autoLearned = entry->EffectImplicitTargetA[i]==TARGET_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(spell) || IsSpellHaveEffect(entry,SPELL_EFFECT_SKILL_STEP);
dbc_node.autoLearned = entry->EffectImplicitTargetA[i]==TARGET_PET || GetTalentSpellCost(spell) > 0 || IsPassiveSpell(entry) || IsSpellHaveEffect(entry,SPELL_EFFECT_SKILL_STEP);
SpellLearnSpellMapBounds db_node_bounds = GetSpellLearnSpellMapBounds(spell);

View file

@ -210,10 +210,11 @@ bool IsSingleFromSpellSpecificSpellRanksPerTarget(SpellSpecific spellSpec1,Spell
bool IsSingleFromSpellSpecificPerTarget(SpellSpecific spellSpec1,SpellSpecific spellSpec2);
bool IsPassiveSpell(uint32 spellId);
bool IsPassiveSpell(SpellEntry const* spellProto);
inline bool IsPassiveSpellStackableWithRanks(SpellEntry const* spellProto)
{
if(!IsPassiveSpell(spellProto->Id))
if(!IsPassiveSpell(spellProto))
return false;
return !IsSpellHaveEffect(spellProto,SPELL_EFFECT_APPLY_AURA);
@ -371,12 +372,9 @@ inline bool IsAreaAuraEffect(uint32 effect)
inline bool IsDispelSpell(SpellEntry const *spellInfo)
{
if (spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_DISPEL ||
spellInfo->Effect[EFFECT_INDEX_1] == SPELL_EFFECT_DISPEL ||
spellInfo->Effect[EFFECT_INDEX_2] == SPELL_EFFECT_DISPEL )
return true;
return false;
return IsSpellHaveEffect(spellInfo, SPELL_EFFECT_DISPEL);
}
inline bool isSpellBreakStealth(SpellEntry const* spellInfo)
{
return !(spellInfo->AttributesEx & SPELL_ATTR_EX_NOT_BREAK_STEALTH);

View file

@ -4006,7 +4006,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur)
SpellEffectIndex effIndex = Aur->GetEffIndex();
// passive spell special case (only non stackable with ranks)
if(IsPassiveSpell(spellId))
if(IsPassiveSpell(spellProto))
{
if(IsPassiveSpellStackableWithRanks(spellProto))
return true;
@ -4029,7 +4029,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur)
uint32 i_spellId = i_spellProto->Id;
// early checks that spellId is passive non stackable spell
if(IsPassiveSpell(i_spellId))
if(IsPassiveSpell(i_spellProto))
{
// passive non-stackable spells not stackable only for same caster
if(Aur->GetCasterGUID()!=i->second->GetCasterGUID())
@ -8610,7 +8610,7 @@ void Unit::ModifyAuraState(AuraState flag, bool apply)
{
if(itr->second.state == PLAYERSPELL_REMOVED) continue;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(itr->first);
if (!spellInfo || !IsPassiveSpell(itr->first)) continue;
if (!spellInfo || !IsPassiveSpell(spellInfo)) continue;
if (spellInfo->CasterAuraState == flag)
CastSpell(this, itr->first, true, NULL);
}

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10073"
#define REVISION_NR "10074"
#endif // __REVISION_NR_H__