Core/Entities: Remove phasemask

This commit is contained in:
hondacrx
2018-01-10 22:26:47 -05:00
parent ae9b786784
commit 79980e3dd2
21 changed files with 41 additions and 67 deletions
@@ -324,12 +324,6 @@ namespace Framework.Constants
}
}
public struct PhaseMasks
{
public const uint Normal = 0x00000001;
public const uint Anywhere = 0xFFFFFFFF;
}
public enum LocaleConstant
{
enUS = 0,
+2 -2
View File
@@ -683,7 +683,7 @@ namespace Game.BattleFields
pos.GetPosition(out x, out y, out z, out o);
Creature creature = new Creature();
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, PhaseMasks.Normal, entry, x, y, z, o))
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, entry, x, y, z, o))
{
Log.outError(LogFilter.Battlefield, "Battlefield:SpawnCreature: Can't create creature entry: {0}", entry);
return null;
@@ -715,7 +715,7 @@ namespace Game.BattleFields
// Create gameobject
GameObject go = new GameObject();
if (!go.Create(entry, map, PhaseMasks.Normal, pos, rotation, 255, GameObjectState.Ready))
if (!go.Create(entry, map, pos, rotation, 255, GameObjectState.Ready))
{
Log.outError(LogFilter.Battlefield, "Battlefield:SpawnGameObject: Cannot create gameobject template {1}! Battlefield not created!", entry);
return null;
+2 -2
View File
@@ -1324,7 +1324,7 @@ namespace Game.BattleGrounds
// and when loading it (in go.LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
// So we must create it specific for this instance
GameObject go = new GameObject();
if (!go.Create(entry, GetBgMap(), PhaseMasks.Normal, new Position(x, y, z, o), rotation, 100, goState))
if (!go.Create(entry, GetBgMap(), new Position(x, y, z, o), rotation, 100, goState))
{
Log.outError(LogFilter.Battleground, "Battleground.AddObject: cannot create gameobject (entry: {0}) for BG (map: {1}, instance id: {2})!", entry, m_MapId, m_InstanceID);
return false;
@@ -1440,7 +1440,7 @@ namespace Game.BattleGrounds
}
Creature creature = new Creature();
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, PhaseMasks.Normal, entry, x, y, z, o))
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, entry, x, y, z, o))
{
Log.outError(LogFilter.Battleground, "Battleground.AddCreature: cannot create creature (entry: {0}) for BG (map: {1}, instance id: {2})!",
entry, m_MapId, m_InstanceID);
+1 -1
View File
@@ -941,7 +941,7 @@ namespace Game.Chat
Creature creature = new Creature();
Map map = handler.GetSession().GetPlayer().GetMap();
if (!creature.Create(map.GenerateLowGuid(HighGuid.Vehicle), map, handler.GetSession().GetPlayer().GetPhaseMask(), entry, x, y, z, o, null, id))
if (!creature.Create(map.GenerateLowGuid(HighGuid.Vehicle), map, entry, x, y, z, o, null, id))
return false;
map.AddToMap(creature.ToCreature());
@@ -476,7 +476,7 @@ namespace Game.Chat
GameObject obj = new GameObject();
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(player.GetOrientation(), 0.0f, 0.0f));
if (!obj.Create(objectInfo.entry, map, 0, player, rotation, 255, GameObjectState.Ready))
if (!obj.Create(objectInfo.entry, map, player, rotation, 255, GameObjectState.Ready))
return false;
obj.CopyPhaseFrom(player);
+3 -4
View File
@@ -240,7 +240,6 @@ namespace Game.Chat
{
// Get ALL the variables!
Player playerTarget;
uint phase = 0;
ObjectGuid guidTarget;
string nameTarget;
string zoneName = "";
@@ -317,11 +316,12 @@ namespace Game.Chat
// Check if iterator is online. If is...
Player p = Global.ObjAccessor.FindPlayer(slot.guid);
string phases = "";
if (p && p.IsInWorld)
{
// ... than, it prints information like "is online", where he is, etc...
onlineState = "online";
phase = (!p.IsGameMaster() ? p.GetPhaseMask() : uint.MaxValue);
phases = string.Join(", ", p.GetPhases());
AreaTableRecord area = CliDB.AreaTableStorage.LookupByKey(p.GetAreaId());
if (area != null)
@@ -336,12 +336,11 @@ namespace Game.Chat
// ... else, everything is set to offline or neutral values.
zoneName = "<ERROR>";
onlineState = "Offline";
phase = 0;
}
// Now we can print those informations for every single member of each group!
handler.SendSysMessage(CypherStrings.GroupPlayerNameGuid, slot.name, onlineState,
zoneName, phase, slot.guid.ToString(), flags, LFGQueue.GetRolesString(slot.roles));
zoneName, phases, slot.guid.ToString(), flags, LFGQueue.GetRolesString(slot.roles));
}
// And finish after every iterator is done.
+1 -1
View File
@@ -224,7 +224,7 @@ namespace Game.Chat
mapId, (mapEntry != null ? mapEntry.MapName[handler.GetSessionDbcLocale()] : unknown),
zoneId, (zoneEntry != null ? zoneEntry.AreaName[handler.GetSessionDbcLocale()] : unknown),
areaId, (areaEntry != null ? areaEntry.AreaName[handler.GetSessionDbcLocale()] : unknown),
obj.GetPhaseMask(), string.Join(", ", obj.GetPhases()), obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ(), obj.GetOrientation());
string.Join(", ", obj.GetPhases()), obj.GetPositionX(), obj.GetPositionY(), obj.GetPositionZ(), obj.GetOrientation());
Transport transport = obj.GetTransport();
if (transport)
+1 -1
View File
@@ -1120,7 +1120,7 @@ namespace Game.Chat
}
Creature creature = new Creature();
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, chr.GetPhaseMask(), id, x, y, z, o))
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, id, x, y, z, o))
return false;
creature.CopyPhaseFrom(chr);
+4 -4
View File
@@ -546,7 +546,7 @@ namespace Game.Chat.Commands
// re-create
Creature wpCreature = new Creature();
if (!wpCreature.Create(map.GenerateLowGuid(HighGuid.Creature), map, chr.GetPhaseMask(), 1, chr.GetPositionX(), chr.GetPositionY(), chr.GetPositionZ(), chr.GetOrientation()))
if (!wpCreature.Create(map.GenerateLowGuid(HighGuid.Creature), map, 1, chr.GetPositionX(), chr.GetPositionY(), chr.GetPositionZ(), chr.GetOrientation()))
{
wpCreature.CopyPhaseFrom(chr);
wpCreature.SaveToDB(map.GetId(), 1ul << (int)map.GetSpawnMode());
@@ -755,7 +755,7 @@ namespace Game.Chat.Commands
float o = chr.GetOrientation();
Creature wpCreature = new Creature();
if (!wpCreature.Create(map.GenerateLowGuid(HighGuid.Creature), map, chr.GetPhaseMask(), id, x, y, z, o))
if (!wpCreature.Create(map.GenerateLowGuid(HighGuid.Creature), map, id, x, y, z, o))
{
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
return false;
@@ -815,7 +815,7 @@ namespace Game.Chat.Commands
Map map = chr.GetMap();
Creature creature = new Creature();
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, chr.GetPhaseMask(), id, x, y, z, o))
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, id, x, y, z, o))
{
handler.SendSysMessage(CypherStrings.WaypointVpNotcreated, id);
return false;
@@ -863,7 +863,7 @@ namespace Game.Chat.Commands
Map map = chr.GetMap();
Creature creature = new Creature();
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, chr.GetPhaseMask(), id, x, y, z, o))
if (!creature.Create(map.GenerateLowGuid(HighGuid.Creature), map, id, x, y, z, o))
{
handler.SendSysMessage(CypherStrings.WaypointNotcreated, id);
return false;
@@ -96,7 +96,6 @@ namespace Game.Entities
}
_Create(ObjectGuid.Create(HighGuid.AreaTrigger, GetMapId(), GetTemplate().Id, caster.GetMap().GenerateLowGuid(HighGuid.AreaTrigger)));
SetPhaseMask(caster.GetPhaseMask(), false);
SetEntry(GetTemplate().Id);
SetDuration(duration);
-1
View File
@@ -111,7 +111,6 @@ namespace Game.Entities
Relocate(pos);
base._Create(ObjectGuid.Create(HighGuid.Conversation, GetMapId(), conversationEntry, lowGuid));
SetPhaseMask(creator.GetPhaseMask(), false);
CopyPhaseFrom(creator);
SetEntry(conversationEntry);
-1
View File
@@ -78,7 +78,6 @@ namespace Game.Entities
}
_Create(ObjectGuid.Create(HighGuid.Corpse, owner.GetMapId(), 0, guidlow));
SetPhaseMask(owner.GetPhaseMask(), false);
SetObjectScale(1);
SetGuidValue(CorpseFields.Owner, owner.GetGUID());
+4 -4
View File
@@ -720,7 +720,7 @@ namespace Game.Entities
GetMotionMaster().Initialize();
}
public bool Create(ulong guidlow, Map map, uint phaseMask, uint entry, float x, float y, float z, float ang, CreatureData data = null, uint vehId = 0)
public bool Create(ulong guidlow, Map map, uint entry, float x, float y, float z, float ang, CreatureData data = null, uint vehId = 0)
{
SetMap(map);
@@ -1044,8 +1044,8 @@ namespace Game.Entities
data.unit_flags3 = unitFlags3;
data.dynamicflags = dynamicflags;
data.phaseId = (uint)(GetDBPhase() > 0 ? GetDBPhase() : 0);
data.phaseGroup = (uint)(GetDBPhase() < 0 ? Math.Abs(GetDBPhase()) : 0);
data.phaseId = GetDBPhase() > 0 ? (uint)GetDBPhase() : data.phaseId;
data.phaseGroup = GetDBPhase() < 0 ? (uint)-GetDBPhase() : data.phaseGroup;
// update in DB
SQLTransaction trans = new SQLTransaction();
@@ -1319,7 +1319,7 @@ namespace Game.Entities
m_spawnId = spawnId;
m_creatureData = data;
if (!Create(map.GenerateLowGuid(HighGuid.Creature), map, PhaseMasks.Normal, data.id, data.posX, data.posY, data.posZ, data.orientation, data))
if (!Create(map.GenerateLowGuid(HighGuid.Creature), map, 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
-1
View File
@@ -88,7 +88,6 @@ namespace Game.Entities
}
_Create(ObjectGuid.Create(HighGuid.DynamicObject, GetMapId(), spell.Id, guidlow));
SetPhaseMask(caster.GetPhaseMask(), false);
SetEntry(spell.Id);
SetObjectScale(1f);
@@ -158,7 +158,7 @@ namespace Game.Entities
}
}
public bool Create(uint name_id, Map map, uint phaseMask, Position pos, Quaternion rotation, uint animprogress, GameObjectState go_state, uint artKit = 0)
public bool Create(uint name_id, Map map, Position pos, Quaternion rotation, uint animprogress, GameObjectState go_state, uint artKit = 0)
{
Contract.Assert(map);
SetMap(map);
@@ -341,7 +341,7 @@ namespace Game.Entities
if (linkedEntry != 0)
{
GameObject linkedGO = new GameObject();
if (linkedGO.Create(linkedEntry, map, phaseMask, pos, rotation, 255, GameObjectState.Ready))
if (linkedGO.Create(linkedEntry, map, pos, rotation, 255, GameObjectState.Ready))
{
SetLinkedTrap(linkedGO);
map.AddToMap(linkedGO);
@@ -877,8 +877,8 @@ namespace Game.Entities
data.artKit = GetGoArtKit();
Global.ObjectMgr.NewGOData(m_spawnId, data);
data.phaseId = (uint)(GetDBPhase() > 0 ? GetDBPhase() : 0);
data.phaseGroup = (uint)(GetDBPhase() < 0 ? Math.Abs(GetDBPhase()) : 0);
data.phaseId = GetDBPhase() > 0 ? (uint)GetDBPhase() : data.phaseId;
data.phaseGroup = GetDBPhase() < 0 ? (uint)-GetDBPhase() : data.phaseGroup;
// Update in DB
byte index = 0;
@@ -925,7 +925,7 @@ namespace Game.Entities
uint artKit = data.artKit;
m_spawnId = spawnId;
if (!Create(entry, map, PhaseMasks.Normal, pos, data.rotation, animprogress, go_state, artKit))
if (!Create(entry, map, pos, data.rotation, animprogress, go_state, artKit))
return false;
if (data.phaseId != 0)
+8 -23
View File
@@ -43,7 +43,6 @@ namespace Game.Entities
{
_name = "";
m_isWorldObject = isWorldObject;
phaseMask = PhaseMasks.Normal;
m_serverSideVisibility.SetValue(ServerSideVisibilityType.Ghost, GhostVisibilityType.Alive | GhostVisibilityType.Ghost);
m_serverSideVisibilityDetect.SetValue(ServerSideVisibilityType.Ghost, GhostVisibilityType.Alive);
@@ -2045,7 +2044,7 @@ namespace Game.Entities
Map map = GetMap();
GameObject go = new GameObject();
if (!go.Create(entry, map, GetPhaseMask(), pos, rotation, 255, GameObjectState.Ready))
if (!go.Create(entry, map, pos, rotation, 255, GameObjectState.Ready))
return null;
go.CopyPhaseFrom(this);
@@ -2155,14 +2154,6 @@ namespace Game.Entities
return (valuesCount > (uint)UnitFields.CombatReach) ? GetFloatValue(UnitFields.CombatReach) : SharedConst.DefaultWorldObjectSize;
}
public virtual void SetPhaseMask(uint newPhaseMask, bool update)
{
phaseMask = newPhaseMask;
if (update && IsInWorld)
UpdateObjectVisibility();
}
bool HasInPhaseList(uint phase)
{
return _phases.Contains(phase);
@@ -2209,20 +2200,14 @@ namespace Game.Entities
foreach (var eff in auraPhaseList)
{
uint phase = (uint)eff.GetMiscValueB();
bool up = SetInPhase(phase, false, true);
if (!updateNeeded && up)
updateNeeded = true;
updateNeeded = SetInPhase(phase, false, true) || updateNeeded;
}
var auraPhaseGroupList = unit.GetAuraEffectsByType(AuraType.PhaseGroup);
foreach (var eff in auraPhaseGroupList)
{
bool up = false;
uint phaseGroup = (uint)eff.GetMiscValueB();
foreach (uint phase in Global.DB2Mgr.GetPhasesForGroup(phaseGroup))
up = SetInPhase(phase, false, true);
if (!updateNeeded && up)
updateNeeded = true;
updateNeeded = SetInPhase(phase, false, true) || updateNeeded;
}
}
@@ -2242,13 +2227,17 @@ namespace Game.Entities
{
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.Contains(id))
return false;
_phases.Add(id);
}
else
{
if (!_phases.Contains(id))
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
var phases = Global.ObjectMgr.GetPhasesForArea(GetAreaId());
@@ -2262,8 +2251,6 @@ namespace Game.Entities
}
}
if (!HasInPhaseList(id)) // do not run the updates if we are not in this phase
return false;
_phases.Remove(id);
}
}
@@ -2400,7 +2387,6 @@ namespace Game.Entities
}
}
public uint GetPhaseMask() { return phaseMask; }
public List<uint> GetPhases() { return _phases; }
public List<uint> GetTerrainSwaps() { return _terrainSwaps; }
public List<uint> GetWorldMapAreaSwaps() { return _worldMapAreaSwaps; }
@@ -3172,7 +3158,6 @@ namespace Game.Entities
Transport m_transport;
Map _currMap;
uint instanceId;
uint phaseMask;
List<uint> _phases = new List<uint>();
List<uint> _terrainSwaps = new List<uint>();
List<uint> _worldMapAreaSwaps = new List<uint>();
+1 -1
View File
@@ -474,7 +474,7 @@ namespace Game.Entities
pos.GetPosition(out x, out y, out z, out o);
CalculatePassengerPosition(ref x, ref y, ref z, ref o);
if (!summon.Create(map.GenerateLowGuid(HighGuid.Creature), map, 0, entry, x, y, z, o, null, vehId))
if (!summon.Create(map.GenerateLowGuid(HighGuid.Creature), map, entry, x, y, z, o, null, vehId))
return null;
foreach (var phase in phases)
+2 -2
View File
@@ -709,7 +709,7 @@ namespace Game.Garrisons
Position pos = PacketInfo.PlotPos;
GameObject go = new GameObject();
if (!go.Create(entry, map, 0, pos, Quaternion.WAxis, 255, GameObjectState.Active))
if (!go.Create(entry, map, pos, Quaternion.WAxis, 255, GameObjectState.Active))
return null;
if (BuildingInfo.CanActivate() && BuildingInfo.PacketInfo.HasValue && !BuildingInfo.PacketInfo.Value.Active)
@@ -719,7 +719,7 @@ namespace Game.Garrisons
{
Position pos2 = finalizeInfo.factionInfo[faction].Pos;
GameObject finalizer = new GameObject();
if (finalizer.Create(finalizeInfo.factionInfo[faction].GameObjectId, map, 0, pos2, Quaternion.WAxis, 255, GameObjectState.Ready))
if (finalizer.Create(finalizeInfo.factionInfo[faction].GameObjectId, map, pos2, Quaternion.WAxis, 255, GameObjectState.Ready))
{
// set some spell id to make the object delete itself after use
finalizer.SetSpellId(finalizer.GetGoInfo().Goober.spell);
+1 -1
View File
@@ -3203,7 +3203,7 @@ namespace Game.Maps
return null;
}
if (!summon.Create(GenerateLowGuid(HighGuid.Creature), this, 0, entry, pos.posX, pos.posY, pos.posZ, pos.Orientation, null, vehId))
if (!summon.Create(GenerateLowGuid(HighGuid.Creature), this, entry, pos.posX, pos.posY, pos.posZ, pos.Orientation, null, vehId))
return null;
// Set the summon to the summoner's phase
+4 -4
View File
@@ -2852,7 +2852,7 @@ namespace Game.Spells
Map map = target.GetMap();
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(target.GetOrientation(), 0.0f, 0.0f));
if (!pGameObj.Create(gameobject_id, map, m_caster.GetPhaseMask(), new Position(x, y, z, target.GetOrientation()), rotation, 255, GameObjectState.Ready))
if (!pGameObj.Create(gameobject_id, map, new Position(x, y, z, target.GetOrientation()), rotation, 255, GameObjectState.Ready))
return;
pGameObj.CopyPhaseFrom(m_caster);
@@ -3516,7 +3516,7 @@ namespace Game.Spells
Map map = m_caster.GetMap();
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(pos.GetOrientation(), 0.0f, 0.0f));
if (!pGameObj.Create((uint)gameobject_id, map, m_caster.GetPhaseMask(), pos, rotation, 0, GameObjectState.Ready))
if (!pGameObj.Create((uint)gameobject_id, map, pos, rotation, 0, GameObjectState.Ready))
return;
pGameObj.CopyPhaseFrom(m_caster);
@@ -3860,7 +3860,7 @@ namespace Game.Spells
Map map = m_caster.GetMap();
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(m_caster.GetOrientation(), 0.0f, 0.0f));
if (!go.Create(go_id, map, m_caster.GetPhaseMask(), new Position(x, y, z, m_caster.GetOrientation()), rotation, 255, GameObjectState.Ready))
if (!go.Create(go_id, map, new Position(x, y, z, m_caster.GetOrientation()), rotation, 255, GameObjectState.Ready))
return;
go.CopyPhaseFrom(m_caster);
@@ -4548,7 +4548,7 @@ namespace Game.Spells
Position pos = new Position(fx, fy, fz, m_caster.GetOrientation());
Quaternion rotation = new Quaternion(Matrix3.fromEulerAnglesZYX(m_caster.GetOrientation(), 0.0f, 0.0f));
if (!pGameObj.Create(name_id, cMap, m_caster.GetPhaseMask(), pos, rotation, 255, GameObjectState.Ready))
if (!pGameObj.Create(name_id, cMap, pos, rotation, 255, GameObjectState.Ready))
return;
pGameObj.CopyPhaseFrom(m_caster);
@@ -144,7 +144,7 @@ namespace Scripts.Northrend.Nexus.EyeOfEternity
void SpawnGameObject(uint entry, Position pos)
{
GameObject go = new GameObject();
if (go.Create(entry, instance, PhaseMasks.Normal, pos, Quaternion.WAxis, 255, GameObjectState.Ready))
if (go.Create(entry, instance, pos, Quaternion.WAxis, 255, GameObjectState.Ready))
instance.AddToMap(go);
}