Properly stop attacking after player leaves ffa area (like Gurubashi Arena) (#18952)

This commit is contained in:
xinef1
2017-02-20 19:03:11 +01:00
committed by ariel-
parent 6d991e9361
commit 4eae29d421
3 changed files with 25 additions and 0 deletions

View File

@@ -5874,6 +5874,24 @@ bool Unit::AttackStop()
return true;
}
void Unit::ValidateAttackersAndOwnTarget()
{
// iterate attackers
UnitVector toRemove;
AttackerSet const& attackers = getAttackers();
for (Unit* attacker : attackers)
if (!attacker->IsValidAttackTarget(this))
toRemove.push_back(attacker);
for (Unit* attacker : toRemove)
attacker->AttackStop();
// remove our own victim
if (Unit* victim = GetVictim())
if (!IsValidAttackTarget(victim))
AttackStop();
}
void Unit::CombatStop(bool includingCast)
{
if (includingCast && IsNonMeleeSpellCast(false))