From fdd6bbc1cf0e1bf86d594b8b288d6da102f49278 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Mon, 28 May 2018 11:54:20 +0200 Subject: [PATCH] Core/Spells: merged commit 2d10429a2d788d6b3aead19bd91ed662bad38751 in order to fix some crashes --- src/server/game/Spells/Auras/SpellAuras.cpp | 84 +++++++++++---------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index da38bd6150f..1377eafa4ff 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -2331,66 +2331,68 @@ void UnitAura::Remove(AuraRemoveMode removeMode) void UnitAura::FillTargetMap(std::unordered_map& targets, Unit* caster) { + Unit* ref = caster; + if (!ref) + ref = GetUnitOwner(); + for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex) { if (!HasEffect(effIndex)) continue; - std::deque units; + std::vector units; + ConditionContainer* condList = m_spellInfo->Effects[effIndex].ImplicitTargetConditions; // non-area aura if (GetSpellInfo()->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AURA) - units.push_back(GetUnitOwner()); + { + if (!condList || sConditionMgr->IsObjectMeetToConditions(GetUnitOwner(), ref, *condList)) + units.push_back(GetUnitOwner()); + } else { - ASSERT(caster, "Area aura (Id: %u) has nullptr caster (%s)", m_spellInfo->Id, GetCasterGUID().ToString().c_str()); - ASSERT(GetCasterGUID() == GetUnitOwner()->GetGUID(), "Area aura (Id: %u) has owner (%s) different to caster (%s)", m_spellInfo->Id, GetUnitOwner()->GetGUID().ToString().c_str(), GetCasterGUID().ToString().c_str()); - // skip area update if owner is not in world! if (!GetUnitOwner()->IsInWorld()) continue; - float radius = GetSpellInfo()->Effects[effIndex].CalcRadius(caster); + if (GetUnitOwner()->HasUnitState(UNIT_STATE_ISOLATED)) + continue; - if (!GetUnitOwner()->HasUnitState(UNIT_STATE_ISOLATED)) + float radius = GetSpellInfo()->Effects[effIndex].CalcRadius(ref); + SpellTargetCheckTypes selectionType = TARGET_CHECK_DEFAULT; + switch (GetSpellInfo()->Effects[effIndex].Effect) { - switch (GetSpellInfo()->Effects[effIndex].Effect) + case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: + selectionType = TARGET_CHECK_PARTY; + break; + case SPELL_EFFECT_APPLY_AREA_AURA_RAID: + selectionType = TARGET_CHECK_RAID; + break; + case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: + selectionType = TARGET_CHECK_ALLY; + break; + case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: + selectionType = TARGET_CHECK_ENEMY; + break; + case SPELL_EFFECT_APPLY_AREA_AURA_PET: + if (!condList || sConditionMgr->IsObjectMeetToConditions(GetUnitOwner(), ref, *condList)) + units.push_back(GetUnitOwner()); + // no break + case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: { - case SPELL_EFFECT_APPLY_AREA_AURA_PARTY: - case SPELL_EFFECT_APPLY_AREA_AURA_RAID: - { - units.push_back(GetUnitOwner()); - Trinity::AnyGroupedUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, m_spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_APPLY_AREA_AURA_RAID, m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS)); - Trinity::UnitListSearcher searcher(GetUnitOwner(), units, u_check); - Cell::VisitAllObjects(GetUnitOwner(), searcher, radius); - break; - } - case SPELL_EFFECT_APPLY_AREA_AURA_FRIEND: - { - units.push_back(GetUnitOwner()); - Trinity::AnyFriendlyUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, m_spellInfo->HasAttribute(SPELL_ATTR3_ONLY_TARGET_PLAYERS)); - Trinity::UnitListSearcher searcher(GetUnitOwner(), units, u_check); - Cell::VisitAllObjects(GetUnitOwner(), searcher, radius); - break; - } - case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY: - { - Trinity::AnyAoETargetUnitInObjectRangeCheck u_check(GetUnitOwner(), GetUnitOwner(), radius, m_spellInfo); // No GetCharmer in searcher - Trinity::UnitListSearcher searcher(GetUnitOwner(), units, u_check); - Cell::VisitAllObjects(GetUnitOwner(), searcher, radius); - break; - } - case SPELL_EFFECT_APPLY_AREA_AURA_PET: - units.push_back(GetUnitOwner()); - // no break - case SPELL_EFFECT_APPLY_AREA_AURA_OWNER: - { - if (Unit* owner = GetUnitOwner()->GetCharmerOrOwner()) - if (GetUnitOwner()->IsWithinDistInMap(owner, radius)) + if (Unit* owner = GetUnitOwner()->GetCharmerOrOwner()) + if (GetUnitOwner()->IsWithinDistInMap(owner, radius)) + if (!condList || sConditionMgr->IsObjectMeetToConditions(owner, ref, *condList)) units.push_back(owner); - break; - } + break; } } + + if (selectionType != TARGET_CHECK_DEFAULT) + { + Trinity::WorldObjectSpellAreaTargetCheck check(radius, GetUnitOwner(), ref, GetUnitOwner(), m_spellInfo, selectionType, condList); + Trinity::UnitListSearcher searcher(GetUnitOwner(), units, check); + Cell::VisitAllObjects(GetUnitOwner(), searcher, radius); + } } for (Unit* unit : units)