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

@@ -7060,9 +7060,14 @@ void Player::UpdateArea(uint32 newArea)
m_areaUpdateId = newArea;
AreaTableEntry const* area = sAreaTableStore.LookupEntry(newArea);
bool oldFFAPvPArea = pvpInfo.IsInFFAPvPArea;
pvpInfo.IsInFFAPvPArea = area && (area->flags & AREA_FLAG_ARENA);
UpdatePvPState(true);
// check if we were in ffa arena and we left
if (oldFFAPvPArea && !pvpInfo.IsInFFAPvPArea)
ValidateAttackersAndOwnTarget();
UpdateAreaDependentAuras(newArea);
// previously this was in UpdateZone (but after UpdateArea) so nothing will break

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))

View File

@@ -1264,6 +1264,7 @@ class TC_GAME_API Unit : public WorldObject
public:
typedef std::set<Unit*> AttackerSet;
typedef std::set<Unit*> ControlList;
typedef std::vector<Unit*> UnitVector;
typedef std::multimap<uint32, Aura*> AuraMap;
typedef std::pair<AuraMap::const_iterator, AuraMap::const_iterator> AuraMapBounds;
@@ -1340,6 +1341,7 @@ class TC_GAME_API Unit : public WorldObject
return m_attacking;
}
void ValidateAttackersAndOwnTarget();
void CombatStop(bool includingCast = false);
void CombatStopWithPets(bool includingCast = false);
void StopAttackFaction(uint32 faction_id);