Core/Phases: Preliminary work with correctly implementing the phase system in 4.3.4
Put here for peer review.
This commit is contained in:
1 parent
6bc62d730e
commit
48ec2df81f
40 files changed
+436
-863
No files matched your search
@@ -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();
|
||||
@@ -3623,7 +3623,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();)
|
||||
@@ -3633,12 +3633,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;
|
||||
@@ -14526,6 +14526,56 @@ float Unit::MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, u
|
||||
return missChance;
|
||||
}
|
||||
|
||||
void Unit::SetInPhase(uint32 id, bool update, bool apply)
|
||||
{
|
||||
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)->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->SetInPhase(id, true, apply);
|
||||
}
|
||||
|
||||
void Unit::SetPhaseMask(uint32 newPhaseMask, bool update)
|
||||
{
|
||||
if (newPhaseMask == GetPhaseMask())
|
||||
|
||||
Reference in new issue
Block a user