Core/Auras: Fix a crash in Unit::RemoveAurasDueToSpellBySteal

This commit is contained in:
QAston
2011-05-31 15:30:41 +02:00
parent 5254f3490b
commit f3428cbad4
+15 -17
View File
@@ -3797,30 +3797,28 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
newAura->SetCharges(maxCharges < newCharges ? maxCharges : newCharges); newAura->SetCharges(maxCharges < newCharges ? maxCharges : newCharges);
} }
else else
{ newAura->ModStackAmount(1);
uint8 newStacks = newAura->GetStackAmount() + 1;
uint8 maxStacks = newAura->GetSpellProto()->StackAmount;
newAura->SetStackAmount(maxStacks < newStacks ? maxStacks : newStacks);
}
newAura->SetDuration(dur); newAura->SetDuration(dur);
} }
else else
{ {
bool isSingleTarget = aura->IsSingleTarget() && caster; // single target state must be removed before aura creation to preserve existing single target aura
if (isSingleTarget) if (aura->IsSingleTarget())
aura->UnregisterSingleTarget(); aura->UnregisterSingleTarget();
newAura = Aura::TryCreate(aura->GetSpellProto(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID());
// strange but intended behaviour: Stolen single target auras won't be treated as single targeted if (newAura = Aura::TryCreate(aura->GetSpellProto(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID()))
if (newAura && isSingleTarget)
{ {
aura->SetIsSingleTarget(true); // created aura must not be single target aura,, so stealer won't loose it on recast
caster->GetSingleCastAuras().push_back(aura); if (newAura->IsSingleTarget())
newAura->UnregisterSingleTarget(); {
newAura->UnregisterSingleTarget();
// bring back single target aura status to the old aura
aura->SetIsSingleTarget(true);
caster->GetSingleCastAuras().push_back(aura);
}
newAura->SetLoadedState(dur, dur, stealCharge ? 1 : aura->GetCharges(), 1, recalculateMask, &damage[0]);
newAura->ApplyForTargets();
} }
if (!newAura)
return;
newAura->SetLoadedState(dur, dur, stealCharge ? 1 : aura->GetCharges(), 1, recalculateMask, &damage[0]);
newAura->ApplyForTargets();
} }
if (stealCharge) if (stealCharge)