aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Entities')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp7
-rw-r--r--src/server/game/Entities/Creature/Creature.h4
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp17
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h6
-rw-r--r--src/server/game/Entities/Object/Object.cpp47
-rw-r--r--src/server/game/Entities/Object/Object.h5
-rw-r--r--src/server/game/Entities/Pet/Pet.cpp3
-rw-r--r--src/server/game/Entities/Player/Player.cpp58
-rw-r--r--src/server/game/Entities/Player/Player.h8
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp10
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp60
-rw-r--r--src/server/game/Entities/Unit/Unit.h3
12 files changed, 175 insertions, 53 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 517464fef4a..51d2646b1c3 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -739,6 +739,13 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry,
ASSERT(map);
SetMap(map);
SetPhaseMask(phaseMask, false);
+
+ if (data && data->phaseid)
+ SetInPhase(data->phaseid, false, true);
+
+ if (data && data->phaseGroup)
+ for (auto ph : GetPhasesForGroup(data->phaseGroup))
+ SetInPhase(ph, false, true);
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cinfo)
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 8a22ce61f0d..574c10d14f4 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -254,7 +254,7 @@ struct CreatureData
CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0),
posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
spawndist(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0),
- spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), dbData(true) { }
+ spawnMask(0), npcflag(0), unit_flags(0), dynamicflags(0), phaseid(0), phaseGroup(0), dbData(true) { }
uint32 id; // entry in creature_template
uint16 mapid;
uint32 phaseMask;
@@ -274,6 +274,8 @@ struct CreatureData
uint32 npcflag;
uint32 unit_flags; // enum UnitFlags mask values
uint32 dynamicflags;
+ uint32 phaseid;
+ uint32 phaseGroup;
bool dbData;
};
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index d6a029d29bf..736c39461cd 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -813,6 +813,16 @@ bool GameObject::LoadGameObjectFromDB(uint32 guid, Map* map, bool addToMap)
if (!Create(guid, entry, map, phaseMask, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, artKit))
return false;
+ if (data->phaseid)
+ SetInPhase(data->phaseid, false, true);
+
+ if (data->phaseGroup)
+ {
+ // Set the gameobject in all the phases of the phasegroup
+ for (auto ph : GetPhasesForGroup(data->phaseGroup))
+ SetInPhase(ph, false, true);
+ }
+
if (data->spawntimesecs >= 0)
{
m_spawnedByDefault = true;
@@ -2053,6 +2063,13 @@ void GameObject::SetDisplayId(uint32 displayid)
UpdateModel();
}
+void GameObject::SetInPhase(uint32 id, bool update, bool apply)
+{
+ WorldObject::SetInPhase(id, update, apply);
+ if (m_model && m_model->isEnabled())
+ EnableCollision(true);
+}
+
void GameObject::SetPhaseMask(uint32 newPhaseMask, bool update)
{
WorldObject::SetPhaseMask(newPhaseMask, update);
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 640d5718186..2b24f29fe69 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -592,7 +592,7 @@ struct GameObjectData
{
explicit GameObjectData() : id(0), mapid(0), phaseMask(0), posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f),
rotation0(0.0f), rotation1(0.0f), rotation2(0.0f), rotation3(0.0f), spawntimesecs(0),
- animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), dbData(true) { }
+ animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), phaseid(0), phaseGroup(0), dbData(true) { }
uint32 id; // entry in gamobject_template
uint16 mapid;
uint32 phaseMask;
@@ -609,6 +609,8 @@ struct GameObjectData
GOState go_state;
uint8 spawnMask;
uint8 artKit;
+ uint32 phaseid;
+ uint32 phaseGroup;
bool dbData;
};
@@ -725,6 +727,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
static void SetGoArtKit(uint8 artkit, GameObject* go, uint32 lowguid = 0);
void SetPhaseMask(uint32 newPhaseMask, bool update);
+ void SetInPhase(uint32 id, bool update, bool apply);
void EnableCollision(bool enable);
void Use(Unit* user);
@@ -876,6 +879,7 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
//! Following check does check 3d distance
return IsInRange(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), dist2compare);
}
+
GameObjectAI* m_AI;
};
#endif
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index a2fd19c443c..24e4a7b82ce 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1493,7 +1493,7 @@ bool WorldObject::IsWithinDist(WorldObject const* obj, float dist2compare, bool
bool WorldObject::IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D /*= true*/) const
{
- return obj && IsInMap(obj) && InSamePhase(obj) && _IsWithinDist(obj, dist2compare, is3D);
+ return obj && IsInMap(obj) && IsInPhase(obj) && _IsWithinDist(obj, dist2compare, is3D);
}
bool WorldObject::IsWithinLOS(float ox, float oy, float oz) const
@@ -1932,7 +1932,7 @@ bool WorldObject::CanSeeOrDetect(WorldObject const* obj, bool ignoreStealth, boo
bool WorldObject::CanNeverSee(WorldObject const* obj) const
{
- return GetMap() != obj->GetMap() || !InSamePhase(obj);
+ return GetMap() != obj->GetMap() || !IsInPhase(obj);
}
bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth) const
@@ -2330,8 +2330,12 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
}
uint32 phase = PHASEMASK_NORMAL;
+ std::set<uint32> phases;
if (summoner)
+ {
phase = summoner->GetPhaseMask();
+ phases = summoner->GetPhases();
+ }
TempSummon* summon = NULL;
switch (mask)
@@ -2359,6 +2363,10 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
return NULL;
}
+ // Set the summon to the summoner's phase
+ for (auto phaseId : phases)
+ summon->SetInPhase(phaseId, false, true);
+
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
summon->SetHomePosition(pos);
@@ -2453,6 +2461,9 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float
return NULL;
}
+ for (auto phase : GetPhases())
+ go->SetInPhase(phase, false, true);
+
go->SetRespawnTime(respawnTime);
if (GetTypeId() == TYPEID_PLAYER || GetTypeId() == TYPEID_UNIT) //not sure how to handle this
ToUnit()->AddGameObject(go);
@@ -2835,9 +2846,39 @@ void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
UpdateObjectVisibility();
}
+void WorldObject::SetInPhase(uint32 id, bool update, bool apply)
+{
+ if (apply)
+ _phases.insert(id);
+ else
+ _phases.erase(id);
+
+ if (update && IsInWorld())
+ UpdateObjectVisibility();
+}
+
+bool WorldObject::IsInPhase(WorldObject const* obj) const
+{
+ // PhaseId 169 is the default fallback phase
+ if (_phases.empty() && obj->GetPhases().empty())
+ return true;
+
+ if (_phases.empty() && obj->IsInPhase(169))
+ return true;
+
+ if (obj->GetPhases().empty() && IsInPhase(169))
+ return true;
+
+ for (auto phase : _phases)
+ if (obj->IsInPhase(phase))
+ return true;
+ return false;
+}
+
bool WorldObject::InSamePhase(WorldObject const* obj) const
{
- return InSamePhase(obj->GetPhaseMask());
+ return IsInPhase(obj);
+ // return InSamePhase(obj->GetPhaseMask());
}
void WorldObject::PlayDistanceSound(uint32 sound_id, Player* target /*= NULL*/)
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 5e525f1e0d5..2d7a6f12016 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -676,9 +676,13 @@ class WorldObject : public Object, public WorldLocation
uint32 GetInstanceId() const { return m_InstanceId; }
virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
+ virtual void SetInPhase(uint32 id, bool update, bool apply);
uint32 GetPhaseMask() const { return m_phaseMask; }
bool InSamePhase(WorldObject const* obj) const;
bool InSamePhase(uint32 phasemask) const { return (GetPhaseMask() & phasemask); }
+ bool IsInPhase(uint32 phase) const { return _phases.find(phase) != _phases.end(); }
+ bool IsInPhase(WorldObject const* obj) const;
+ std::set<uint32> const& GetPhases() const { return _phases; }
uint32 GetZoneId() const;
uint32 GetAreaId() const;
@@ -861,6 +865,7 @@ class WorldObject : public Object, public WorldLocation
//uint32 m_mapId; // object at map with map_id
uint32 m_InstanceId; // in map copy with instance id
uint32 m_phaseMask; // in area phase state
+ std::set<uint32> _phases;
uint16 m_notifyflags;
uint16 m_executed_notifies;
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index 7f4bead4656..4a2e9968c1a 100644
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -179,6 +179,9 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
if (!Create(guid, map, owner->GetPhaseMask(), petEntry, petId))
return false;
+ for (auto itr : owner->GetPhases())
+ SetInPhase(itr, false, true);
+
setPetType(petType);
setFaction(owner->getFaction());
SetUInt32Value(UNIT_CREATED_BY_SPELL, summonSpellId);
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index f5c6d12a341..672596705d5 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -668,7 +668,7 @@ void KillRewarder::Reward()
}
-Player::Player(WorldSession* session): Unit(true), phaseMgr(this)
+Player::Player(WorldSession* session): Unit(true)
{
m_speakTime = 0;
m_speakCount = 0;
@@ -2921,9 +2921,6 @@ void Player::SetGameMaster(bool on)
getHostileRefManager().setOnlineOfflineState(true);
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GM, SEC_PLAYER);
-
- phaseMgr.AddUpdateFlag(PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED);
- phaseMgr.Update();
}
UpdateObjectVisibility();
@@ -3164,11 +3161,6 @@ void Player::GiveLevel(uint8 level)
UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_LEVEL);
- PhaseUpdateData phaseUpdateData;
- phaseUpdateData.AddConditionType(CONDITION_LEVEL);
-
- phaseMgr.NotifyConditionChanged(phaseUpdateData);
-
// Refer-A-Friend
if (GetSession()->GetRecruiterId())
if (level < sWorld->getIntConfig(CONFIG_MAX_RECRUIT_A_FRIEND_BONUS_PLAYER_LEVEL))
@@ -7785,8 +7777,6 @@ void Player::UpdateArea(uint32 newArea)
// so apply them accordingly
m_areaUpdateId = newArea;
- phaseMgr.AddUpdateFlag(PHASE_UPDATE_FLAG_AREA_UPDATE);
-
AreaTableEntry const* area = GetAreaEntryByAreaID(newArea);
pvpInfo.IsInFFAPvPArea = area && (area->flags & AREA_FLAG_ARENA);
UpdatePvPState(true);
@@ -7816,14 +7806,10 @@ void Player::UpdateArea(uint32 newArea)
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_RESTING);
SetRestType(REST_TYPE_NO);
}
-
- phaseMgr.RemoveUpdateFlag(PHASE_UPDATE_FLAG_AREA_UPDATE);
}
void Player::UpdateZone(uint32 newZone, uint32 newArea)
{
- phaseMgr.AddUpdateFlag(PHASE_UPDATE_FLAG_ZONE_UPDATE);
-
if (m_zoneUpdateId != newZone)
{
sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
@@ -7928,8 +7914,6 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
UpdateLocalChannels(newZone);
UpdateZoneDependentAuras(newZone);
-
- phaseMgr.RemoveUpdateFlag(PHASE_UPDATE_FLAG_ZONE_UPDATE);
}
//If players are too far away from the duel flag... they lose the duel
@@ -15476,10 +15460,6 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
m_RewardedQuests.insert(quest_id);
m_RewardedQuestsSave[quest_id] = true;
- PhaseUpdateData phaseUpdateData;
- phaseUpdateData.AddQuestUpdate(quest_id);
- phaseMgr.NotifyConditionChanged(phaseUpdateData);
-
// StoreNewItem, mail reward, etc. save data directly to the database
// to prevent exploitable data desynchronisation we save the quest status to the database too
// (to prevent rewarding this quest another time while rewards were already given out)
@@ -16129,11 +16109,6 @@ void Player::SetQuestStatus(uint32 questId, QuestStatus status, bool update /*=
m_QuestStatusSave[questId] = true;
}
- PhaseUpdateData phaseUpdateData;
- phaseUpdateData.AddQuestUpdate(questId);
-
- phaseMgr.NotifyConditionChanged(phaseUpdateData);
-
if (update)
SendQuestUpdate(questId);
}
@@ -16145,11 +16120,6 @@ void Player::RemoveActiveQuest(uint32 questId, bool update /*= true*/)
{
m_QuestStatus.erase(itr);
m_QuestStatusSave[questId] = false;
-
- PhaseUpdateData phaseUpdateData;
- phaseUpdateData.AddQuestUpdate(questId);
-
- phaseMgr.NotifyConditionChanged(phaseUpdateData);
}
if (update)
@@ -16163,11 +16133,6 @@ void Player::RemoveRewardedQuest(uint32 questId, bool update /*= true*/)
{
m_RewardedQuests.erase(rewItr);
m_RewardedQuestsSave[questId] = false;
-
- PhaseUpdateData phaseUpdateData;
- phaseUpdateData.AddQuestUpdate(questId);
-
- phaseMgr.NotifyConditionChanged(phaseUpdateData);
}
if (update)
@@ -27532,6 +27497,9 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
return NULL;
}
+ for (auto itr : GetPhases())
+ pet->SetInPhase(itr, false, true);
+
pet->SetCreatorGUID(GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, getFaction());
@@ -27899,3 +27867,21 @@ void Player::ReadMovementInfo(WorldPacket& data, MovementInfo* mi, Movement::Ext
#undef REMOVE_VIOLATING_FLAGS
}
+
+void Player::UpdatePhasing()
+{
+ std::set<uint32> phaseIds;
+ std::set<uint32> terrainswaps;
+ std::set<uint32> worldAreaSwaps;
+
+ for (auto phase : GetPhases())
+ {
+ PhaseInfo const* info = sObjectMgr->GetPhaseInfo(phase);
+ if (!info)
+ continue;
+ terrainswaps.insert(info->terrainSwapMap);
+ worldAreaSwaps.insert(info->worldMapAreaSwap);
+ }
+
+ GetSession()->SendSetPhaseShift(GetPhases(), terrainswaps, worldAreaSwaps);
+} \ No newline at end of file
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index dccbc550a1e..d318efc3117 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -25,7 +25,6 @@
#include "Item.h"
#include "PetDefines.h"
-#include "PhaseMgr.h"
#include "QuestDef.h"
#include "SpellMgr.h"
#include "Unit.h"
@@ -56,7 +55,6 @@ class PlayerMenu;
class PlayerSocial;
class SpellCastTargets;
class UpdateMask;
-class PhaseMgr;
typedef std::deque<Mail*> PlayerMails;
@@ -1333,8 +1331,6 @@ class Player : public Unit, public GridObject<Player>
Pet* SummonPet(uint32 entry, float x, float y, float z, float ang, PetType petType, uint32 despwtime);
void RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent = false);
- PhaseMgr& GetPhaseMgr() { return phaseMgr; }
-
/// Handles said message in regular chat based on declared language and in config pre-defined Range.
void Say(std::string const& text, const uint32 language);
/// Handles yelled message in regular chat based on declared language and in config pre-defined Range.
@@ -2361,6 +2357,8 @@ class Player : public Unit, public GridObject<Player>
void UpdateVisibilityOf(WorldObject* target);
void UpdateTriggerVisibility();
+ void UpdatePhasing();
+
template<class T>
void UpdateVisibilityOf(T* target, UpdateData& data, std::set<Unit*>& visibleNow);
@@ -2885,8 +2883,6 @@ class Player : public Unit, public GridObject<Player>
uint32 _activeCheats;
uint32 _maxPersonalArenaRate;
-
- PhaseMgr phaseMgr;
};
void AddItemsSetItem(Player*player, Item* item);
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 5f0ae6ecdea..05b7c25ecde 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -388,8 +388,15 @@ TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSu
}
uint32 phase = PHASEMASK_NORMAL;
+ std::set<uint32> phases;
if (summoner)
+ {
phase = summoner->GetPhaseMask();
+ phases = summoner->GetPhases();
+ }
+
+ if (phases.empty())
+ phases = GetPhases(); // If there was no summoner, try to use the transport phases
TempSummon* summon = NULL;
switch (mask)
@@ -421,6 +428,9 @@ TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSu
return NULL;
}
+ for (auto itr : phases)
+ summon->SetInPhase(itr, false, true);
+
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
summon->SetTransport(this);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 038db352edd..29c32b7e36c 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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())
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 21c55ffe700..9c03809b428 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1762,7 +1762,7 @@ class Unit : public WorldObject
void RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit* stealer);
void RemoveAurasDueToItemSpell(uint32 spellId, uint64 castItemGuid);
void RemoveAurasByType(AuraType auraType, uint64 casterGUID = 0, Aura* except = NULL, bool negative = true, bool positive = true);
- void RemoveNotOwnSingleTargetAuras(uint32 newPhase = 0x0);
+ void RemoveNotOwnSingleTargetAuras(uint32 newPhase = 0x0, bool phaseid = false);
void RemoveAurasWithInterruptFlags(uint32 flag, uint32 except = 0);
void RemoveAurasWithAttribute(uint32 flags);
void RemoveAurasWithFamily(SpellFamilyNames family, uint32 familyFlag1, uint32 familyFlag2, uint32 familyFlag3, uint64 casterGUID);
@@ -1929,6 +1929,7 @@ class Unit : public WorldObject
// common function for visibility checks for player/creatures with detection code
void SetPhaseMask(uint32 newPhaseMask, bool update);// overwrite WorldObject::SetPhaseMask
+ void SetInPhase(uint32 id, bool update, bool apply);
void UpdateObjectVisibility(bool forced = true);
SpellImmuneList m_spellImmune[MAX_SPELL_IMMUNITY];