mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 19:37:02 +00:00
[8426] Use upper/lower iterator pairs as result instead 2 function calls.
This commit is contained in:
parent
fdb2842f60
commit
5d50bb16b8
9 changed files with 139 additions and 173 deletions
|
|
@ -3966,15 +3966,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;
|
||||
|
|
@ -3985,21 +3985,21 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
|
||||
SpellCastResult locRes= spellmgr.GetSpellAllowedInLocationError(m_spellInfo,m_caster->GetMapId(),zone,area,
|
||||
m_caster->GetTypeId() == TYPEID_PLAYER ? ((Player*)m_caster) : NULL);
|
||||
if(locRes != SPELL_CAST_OK)
|
||||
if (locRes != SPELL_CAST_OK)
|
||||
return locRes;
|
||||
|
||||
// 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)
|
||||
|
|
@ -4007,7 +4007,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
}
|
||||
|
||||
//ImpliciteTargetA-B = 38, If fact there is 0 Spell with ImpliciteTargetB=38
|
||||
if(m_UniqueTargetInfo.empty()) // skip second CheckCast apply (for delayed spells for example)
|
||||
if (m_UniqueTargetInfo.empty()) // skip second CheckCast apply (for delayed spells for example)
|
||||
{
|
||||
for(uint8 j = 0; j < 3; ++j)
|
||||
{
|
||||
|
|
@ -4016,9 +4016,8 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES ||
|
||||
m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES )
|
||||
{
|
||||
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.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = TARGET_SCRIPT or TARGET_SCRIPT_COORDINATES, but does not have record in `spell_script_target`",m_spellInfo->Id);
|
||||
|
||||
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
|
||||
|
|
@ -4027,7 +4026,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)
|
||||
{
|
||||
|
|
@ -4035,7 +4034,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);
|
||||
|
|
@ -4048,7 +4047,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;
|
||||
|
|
@ -4056,10 +4055,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;
|
||||
|
|
@ -5952,4 +5951,4 @@ void Spell::FillRaidOrPartyHealthPriorityTargets( UnitList &TagUnitMap, Unit* me
|
|||
TagUnitMap.push_back(healthQueue.top().getUnit());
|
||||
healthQueue.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue