diff options
| author | Spp <spp@jorge.gr> | 2013-05-30 13:14:06 +0200 |
|---|---|---|
| committer | Spp <spp@jorge.gr> | 2013-05-30 13:18:29 +0200 |
| commit | 9664c0ab5cc7449f2e839fb60b6b87c9d56dfb92 (patch) | |
| tree | 092af4d16233823423cc552c567acb3307380951 /src/server/game/AI | |
| parent | 782ea4309a4d392ba9933caace067d567703c84b (diff) | |
Core/Misc: Another batch of fixes for issues found by static analysis
Diffstat (limited to 'src/server/game/AI')
| -rw-r--r-- | src/server/game/AI/CoreAI/UnitAI.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/src/server/game/AI/CoreAI/UnitAI.cpp b/src/server/game/AI/CoreAI/UnitAI.cpp index 0ab807466d5..70c4761e025 100644 --- a/src/server/game/AI/CoreAI/UnitAI.cpp +++ b/src/server/game/AI/CoreAI/UnitAI.cpp @@ -123,34 +123,45 @@ void UnitAI::DoCastToAllHostilePlayers(uint32 spellid, bool triggered) void UnitAI::DoCast(uint32 spellId) { Unit* target = NULL; - //TC_LOG_ERROR(LOG_FILTER_GENERAL, "aggre %u %u", spellId, (uint32)AISpellInfo[spellId].target); + switch (AISpellInfo[spellId].target) { default: - case AITARGET_SELF: target = me; break; - case AITARGET_VICTIM: target = me->getVictim(); break; + case AITARGET_SELF: + target = me; + break; + case AITARGET_VICTIM: + target = me->getVictim(); + break; case AITARGET_ENEMY: { - const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); - bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; - //float range = GetSpellMaxRange(spellInfo, false); - target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly); + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) + { + bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; + target = SelectTarget(SELECT_TARGET_RANDOM, 0, spellInfo->GetMaxRange(false), playerOnly); + } break; } - case AITARGET_ALLY: target = me; break; - case AITARGET_BUFF: target = me; break; + case AITARGET_ALLY: + target = me; + break; + case AITARGET_BUFF: + target = me; + break; case AITARGET_DEBUFF: { - const SpellInfo* spellInfo = sSpellMgr->GetSpellInfo(spellId); - bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; - float range = spellInfo->GetMaxRange(false); - - DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId); - if (!(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM) - && targetSelector(me->getVictim())) - target = me->getVictim(); - else - target = SelectTarget(SELECT_TARGET_RANDOM, 0, targetSelector); + if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId)) + { + bool playerOnly = spellInfo->AttributesEx3 & SPELL_ATTR3_ONLY_TARGET_PLAYERS; + float range = spellInfo->GetMaxRange(false); + + DefaultTargetSelector targetSelector(me, range, playerOnly, -(int32)spellId); + if (!(spellInfo->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_VICTIM) + && targetSelector(me->getVictim())) + target = me->getVictim(); + else + target = SelectTarget(SELECT_TARGET_RANDOM, 0, targetSelector); + } break; } } |
