diff options
Diffstat (limited to 'src/game/Spell.cpp')
-rw-r--r-- | src/game/Spell.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index e48251347b2..e2adba9043a 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -1735,9 +1735,8 @@ WorldObject* Spell::SearchNearbyTarget(float range, SpellTargets TargetType) { case SPELL_TARGETS_ENTRY: { - SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(m_spellInfo->Id); - SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(m_spellInfo->Id); - if(lower == upper) + SpellScriptTargetBounds bounds = spellmgr.GetSpellScriptTargetBounds(m_spellInfo->Id); + if(bounds.first==bounds.second) { sLog.outDebug("Spell (ID: %u) (caster Entry: %u) does not have record in `spell_script_target`", m_spellInfo->Id, m_caster->GetEntry()); if(IsPositiveSpell(m_spellInfo->Id)) @@ -1749,7 +1748,7 @@ WorldObject* Spell::SearchNearbyTarget(float range, SpellTargets TargetType) Creature* creatureScriptTarget = NULL; GameObject* goScriptTarget = NULL; - for(SpellScriptTarget::const_iterator i_spellST = lower; i_spellST != upper; ++i_spellST) + for(SpellScriptTarget::const_iterator i_spellST = bounds.first; i_spellST != bounds.second; ++i_spellST) { switch(i_spellST->second.type) { @@ -2285,9 +2284,8 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur) std::list<Unit*> unitList; if(targetType == SPELL_TARGETS_ENTRY) { - SpellScriptTarget::const_iterator lower = spellmgr.GetBeginSpellScriptTarget(m_spellInfo->Id); - SpellScriptTarget::const_iterator upper = spellmgr.GetEndSpellScriptTarget(m_spellInfo->Id); - if(lower == upper) + SpellScriptTargetBounds bounds = spellmgr.GetSpellScriptTargetBounds(m_spellInfo->Id); + if(bounds.first==bounds.second) { // Custom entries // TODO: move these to sql @@ -2360,7 +2358,7 @@ void Spell::SelectEffectTargets(uint32 i, uint32 cur) // let it be done in one check? else { - for(SpellScriptTarget::const_iterator i_spellST = lower; i_spellST != upper; ++i_spellST) + for(SpellScriptTarget::const_iterator i_spellST = bounds.first; i_spellST != bounds.second; ++i_spellST) { if(i_spellST->second.type == SPELL_TARGET_TYPE_CREATURE) SearchAreaTarget(unitList, radius, pushType, SPELL_TARGETS_ENTRY, i_spellST->second.targetEntry); @@ -4566,15 +4564,15 @@ SpellCastResult Spell::CheckCast(bool strict) } // Spell casted only on battleground - if((m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId() == TYPEID_PLAYER) + if ((m_spellInfo->AttributesEx3 & SPELL_ATTR_EX3_BATTLEGROUND) && m_caster->GetTypeId() == TYPEID_PLAYER) if(!((Player*)m_caster)->InBattleGround()) return SPELL_FAILED_ONLY_BATTLEGROUNDS; // do not allow spells to be cast in arenas // - with greater than 15 min CD without SPELL_ATTR_EX4_USABLE_IN_ARENA flag // - with SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA flag - if( (m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || - GetSpellRecoveryTime(m_spellInfo) > 15 * MINUTE * IN_MILISECONDS && !(m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA) ) + if ((m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_NOT_USABLE_IN_ARENA) || + GetSpellRecoveryTime(m_spellInfo) > 15 * MINUTE * IN_MILISECONDS && !(m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_USABLE_IN_ARENA)) if(MapEntry const* mapEntry = sMapStore.LookupEntry(m_caster->GetMapId())) if(mapEntry->IsBattleArena()) return SPELL_FAILED_NOT_IN_ARENA; @@ -4592,17 +4590,17 @@ 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) ) + if (m_caster->IsMounted() && m_caster->GetTypeId()==TYPEID_PLAYER && !m_IsTriggeredSpell && + !IsPassiveSpell(m_spellInfo->Id) && !(m_spellInfo->Attributes & SPELL_ATTR_CASTABLE_WHILE_MOUNTED)) { - if(m_caster->isInFlight()) + if (m_caster->isInFlight()) return SPELL_FAILED_NOT_FLYING; else return SPELL_FAILED_NOT_MOUNTED; } // always (except passive spells) check items (focus object can be required for any type casts) - if(!IsPassiveSpell(m_spellInfo->Id)) + if (!IsPassiveSpell(m_spellInfo->Id)) { SpellCastResult castResult = CheckItems(); if(castResult != SPELL_CAST_OK) @@ -4630,7 +4628,7 @@ SpellCastResult Spell::CheckCast(bool strict) Creature* creatureScriptTarget = NULL; GameObject* goScriptTarget = NULL; - for(SpellScriptTarget::const_iterator i_spellST = lower; i_spellST != upper; ++i_spellST) + for(SpellScriptTarget::const_iterator i_spellST = bounds.first; i_spellST != bounds.second; ++i_spellST) { switch(i_spellST->second.type) { @@ -4638,7 +4636,7 @@ SpellCastResult Spell::CheckCast(bool strict) { GameObject* p_GameObject = NULL; - if(i_spellST->second.targetEntry) + if (i_spellST->second.targetEntry) { CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY())); Cell cell(p); @@ -4651,7 +4649,7 @@ SpellCastResult Spell::CheckCast(bool strict) CellLock<GridReadGuard> cell_lock(cell, p); cell_lock->Visit(cell_lock, object_checker, *m_caster->GetMap()); - if(p_GameObject) + if (p_GameObject) { // remember found target and range, next attempt will find more near target with another entry creatureScriptTarget = NULL; @@ -4659,10 +4657,10 @@ SpellCastResult Spell::CheckCast(bool strict) range = go_check.GetLastRange(); } } - else if( focusObject ) // Focus Object + else if (focusObject) // Focus Object { float frange = m_caster->GetDistance(focusObject); - if(range >= frange) + if (range >= frange) { creatureScriptTarget = NULL; goScriptTarget = focusObject; @@ -6793,4 +6791,4 @@ void Spell::FillRaidOrPartyHealthPriorityTargets( UnitList &TagUnitMap, Unit* ta TagUnitMap.push_back(healthQueue.top().getUnit()); healthQueue.pop(); } -} +}
\ No newline at end of file |