mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Core/Spells: merged commit 2d10429a2d in order to fix some crashes
This commit is contained in:
@@ -2331,66 +2331,68 @@ void UnitAura::Remove(AuraRemoveMode removeMode)
|
||||
|
||||
void UnitAura::FillTargetMap(std::unordered_map<Unit*, uint8>& 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<Unit*> units;
|
||||
std::vector<Unit*> 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<Trinity::AnyGroupedUnitInObjectRangeCheck> 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<Trinity::AnyFriendlyUnitInObjectRangeCheck> 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<Trinity::AnyAoETargetUnitInObjectRangeCheck> 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<Trinity::WorldObjectSpellAreaTargetCheck> searcher(GetUnitOwner(), units, check);
|
||||
Cell::VisitAllObjects(GetUnitOwner(), searcher, radius);
|
||||
}
|
||||
}
|
||||
|
||||
for (Unit* unit : units)
|
||||
|
||||
Reference in New Issue
Block a user