Merge branch '4.3.4_phases' of https://github.com/TrinityCore/TrinityCore into 4.3.4

This commit is contained in:
Kinzcool committed 2014-06-18 23:25:57 -04:00
commit 34572492dd
63 files changed
+623 -1039

No files matched your search

+42 -49
View File
@@ -435,7 +435,7 @@ float Unit::GetMeleeReach() const
bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const
{
if (!obj || !IsInMap(obj) || !InSamePhase(obj))
if (!obj || !IsInMap(obj) || !IsInPhase(obj))
return false;
float dx = GetPositionX() - obj->GetPositionX();
@@ -451,7 +451,7 @@ bool Unit::IsWithinCombatRange(const Unit* obj, float dist2compare) const
bool Unit::IsWithinMeleeRange(const Unit* obj, float dist) const
{
if (!obj || !IsInMap(obj) || !InSamePhase(obj))
if (!obj || !IsInMap(obj) || !IsInPhase(obj))
return false;
float dx = GetPositionX() - obj->GetPositionX();
@@ -3643,7 +3643,7 @@ void Unit::RemoveAurasWithAttribute(uint32 flags)
}
}
void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase)
void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase, bool phaseid)
{
// single target auras from other casters
for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
@@ -3653,12 +3653,12 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase)
if (aura->GetCasterGUID() != GetGUID() && aura->GetSpellInfo()->IsSingleTarget())
{
if (!newPhase)
if (!newPhase && !phaseid)
RemoveAura(iter);
else
{
Unit* caster = aura->GetCaster();
if (!caster || !caster->InSamePhase(newPhase))
if (!caster || (newPhase && !caster->InSamePhase(newPhase)) || (!newPhase && !caster->IsInPhase(this)))
RemoveAura(iter);
else
++iter;
@@ -14656,61 +14656,54 @@ float Unit::MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, u
return missChance;
}
void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
void Unit::SetInPhase(uint32 id, bool update, bool apply)
{
if (newPhaseMask == GetPhaseMask())
return;
if (IsInWorld())
{
RemoveNotOwnSingleTargetAuras(newPhaseMask); // we can lost access to caster or target
// modify hostile references for new phasemask, some special cases deal with hostile references themselves
if (GetTypeId() == TYPEID_UNIT || (!ToPlayer()->IsGameMaster() && !ToPlayer()->GetSession()->PlayerLogout()))
{
HostileRefManager& refManager = getHostileRefManager();
HostileReference* ref = refManager.getFirst();
while (ref)
{
if (Unit* unit = ref->GetSource()->GetOwner())
if (Creature* creature = unit->ToCreature())
refManager.setOnlineOfflineState(creature, creature->InSamePhase(newPhaseMask));
ref = ref->next();
}
// modify threat lists for new phasemask
if (GetTypeId() != TYPEID_PLAYER)
{
std::list<HostileReference*> threatList = getThreatManager().getThreatList();
std::list<HostileReference*> offlineThreatList = getThreatManager().getOfflineThreatList();
// merge expects sorted lists
threatList.sort();
offlineThreatList.sort();
threatList.merge(offlineThreatList);
for (std::list<HostileReference*>::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
if (Unit* unit = (*itr)->getTarget())
unit->getHostileRefManager().setOnlineOfflineState(ToCreature(), unit->InSamePhase(newPhaseMask));
}
}
}
WorldObject::SetPhaseMask(newPhaseMask, update);
WorldObject::SetInPhase(id, update, apply);
if (!IsInWorld())
return;
RemoveNotOwnSingleTargetAuras(0, true);
if (GetTypeId() == TYPEID_UNIT || (!ToPlayer()->IsGameMaster() && !ToPlayer()->GetSession()->PlayerLogout()))
{
HostileRefManager& refManager = getHostileRefManager();
HostileReference* ref = refManager.getFirst();
while (ref)
{
if (Unit* unit = ref->GetSource()->GetOwner())
if (Creature* creature = unit->ToCreature())
refManager.setOnlineOfflineState(creature, creature->IsInPhase(this));
ref = ref->next();
}
// modify threat lists for new phasemask
if (GetTypeId() != TYPEID_PLAYER)
{
std::list<HostileReference*> threatList = getThreatManager().getThreatList();
std::list<HostileReference*> offlineThreatList = getThreatManager().getOfflineThreatList();
// merge expects sorted lists
threatList.sort();
offlineThreatList.sort();
threatList.merge(offlineThreatList);
for (std::list<HostileReference*>::const_iterator itr = threatList.begin(); itr != threatList.end(); ++itr)
if (Unit* unit = (*itr)->getTarget())
unit->getHostileRefManager().setOnlineOfflineState(ToCreature(), unit->IsInPhase(this));
}
}
for (ControlList::const_iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
if ((*itr)->GetTypeId() == TYPEID_UNIT)
(*itr)->SetPhaseMask(newPhaseMask, true);
(*itr)->SetInPhase(id, true, apply);
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
if (m_SummonSlot[i])
if (Creature* summon = GetMap()->GetCreature(m_SummonSlot[i]))
summon->SetPhaseMask(newPhaseMask, true);
summon->SetInPhase(id, true, apply);
}
void Unit::UpdateObjectVisibility(bool forced)