Skip to content

Instantly share code, notes, and snippets.

@Subv
Created June 1, 2014 03:40
Show Gist options
  • Select an option

  • Save Subv/6d6dda509c2480462aa6 to your computer and use it in GitHub Desktop.

Select an option

Save Subv/6d6dda509c2480462aa6 to your computer and use it in GitHub Desktop.
Implement visibility based on phaseids
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp
index a797f61..8fe286c 100644
--- a/src/server/game/Battlefield/Battlefield.cpp
+++ b/src/server/game/Battlefield/Battlefield.cpp
@@ -794,7 +794,7 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
}
Creature* creature = new Creature();
- if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, x, y, z, o))
+ if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, 0, entry, x, y, z, o))
{
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry);
delete creature;
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index dff9928..b28e44d 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -1662,7 +1662,7 @@ Creature* Battleground::AddCreature(uint32 entry, uint32 type, float x, float y,
return NULL;
Creature* creature = new Creature();
- if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, x, y, z, o))
+ if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, 0, entry, x, y, z, o))
{
TC_LOG_ERROR("bg.battleground", "Battleground::AddCreature: cannot create creature (entry: %u) for BG (map: %u, instance id: %u)!",
entry, m_MapId, m_InstanceID);
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index f3154d7..feb4739 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -2523,5 +2523,5 @@ typedef std::vector<TaxiPathNodeList> TaxiPathNodesByPath;
#define TaxiMaskSize 114
typedef uint8 TaxiMask[TaxiMaskSize];
-typedef std::unordered_map<uint32, std::set<uint32> const&> PhaseGroupContainer;
+typedef std::unordered_map<uint32, std::set<uint32>> PhaseGroupContainer;
#endif
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 517464f..25e2f63 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -734,11 +734,11 @@ void Creature::Motion_Initialize()
GetMotionMaster()->Initialize();
}
-bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/)
+bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseid, uint32 entry, float x, float y, float z, float ang, CreatureData const* data /*= nullptr*/, uint32 vehId /*= 0*/)
{
ASSERT(map);
SetMap(map);
- SetPhaseMask(phaseMask, false);
+ SetPhaseId(phaseid, false);
CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
if (!cinfo)
@@ -1213,7 +1213,7 @@ bool Creature::LoadCreatureFromDB(uint32 guid, Map* map, bool addToMap)
else
guid = sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT);
- if (!Create(guid, map, data->phaseMask, data->id, data->posX, data->posY, data->posZ, data->orientation, data))
+ if (!Create(guid, map, data->phaseMask, data->phaseid, data->id, data->posX, data->posY, data->posZ, data->orientation, data))
return false;
//We should set first home position, because then AI calls home movement
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 8a22ce6..f93d414 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -251,13 +251,14 @@ typedef std::unordered_map<uint32, EquipmentInfoContainerInternal> EquipmentInfo
// from `creature` table
struct CreatureData
{
- CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0),
+ CreatureData() : id(0), mapid(0), phaseMask(0), phaseid(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) { }
uint32 id; // entry in creature_template
uint16 mapid;
uint32 phaseMask;
+ uint32 phaseid;
uint32 displayid;
int8 equipmentId;
float posX;
@@ -439,7 +440,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
void DisappearAndDie();
- bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const* data = nullptr, uint32 vehId = 0);
+ bool Create(uint32 guidlow, Map* map, uint32 phaseid, uint32 entry, float x, float y, float z, float ang, CreatureData const* data = nullptr, uint32 vehId = 0);
bool LoadCreaturesAddon(bool reload = false);
void SelectLevel();
void LoadEquipment(int8 id = 1, bool force = false);
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index a2fd19c..81e7415 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1273,7 +1273,7 @@ void MovementInfo::OutDebug()
WorldObject::WorldObject(bool isWorldObject) : WorldLocation(), LastUsedScriptID(0),
m_name(""), m_isActive(false), m_isWorldObject(isWorldObject), m_zoneScript(NULL),
m_transport(NULL), m_currMap(NULL), m_InstanceId(0),
-m_phaseMask(PHASEMASK_NORMAL), m_notifyflags(0), m_executed_notifies(0)
+phaseId(0), m_notifyflags(0), m_executed_notifies(0)
{
m_serverSideVisibility.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE | GHOST_VISIBILITY_GHOST);
m_serverSideVisibilityDetect.SetValue(SERVERSIDE_VISIBILITY_GHOST, GHOST_VISIBILITY_ALIVE);
@@ -2353,7 +2353,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
break;
}
- if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
+ if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), this, phase, 0, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
{
delete summon;
return NULL;
@@ -2827,17 +2827,21 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
pos.SetOrientation(GetOrientation());
}
-void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
+void WorldObject::SetPhaseId(uint32 id, bool update)
{
- m_phaseMask = newPhaseMask;
-
+ phaseId = id;
if (update && IsInWorld())
UpdateObjectVisibility();
}
bool WorldObject::InSamePhase(WorldObject const* obj) const
{
- return InSamePhase(obj->GetPhaseMask());
+ if (Player* plr = const_cast<Player*>(ToPlayer()))
+ return plr->GetPhaseMgr().CanSee(obj);
+ if (Player* plr = const_cast<Player*>(obj->ToPlayer()))
+ return plr->GetPhaseMgr().CanSee(this);
+
+ return GetPhaseId() == obj->GetPhaseId();
}
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 5e525f1..ed1e6e2 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -675,10 +675,9 @@ class WorldObject : public Object, public WorldLocation
uint32 GetInstanceId() const { return m_InstanceId; }
- virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
- uint32 GetPhaseMask() const { return m_phaseMask; }
+ virtual void SetPhaseId(uint32 newId, bool update);
+ uint32 GetPhaseId() const { return phaseId; }
bool InSamePhase(WorldObject const* obj) const;
- bool InSamePhase(uint32 phasemask) const { return (GetPhaseMask() & phasemask); }
uint32 GetZoneId() const;
uint32 GetAreaId() const;
@@ -860,7 +859,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
+ uint32 phaseId; // Only used for creatures and gameobjects
uint16 m_notifyflags;
uint16 m_executed_notifies;
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 5f0ae6e..d14e34a 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -415,7 +415,7 @@ TempSummon* Transport::SummonPassenger(uint32 entry, Position const& pos, TempSu
pos.GetPosition(x, y, z, o);
CalculatePassengerPosition(x, y, z, &o);
- if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, entry, x, y, z, o, nullptr, vehId))
+ if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, phase, 0, entry, x, y, z, o, nullptr, vehId))
{
delete summon;
return NULL;
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 454d79a..291248e 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1628,7 +1628,7 @@ void ObjectMgr::LoadCreatures()
// 0 1 2 3 4 5 6 7 8 9 10
QueryResult result = WorldDatabase.Query("SELECT creature.guid, id, map, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, "
// 11 12 13 14 15 16 17 18 19 20 21
- "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags "
+ "currentwaypoint, curhealth, curmana, MovementType, spawnMask, phaseMask, eventEntry, pool_entry, creature.npcflag, creature.unit_flags, creature.dynamicflags, creature.phaseid "
"FROM creature "
"LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
"LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
@@ -1685,6 +1685,7 @@ void ObjectMgr::LoadCreatures()
data.npcflag = fields[19].GetUInt32();
data.unit_flags = fields[20].GetUInt32();
data.dynamicflags = fields[21].GetUInt32();
+ data.phaseid = fields[22].GetUInt32();
MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
if (!mapEntry)
@@ -1903,6 +1904,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 mapId, float x, float y, float
data.movementType = cInfo->MovementType;
data.spawnMask = 1;
data.phaseMask = PHASEMASK_NORMAL;
+ data.phaseid = 0;
data.dbData = false;
data.npcflag = cInfo->npcflag;
data.unit_flags = cInfo->unit_flags;
diff --git a/src/server/game/Maps/PhaseMgr.cpp b/src/server/game/Maps/PhaseMgr.cpp
index 0f542bf..8bb074a 100644
--- a/src/server/game/Maps/PhaseMgr.cpp
+++ b/src/server/game/Maps/PhaseMgr.cpp
@@ -36,14 +36,8 @@ void PhaseMgr::Update()
if (IsUpdateInProgress())
return;
- if (_UpdateFlags & PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED)
- {
- phaseData.SendPhaseshiftToPlayer();
- player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PHASE);
- }
-
- if (_UpdateFlags & PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED)
- phaseData.SendPhaseMaskToPlayer();
+ phaseData.SendPhaseshiftToPlayer();
+ player->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PHASE);
_UpdateFlags = 0;
}
@@ -56,10 +50,7 @@ void PhaseMgr::RemoveUpdateFlag(PhaseUpdateFlag updateFlag)
{
// Update zone changes
if (phaseData.HasActiveDefinitions())
- {
phaseData.ResetDefinitions();
- _UpdateFlags |= (PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED | PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED);
- }
if (_PhaseDefinitionStore->find(player->GetZoneId()) != _PhaseDefinitionStore->end())
Recalculate();
@@ -86,10 +77,7 @@ void PhaseMgr::NotifyConditionChanged(PhaseUpdateData const& updateData)
void PhaseMgr::Recalculate()
{
if (phaseData.HasActiveDefinitions())
- {
phaseData.ResetDefinitions();
- _UpdateFlags |= (PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED | PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED);
- }
PhaseDefinitionStore::const_iterator itr = _PhaseDefinitionStore->find(player->GetZoneId());
if (itr != _PhaseDefinitionStore->end())
@@ -100,12 +88,6 @@ void PhaseMgr::Recalculate()
{
phaseData.AddPhaseDefinition(&(*phase));
- if (phase->phasemask)
- _UpdateFlags |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
-
- if (phase->phaseId || phase->terrainswapmap)
- _UpdateFlags |= PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED;
-
if (phase->IsLastDefinition())
break;
}
@@ -153,32 +135,13 @@ void PhaseMgr::RegisterPhasingAuraEffect(AuraEffect const* auraEffect)
{
PhaseInfo phaseInfo;
- if (auraEffect->GetMiscValue())
- {
- _UpdateFlags |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
- phaseInfo.phasemask = auraEffect->GetMiscValue();
- }
- else
- {
- SpellPhaseStore::const_iterator itr = _SpellPhaseStore->find(auraEffect->GetId());
- if (itr != _SpellPhaseStore->end())
- {
- if (itr->second.phasemask)
- {
- _UpdateFlags |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
- phaseInfo.phasemask = itr->second.phasemask;
- }
-
- if (itr->second.terrainswapmap)
- phaseInfo.terrainswapmap = itr->second.terrainswapmap;
- }
- }
+ SpellPhaseStore::const_iterator itr = _SpellPhaseStore->find(auraEffect->GetId());
+ if (itr != _SpellPhaseStore->end())
+ if (itr->second.terrainswapmap)
+ phaseInfo.terrainswapmap = itr->second.terrainswapmap;
phaseInfo.phaseId = auraEffect->GetMiscValueB();
- if (phaseInfo.NeedsClientSideUpdate())
- _UpdateFlags |= PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED;
-
phases.push_back(phaseInfo);
}
else if (auraEffect->GetAuraType() == SPELL_AURA_PHASE_GROUP)
@@ -189,8 +152,6 @@ void PhaseMgr::RegisterPhasingAuraEffect(AuraEffect const* auraEffect)
{
PhaseInfo phaseInfo;
phaseInfo.phaseId = auraEffect->GetMiscValueB();
- if (phaseInfo.NeedsClientSideUpdate())
- _UpdateFlags |= PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED;
phases.push_back(phaseInfo);
}
}
@@ -223,65 +184,26 @@ void PhaseMgr::SendDebugReportToPlayer(Player* const debugger)
for (PhaseDefinitionContainer::const_iterator phase = itr->second.begin(); phase != itr->second.end(); ++phase)
{
if (CheckDefinition(&(*phase)))
- ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_SUCCESS, phase->entry, phase->IsNegatingPhasemask() ? "negated Phase" : "Phase", phase->phasemask);
+ ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_SUCCESS, phase->entry, phase->IsNegatingPhasemask() ? "negated Phase" : "Phase", 0);
else
- ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_FAILED, phase->phasemask, phase->entry, phase->zoneId);
+ ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_FAILED, 0, phase->entry, phase->zoneId);
if (phase->IsLastDefinition())
{
- ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_LAST_PHASE, phase->phasemask, phase->entry, phase->zoneId);
+ ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_LAST_PHASE, 0, phase->entry, phase->zoneId);
break;
}
}
}
- ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_LIST, phaseData._PhasemaskThroughDefinitions, phaseData._PhasemaskThroughAuras, phaseData._CustomPhasemask);
-
- ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_PHASEMASK, phaseData.GetPhaseMaskForSpawn(), player->GetPhaseMask());
-}
-
-void PhaseMgr::SetCustomPhase(uint32 phaseMask)
-{
- phaseData._CustomPhasemask = phaseMask;
-
- _UpdateFlags |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
+ ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_LIST, 0, 0, 0);
- Update();
+ ChatHandler(debugger->GetSession()).PSendSysMessage(LANG_PHASING_PHASEMASK, 0, 0);
}
//////////////////////////////////////////////////////////////////
// Phase Data
-uint32 PhaseData::GetCurrentPhasemask() const
-{
- if (player->IsGameMaster())
- return uint32(PHASEMASK_ANYWHERE);
-
- if (_CustomPhasemask)
- return _CustomPhasemask;
-
- return GetPhaseMaskForSpawn();
-}
-
-inline uint32 PhaseData::GetPhaseMaskForSpawn() const
-{
- uint32 const phase = (_PhasemaskThroughDefinitions | _PhasemaskThroughAuras);
- return (phase ? phase : PHASEMASK_NORMAL);
-}
-
-void PhaseData::SendPhaseMaskToPlayer()
-{
- // Server side update
- uint32 const phasemask = GetCurrentPhasemask();
- if (player->GetPhaseMask() == phasemask)
- return;
-
- player->SetPhaseMask(phasemask, false);
-
- if (player->IsVisible())
- player->UpdateObjectVisibility();
-}
-
void PhaseData::SendPhaseshiftToPlayer()
{
// Client side update
@@ -311,6 +233,9 @@ void PhaseData::SendPhaseshiftToPlayer()
}
player->GetSession()->SendSetPhaseShift(phaseIds, terrainswaps);
+
+ if (player->IsVisible())
+ player->UpdateObjectVisibility();
}
void PhaseData::GetActivePhases(std::set<uint32>& phases) const
@@ -329,65 +254,19 @@ void PhaseData::GetActivePhases(std::set<uint32>& phases) const
void PhaseData::AddPhaseDefinition(PhaseDefinition const* phaseDefinition)
{
if (phaseDefinition->IsOverwritingExistingPhases())
- {
activePhaseDefinitions.clear();
- _PhasemaskThroughDefinitions = phaseDefinition->phasemask;
- }
- else
- {
- if (phaseDefinition->IsNegatingPhasemask())
- _PhasemaskThroughDefinitions &= ~phaseDefinition->phasemask;
- else
- _PhasemaskThroughDefinitions |= phaseDefinition->phasemask;
- }
activePhaseDefinitions.push_back(phaseDefinition);
}
void PhaseData::AddAuraInfo(uint32 spellId, PhaseInfo const& phaseInfo)
{
- if (phaseInfo.phasemask)
- _PhasemaskThroughAuras |= phaseInfo.phasemask;
-
spellPhaseInfo[spellId].push_back(phaseInfo);
}
-uint32 PhaseData::RemoveAuraInfo(uint32 spellId)
+void PhaseData::RemoveAuraInfo(uint32 spellId)
{
- PhaseInfoContainer::const_iterator rAura = spellPhaseInfo.find(spellId);
- if (rAura != spellPhaseInfo.end())
- {
- bool serverUpdated = false;
- bool clientUpdated = false;
- uint32 updateflag = 0;
-
- for (auto phase = rAura->second.begin(); phase != rAura->second.end(); ++phase)
- {
- if (!clientUpdated && phase->NeedsClientSideUpdate())
- {
- clientUpdated = true;
- updateflag |= PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED;
- }
-
- if (!serverUpdated && phase->NeedsServerSideUpdate())
- {
- serverUpdated = true;
- _PhasemaskThroughAuras = 0;
-
- updateflag |= PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED;
-
- spellPhaseInfo.erase(rAura);
-
- for (PhaseInfoContainer::const_iterator itr = spellPhaseInfo.begin(); itr != spellPhaseInfo.end(); ++itr)
- for (auto ph = itr->second.begin(); ph != itr->second.end(); ++ph)
- _PhasemaskThroughAuras |= ph->phasemask;
- }
- }
-
- return updateflag;
- }
-
- return 0;
+ spellPhaseInfo.erase(spellId);
}
//////////////////////////////////////////////////////////////////
@@ -440,3 +319,28 @@ void PhaseMgr::GetActivePhases(std::set<uint32>& phases) const
{
phaseData.GetActivePhases(phases);
}
+
+bool PhaseMgr::CanSee(WorldObject const* obj) const
+{
+ std::set<uint32> phases;
+ GetActivePhases(phases);
+
+ if (Player* plr = const_cast<Player*>(obj->ToPlayer()))
+ {
+ std::set<uint32> otherPhases;
+ plr->GetPhaseMgr().GetActivePhases(otherPhases);
+ if (phases.empty() && otherPhases.empty())
+ return true;
+
+ for (auto itr = phases.begin(); itr != phases.end(); ++itr)
+ if (otherPhases.find(*itr) != otherPhases.end())
+ return true;
+
+ return false;
+ }
+
+ if (!obj->GetPhaseId())
+ return false;
+
+ return phases.find(obj->GetPhaseId()) != phases.end();
+}
\ No newline at end of file
diff --git a/src/server/game/Maps/PhaseMgr.h b/src/server/game/Maps/PhaseMgr.h
index f5226e6..6397cd7 100644
--- a/src/server/game/Maps/PhaseMgr.h
+++ b/src/server/game/Maps/PhaseMgr.h
@@ -38,17 +38,12 @@ enum PhaseUpdateFlag
{
PHASE_UPDATE_FLAG_ZONE_UPDATE = 0x01,
PHASE_UPDATE_FLAG_AREA_UPDATE = 0x02,
-
- // Internal flags
- PHASE_UPDATE_FLAG_CLIENTSIDE_CHANGED = 0x08,
- PHASE_UPDATE_FLAG_SERVERSIDE_CHANGED = 0x10,
};
struct PhaseDefinition
{
uint32 zoneId;
uint32 entry;
- uint32 phasemask;
uint32 phaseId;
uint32 terrainswapmap;
uint8 flags;
@@ -64,7 +59,6 @@ typedef std::unordered_map<uint32 /*zoneId*/, PhaseDefinitionContainer> PhaseDef
struct SpellPhaseInfo
{
uint32 spellId;
- uint32 phasemask;
uint32 terrainswapmap;
};
@@ -72,37 +66,25 @@ typedef std::unordered_map<uint32 /*spellId*/, SpellPhaseInfo> SpellPhaseStore;
struct PhaseInfo
{
- PhaseInfo() : phasemask(0), terrainswapmap(0), phaseId(0) {}
+ PhaseInfo() : terrainswapmap(0), phaseId(0) {}
- uint32 phasemask;
uint32 terrainswapmap;
uint32 phaseId;
-
- bool NeedsServerSideUpdate() const { return phasemask; }
- bool NeedsClientSideUpdate() const { return terrainswapmap || phaseId; }
};
typedef std::unordered_map<uint32 /*spellId*/, std::list<PhaseInfo>> PhaseInfoContainer;
struct PhaseData
{
- PhaseData(Player* _player) : _PhasemaskThroughDefinitions(0), _PhasemaskThroughAuras(0), _CustomPhasemask(0), player(_player) {}
-
- uint32 _PhasemaskThroughDefinitions;
- uint32 _PhasemaskThroughAuras;
- uint32 _CustomPhasemask;
+ PhaseData(Player* _player) : player(_player) {}
- uint32 GetCurrentPhasemask() const;
- inline uint32 GetPhaseMaskForSpawn() const;
-
- void ResetDefinitions() { _PhasemaskThroughDefinitions = 0; activePhaseDefinitions.clear(); }
+ void ResetDefinitions() { activePhaseDefinitions.clear(); }
void AddPhaseDefinition(PhaseDefinition const* phaseDefinition);
bool HasActiveDefinitions() const { return !activePhaseDefinitions.empty(); }
void AddAuraInfo(uint32 spellId, PhaseInfo const& phaseInfo);
- uint32 RemoveAuraInfo(uint32 spellId);
+ void RemoveAuraInfo(uint32 spellId);
- void SendPhaseMaskToPlayer();
void SendPhaseshiftToPlayer();
void GetActivePhases(std::set<uint32>& phases) const;
@@ -132,9 +114,6 @@ public:
PhaseMgr(Player* _player);
~PhaseMgr() {}
- uint32 GetCurrentPhasemask() { return phaseData.GetCurrentPhasemask(); };
- inline uint32 GetPhaseMaskForSpawn() { return phaseData.GetCurrentPhasemask(); }
-
// Phase definitions update handling
void NotifyConditionChanged(PhaseUpdateData const& updateData);
void NotifyStoresReloaded() { Recalculate(); Update(); }
@@ -149,15 +128,13 @@ public:
void AddUpdateFlag(PhaseUpdateFlag updateFlag) { _UpdateFlags |= updateFlag; }
void RemoveUpdateFlag(PhaseUpdateFlag updateFlag);
- // Needed for modify phase command
- void SetCustomPhase(uint32 phaseMask);
-
// Debug
void SendDebugReportToPlayer(Player* const debugger);
static bool IsConditionTypeSupported(ConditionTypes conditionType);
void GetActivePhases(std::set<uint32>& phases) const;
+ bool CanSee(WorldObject const* obj) const;
private:
void Recalculate();
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index d0a005f..799ff87 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -928,7 +928,7 @@ public:
Map* map = handler->GetSession()->GetPlayer()->GetMap();
- if (!v->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_VEHICLE), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), entry, x, y, z, o, nullptr, id))
+ if (!v->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_VEHICLE), map, handler->GetSession()->GetPlayer()->GetPhaseMask(), 0, entry, x, y, z, o, nullptr, id))
{
delete v;
return false;
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index fb465aa..971af91 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -258,7 +258,7 @@ public:
}
Creature* creature = new Creature();
- if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, x, y, z, o))
+ if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), 0, id, x, y, z, o))
{
delete creature;
return false;
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index 5306e0e..ea2364d 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -694,7 +694,7 @@ public:
}
// re-create
Creature* wpCreature2 = new Creature();
- if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
+ if (!wpCreature2->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), 0, VISUAL_WAYPOINT, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
@@ -918,7 +918,7 @@ public:
float o = chr->GetOrientation();
Creature* wpCreature = new Creature();
- if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, x, y, z, o))
+ if (!wpCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), 0, id, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
@@ -982,7 +982,7 @@ public:
Map* map = chr->GetMap();
Creature* creature = new Creature();
- if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, x, y, z, o))
+ if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), 0, id, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete creature;
@@ -1031,7 +1031,7 @@ public:
Map* map = chr->GetMap();
Creature* creature = new Creature();
- if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), id, x, y, z, o))
+ if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMgr().GetPhaseMaskForSpawn(), 0, id, x, y, z, o))
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
delete creature;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment