Core/Entities: Phase Rework (main commit)

This commit is contained in:
Ovahlord committed 2018-03-08 22:58:50 +01:00
1 parent 4a268b3fd3
commit e44bb5f387
79 files changed
+1738 -851

No files matched your search

+10 -33
View File
@@ -46,6 +46,7 @@
#include "PassiveAI.h"
#include "PetAI.h"
#include "Pet.h"
#include "PhasingHandler.h"
#include "Player.h"
#include "PlayerAI.h"
#include "QuestDef.h"
@@ -3886,7 +3887,7 @@ void Unit::RemoveAurasWithAttribute(uint32 flags)
}
}
void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase, bool phaseid)
void Unit::RemoveNotOwnSingleTargetAuras(bool onPhaseChange /*= false*/)
{
// single target auras from other casters
// Iterate m_ownedAuras - aura is marked as single target in Unit::AddAura (and pushed to m_ownedAuras).
@@ -3903,12 +3904,12 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase, bool phaseid)
if (aura->GetCasterGUID() != GetGUID() && aura->IsSingleTarget())
{
if (!newPhase && !phaseid)
if (!onPhaseChange)
RemoveOwnedAura(iter);
else
{
Unit* caster = aura->GetCaster();
if (!caster || (newPhase && !caster->IsInPhase(newPhase)) || (!newPhase && !caster->IsInPhase(this)))
if (!caster || !caster->IsInPhase(this))
RemoveOwnedAura(iter);
else
++iter;
@@ -3923,7 +3924,7 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase, bool phaseid)
for (AuraList::iterator iter = scAuras.begin(); iter != scAuras.end();)
{
Aura* aura = *iter;
if (aura->GetUnitOwner() != this && !aura->GetUnitOwner()->IsInPhase(newPhase))
if (aura->GetUnitOwner() != this && !aura->GetUnitOwner()->IsInPhase(this))
{
aura->Remove();
iter = scAuras.begin();
@@ -10015,15 +10016,6 @@ int32 Unit::GetCreatePowers(Powers power) const
return 0;
}
void Unit::AddToWorld()
{
if (!IsInWorld())
{
WorldObject::AddToWorld();
}
RebuildTerrainSwaps();
}
void Unit::RemoveFromWorld()
{
// cleanup
@@ -11343,7 +11335,7 @@ bool Unit::InitTamedPet(Pet* pet, uint8 level, uint32 spell_id)
return false;
}
pet->CopyPhaseFrom(this);
PhasingHandler::InheritPhaseShift(pet, this);
pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
@@ -12444,14 +12436,12 @@ float Unit::MeleeSpellMissChance(const Unit* victim, WeaponAttackType attType, u
return missChance;
}
bool Unit::SetInPhase(uint32 id, bool update, bool apply)
void Unit::OnPhaseChange()
{
bool res = WorldObject::SetInPhase(id, update, apply);
if (!IsInWorld())
return res;
return;
if (GetTypeId() == TYPEID_UNIT || (!ToPlayer()->IsGameMaster() && !ToPlayer()->GetSession()->PlayerLogout()))
if (GetTypeId() == TYPEID_UNIT || !ToPlayer()->GetSession()->PlayerLogout())
{
HostileRefManager& refManager = getHostileRefManager();
HostileReference* ref = refManager.getFirst();
@@ -12481,19 +12471,6 @@ bool Unit::SetInPhase(uint32 id, bool update, bool apply)
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);
RemoveNotOwnSingleTargetAuras(0, true);
return res;
}
void Unit::UpdateObjectVisibility(bool forced)
@@ -13274,7 +13251,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
Movement::MoveSplineInit init(this);
// Creatures without inhabit type air should begin falling after exiting the vehicle
if (GetTypeId() == TYPEID_UNIT && !CanFly() && height > GetMap()->GetWaterOrGroundLevel(GetPhases(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), &height) + 0.1f)
if (GetTypeId() == TYPEID_UNIT && !CanFly() && height > GetMap()->GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), &height) + 0.1f)
init.SetFall();
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);