aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2018-01-10 22:01:40 +0100
committerShauren <shauren.trinity@gmail.com>2018-01-10 22:01:40 +0100
commitbb718b557862057524778414ee728bf1923a14a4 (patch)
tree1900ff0b592fed7aa83071a5b1a14b6dddacf8a3 /src/server/game/Entities/Object
parent5b90538919cdf8b1984049bd203104128bec5bf2 (diff)
Core/Entities: Remove phasemask
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/Object.cpp39
-rw-r--r--src/server/game/Entities/Object/Object.h3
-rw-r--r--src/server/game/Entities/Object/PhaseShift.cpp18
-rw-r--r--src/server/game/Entities/Object/PhaseShift.h32
4 files changed, 63 insertions, 29 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 46db4f0d390..fd2b2ff6dfc 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -1542,7 +1542,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), _dbPhase(0), m_notifyflags(0), m_executed_notifies(0)
+_dbPhase(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);
@@ -2421,7 +2421,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
break;
}
- if (!summon->Create(GenerateLowGuid<HighGuid::Creature>(), this, 0, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
+ if (!summon->Create(GenerateLowGuid<HighGuid::Creature>(), this, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
{
delete summon;
return NULL;
@@ -2530,7 +2530,7 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, Position const& pos, Qua
Map* map = GetMap();
GameObject* go = new GameObject();
- if (!go->Create(entry, map, GetPhaseMask(), pos, rot, 255, GO_STATE_READY))
+ if (!go->Create(entry, map, pos, rot, 255, GO_STATE_READY))
{
delete go;
return nullptr;
@@ -2870,14 +2870,6 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
pos.SetOrientation(GetOrientation());
}
-void WorldObject::SetPhaseMask(uint32 newPhaseMask, bool update)
-{
- m_phaseMask = newPhaseMask;
-
- if (update && IsInWorld())
- UpdateObjectVisibility();
-}
-
bool WorldObject::HasInPhaseList(uint32 phase)
{
return _phases.find(phase) != _phases.end();
@@ -2920,20 +2912,15 @@ void WorldObject::UpdateAreaAndZonePhase()
for (Unit::AuraEffectList::const_iterator itr = auraPhaseList.begin(); itr != auraPhaseList.end(); ++itr)
{
uint32 phase = uint32((*itr)->GetMiscValueB());
- bool up = SetInPhase(phase, false, true);
- if (!updateNeeded && up)
- updateNeeded = true;
+ updateNeeded = SetInPhase(phase, false, true) || updateNeeded;
}
Unit::AuraEffectList const& auraPhaseGroupList = unit->GetAuraEffectsByType(SPELL_AURA_PHASE_GROUP);
for (Unit::AuraEffectList::const_iterator itr = auraPhaseGroupList.begin(); itr != auraPhaseGroupList.end(); ++itr)
{
- bool up = false;
uint32 phaseGroup = uint32((*itr)->GetMiscValueB());
- std::set<uint32> const& phaseIDs = sDB2Manager.GetPhasesForGroup(phaseGroup);
+ std::set<uint32> phaseIDs = sDB2Manager.GetPhasesForGroup(phaseGroup);
for (uint32 phase : phaseIDs)
- up = SetInPhase(phase, false, true);
- if (!updateNeeded && up)
- updateNeeded = true;
+ updateNeeded = SetInPhase(phase, false, true) || updateNeeded;
}
}
@@ -2952,13 +2939,16 @@ bool WorldObject::SetInPhase(uint32 id, bool update, bool apply)
{
if (apply)
{
- if (HasInPhaseList(id)) // do not run the updates if we are already in this phase
+ // do not run the updates if we are already in this phase
+ if (!_phases.insert(id).second)
return false;
-
- _phases.insert(id);
}
else
{
+ auto phaseItr = _phases.find(id);
+ if (phaseItr == _phases.end())
+ return false;
+
// if area phase passes the condition we should not remove it (ie: if remove called from aura remove)
// this however breaks the .mod phase command, you wont be able to remove any area based phases with it
if (std::vector<PhaseInfoStruct> const* phases = sObjectMgr->GetPhasesForArea(GetAreaId()))
@@ -2967,10 +2957,7 @@ bool WorldObject::SetInPhase(uint32 id, bool update, bool apply)
if (sConditionMgr->IsObjectMeetToConditions(this, phase.Conditions))
return false;
- if (!HasInPhaseList(id)) // do not run the updates if we are not in this phase
- return false;
-
- _phases.erase(id);
+ _phases.erase(phaseItr);
}
}
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index c2b454f4460..db8e40a45e7 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -408,7 +408,6 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
uint32 GetInstanceId() const { return m_InstanceId; }
- virtual void SetPhaseMask(uint32 newPhaseMask, bool update);
virtual bool SetInPhase(uint32 id, bool update, bool apply);
void CopyPhaseFrom(WorldObject* obj, bool update = false);
void UpdateAreaAndZonePhase();
@@ -416,7 +415,6 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
void RebuildTerrainSwaps();
void RebuildWorldMapAreaSwaps();
bool HasInPhaseList(uint32 phase);
- uint32 GetPhaseMask() const { return m_phaseMask; }
bool IsInPhase(uint32 phase) const { return _phases.find(phase) != _phases.end(); }
bool IsInPhase(std::set<uint32> const& phases) const;
bool IsInPhase(WorldObject const* obj) const;
@@ -608,7 +606,6 @@ class TC_GAME_API 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;
std::set<uint32> _terrainSwaps;
std::set<uint32> _worldMapAreaSwaps;
diff --git a/src/server/game/Entities/Object/PhaseShift.cpp b/src/server/game/Entities/Object/PhaseShift.cpp
new file mode 100644
index 00000000000..7bbf5dfe667
--- /dev/null
+++ b/src/server/game/Entities/Object/PhaseShift.cpp
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "PhaseShift.h"
diff --git a/src/server/game/Entities/Object/PhaseShift.h b/src/server/game/Entities/Object/PhaseShift.h
new file mode 100644
index 00000000000..e830938f41e
--- /dev/null
+++ b/src/server/game/Entities/Object/PhaseShift.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PhaseShift_h__
+#define PhaseShift_h__
+
+#include "Define.h"
+#include <set>
+
+class PhaseShift
+{
+private:
+ std::set<uint32> _phases;
+ std::set<uint32> _terrainSwaps;
+ std::set<uint32> _worldMapAreaSwaps;
+};
+
+#endif // PhaseShift_h__