Core/Auras: Fix aura positivity check after rev bb4bd46d21.

This commit is contained in:
QAston
2010-12-31 16:12:29 +01:00
parent dd5a77bebc
commit 1b18a0ac65
2 changed files with 28 additions and 15 deletions
+26 -13
View File
@@ -116,23 +116,36 @@ void AuraApplication::_InitFlags(Unit * caster, uint8 effMask)
// mark as selfcasted if needed
m_flags |= (GetBase()->GetCasterGUID() == GetTarget()->GetGUID()) ? AFLAG_CASTER : AFLAG_NONE;
// Aura is positive when it is casted by friend and at least one aura is positive
// or when it is casted by enemy and at least one aura is negative
bool needManyNegEffects = false;
if (IsSelfcasted())
needManyNegEffects = false;
else if (caster)
needManyNegEffects = caster->IsFriendlyTo(GetTarget());
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
// aura is casted by self or an enemy
// one negative effect and we know aura is negative
if (IsSelfcasted() || !caster || !caster->IsFriendlyTo(GetTarget()))
{
if ((1<<i) & effMask)
bool negativeFound = false;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (needManyNegEffects == IsPositiveEffect(GetBase()->GetId(), i))
m_flags |= needManyNegEffects ? AFLAG_POSITIVE : AFLAG_NEGATIVE;
if (((1<<i) & effMask) && !IsPositiveEffect(GetBase()->GetId(), i))
{
negativeFound = true;
break;
}
}
m_flags |= negativeFound ? AFLAG_NEGATIVE : AFLAG_POSITIVE;
}
// aura is casted by friend
// one positive effect and we know aura is positive
else
{
bool positiveFound = false;
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (((1<<i) & effMask) && IsPositiveEffect(GetBase()->GetId(), i))
{
positiveFound = true;
break;
}
}
m_flags |= positiveFound ? AFLAG_POSITIVE : AFLAG_NEGATIVE;
}
m_flags |= !needManyNegEffects ? AFLAG_POSITIVE : AFLAG_NEGATIVE;
}
void AuraApplication::_HandleEffect(uint8 effIndex, bool apply)