Some refactoring of code. and some cleanups

This commit is contained in:
hondacrx
2019-09-21 12:11:16 -04:00
parent 7c405230cc
commit 35c06c09fd
214 changed files with 1235 additions and 1341 deletions
-1
View File
@@ -18,7 +18,6 @@
using Framework.Constants;
using Game.Entities;
using System.Collections.Generic;
using System.Linq;
namespace Game.Maps
{
-1
View File
@@ -21,7 +21,6 @@ using Game.DataStorage;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace Game.Maps
{
+15 -16
View File
@@ -24,7 +24,6 @@ using Game.Spells;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Concurrent;
namespace Game.Maps
{
@@ -119,7 +118,7 @@ namespace Game.Maps
break;
case TypeId.Player:
i_player.UpdateVisibilityOf(obj.ToPlayer(), i_data, i_visibleNow);
if (!obj.isNeedNotify(NotifyFlags.VisibilityChanged))
if (!obj.IsNeedNotify(NotifyFlags.VisibilityChanged))
obj.ToPlayer().UpdateVisibilityOf(i_player);
break;
case TypeId.Unit:
@@ -143,7 +142,7 @@ namespace Game.Maps
if (guid.IsPlayer())
{
Player pl = Global.ObjAccessor.FindPlayer(guid);
if (pl != null && pl.IsInWorld && !pl.isNeedNotify(NotifyFlags.VisibilityChanged))
if (pl != null && pl.IsInWorld && !pl.IsNeedNotify(NotifyFlags.VisibilityChanged))
pl.UpdateVisibilityOf(i_player);
}
}
@@ -236,7 +235,7 @@ namespace Game.Maps
i_player.UpdateVisibilityOf(player, i_data, i_visibleNow);
if (player.seerView.isNeedNotify(NotifyFlags.VisibilityChanged))
if (player.seerView.IsNeedNotify(NotifyFlags.VisibilityChanged))
continue;
player.UpdateVisibilityOf(i_player);
@@ -255,7 +254,7 @@ namespace Game.Maps
i_player.UpdateVisibilityOf(creature, i_data, i_visibleNow);
if (relocated_for_ai && !creature.isNeedNotify(NotifyFlags.VisibilityChanged))
if (relocated_for_ai && !creature.IsNeedNotify(NotifyFlags.VisibilityChanged))
CreatureUnitRelocationWorker(creature, i_player);
}
}
@@ -272,7 +271,7 @@ namespace Game.Maps
{
foreach (var player in objs)
{
if (!player.seerView.isNeedNotify(NotifyFlags.VisibilityChanged))
if (!player.seerView.IsNeedNotify(NotifyFlags.VisibilityChanged))
player.UpdateVisibilityOf(i_creature);
CreatureUnitRelocationWorker(i_creature, player);
@@ -288,7 +287,7 @@ namespace Game.Maps
{
CreatureUnitRelocationWorker(i_creature, creature);
if (!creature.isNeedNotify(NotifyFlags.VisibilityChanged))
if (!creature.IsNeedNotify(NotifyFlags.VisibilityChanged))
CreatureUnitRelocationWorker(creature, i_creature);
}
}
@@ -312,7 +311,7 @@ namespace Game.Maps
{
WorldObject viewPoint = player.seerView;
if (!viewPoint.isNeedNotify(NotifyFlags.VisibilityChanged))
if (!viewPoint.IsNeedNotify(NotifyFlags.VisibilityChanged))
continue;
if (player != viewPoint && !viewPoint.IsPositionValid())
@@ -329,7 +328,7 @@ namespace Game.Maps
{
foreach (var creature in objs)
{
if (!creature.isNeedNotify(NotifyFlags.VisibilityChanged))
if (!creature.IsNeedNotify(NotifyFlags.VisibilityChanged))
continue;
CreatureRelocationNotifier relocate = new CreatureRelocationNotifier(creature);
@@ -1519,7 +1518,7 @@ namespace Game.Maps
public bool Invoke(Creature u)
{
if (u.IsAlive() && u.IsInCombat() && !i_obj.IsHostileTo(u) && i_obj.IsWithinDistInMap(u, i_range) &&
(u.isFeared() || u.IsCharmed() || u.isFrozen() || u.HasUnitState(UnitState.Stunned) || u.HasUnitState(UnitState.Confused)))
(u.IsFeared() || u.IsCharmed() || u.IsFrozen() || u.HasUnitState(UnitState.Stunned) || u.HasUnitState(UnitState.Confused)))
return true;
return false;
}
@@ -1594,7 +1593,7 @@ namespace Game.Maps
if (u.IsTypeId(TypeId.Unit) && u.IsTotem())
return false;
if (!u.isTargetableForAttack(false))
if (!u.IsTargetableForAttack(false))
return false;
if (!i_obj.IsWithinDistInMap(u, i_range) || i_funit._IsValidAttackTarget(u, null, i_obj))
@@ -1701,7 +1700,7 @@ namespace Game.Maps
public bool Invoke(Unit u)
{
if (u.isTargetableForAttack() && i_obj.IsWithinDistInMap(u, i_range) &&
if (u.IsTargetableForAttack() && i_obj.IsWithinDistInMap(u, i_range) &&
(i_funit.IsInCombatWith(u) || i_funit.IsHostileTo(u)) && i_obj.CanSeeOrDetect(u))
{
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
@@ -1927,7 +1926,7 @@ namespace Game.Maps
public bool Invoke(Creature u)
{
if (u.getDeathState() != DeathState.Dead && u.GetEntry() == i_entry && u.IsAlive() == i_alive && i_obj.IsWithinDistInMap(u, i_range))
if (u.GetDeathState() != DeathState.Dead && u.GetEntry() == i_entry && u.IsAlive() == i_alive && i_obj.IsWithinDistInMap(u, i_range))
{
i_range = i_obj.GetDistance(u); // use found unit range as new range limit for next check
return true;
@@ -2171,7 +2170,7 @@ namespace Game.Maps
public class UnitAuraCheck<T> : ICheck<T> where T : WorldObject
{
public UnitAuraCheck(bool present, uint spellId, ObjectGuid casterGUID = default(ObjectGuid))
public UnitAuraCheck(bool present, uint spellId, ObjectGuid casterGUID = default)
{
_present = present;
_spellId = spellId;
@@ -2209,7 +2208,7 @@ namespace Game.Maps
if (go.GetGoInfo().SpellFocus.spellFocusType != i_focusId)
return false;
if (!go.isSpawned())
if (!go.IsSpawned())
return false;
float dist = go.GetGoInfo().SpellFocus.radius / 2.0f;
@@ -2232,7 +2231,7 @@ namespace Game.Maps
public bool Invoke(GameObject go)
{
if (go.GetGoInfo().type == GameObjectTypes.FishingHole && go.isSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, go.GetGoInfo().FishingHole.radius))
if (go.GetGoInfo().type == GameObjectTypes.FishingHole && go.IsSpawned() && i_obj.IsWithinDistInMap(go, i_range) && i_obj.IsWithinDistInMap(go, go.GetGoInfo().FishingHole.radius))
{
i_range = i_obj.GetDistance(go);
return true;
+5 -5
View File
@@ -305,7 +305,7 @@ namespace Game.Maps
{
Creature minion = instance.GetCreature(guid);
if (minion)
if (minion.isWorldBoss() && minion.IsAlive())
if (minion.IsWorldBoss() && minion.IsAlive())
return false;
}
}
@@ -460,9 +460,9 @@ namespace Game.Maps
{
if (go.GetGoType() == GameObjectTypes.Door || go.GetGoType() == GameObjectTypes.Button)
{
if (go.getLootState() == LootState.Ready)
if (go.GetLootState() == LootState.Ready)
go.UseDoorOrButton(withRestoreTime, useAlternativeState);
else if (go.getLootState() == LootState.Activated)
else if (go.GetLootState() == LootState.Activated)
go.ResetDoorOrButton();
}
else
@@ -482,7 +482,7 @@ namespace Game.Maps
{
if (go.GetGoType() == GameObjectTypes.Door || go.GetGoType() == GameObjectTypes.Button)
{
if (go.getLootState() == LootState.Activated)
if (go.GetLootState() == LootState.Activated)
go.ResetDoorOrButton();
}
else
@@ -510,7 +510,7 @@ namespace Game.Maps
break;
}
if (go.isSpawned())
if (go.IsSpawned())
return;
go.SetRespawnTime((int)timeToDespawn);
+16 -16
View File
@@ -518,7 +518,7 @@ namespace Game.Maps
}
var cell = new Cell(cellCoord);
if (obj.isActiveObject())
if (obj.IsActiveObject())
EnsureGridLoadedForActiveObject(cell, obj);
else
EnsureGridCreated(new GridCoord(cell.GetGridX(), cell.GetGridY()));
@@ -529,7 +529,7 @@ namespace Game.Maps
InitializeObject(obj);
if (obj.isActiveObject())
if (obj.IsActiveObject())
AddToActive(obj);
//something, such as vehicle, needs to be update immediately
@@ -656,7 +656,7 @@ namespace Game.Maps
if (player.IsInCombat())
{
List<Creature> updateList = new List<Creature>();
HostileReference refe = player.getHostileRefManager().getFirst();
HostileReference refe = player.GetHostileRefManager().getFirst();
while (refe != null)
{
@@ -818,7 +818,7 @@ namespace Game.Maps
{
Global.ScriptMgr.OnPlayerLeaveMap(this, player);
player.getHostileRefManager().deleteReferences(); // multithreading crashfix
player.GetHostileRefManager().deleteReferences(); // multithreading crashfix
bool inWorld = player.IsInWorld;
player.RemoveFromWorld();
@@ -840,7 +840,7 @@ namespace Game.Maps
{
bool inWorld = obj.IsInWorld && obj.GetTypeId() >= TypeId.Unit && obj.GetTypeId() <= TypeId.GameObject;
obj.RemoveFromWorld();
if (obj.isActiveObject())
if (obj.IsActiveObject())
RemoveFromActive(obj);
if (!inWorld) // if was in world, RemoveFromWorld() called DestroyForNearbyPlayers()
@@ -1323,7 +1323,7 @@ namespace Game.Maps
}
// in diff. grids but active creature
if (c.isActiveObject())
if (c.IsActiveObject())
{
EnsureGridLoadedForActiveObject(new_cell, c);
@@ -1367,7 +1367,7 @@ namespace Game.Maps
}
// in diff. grids but active GameObject
if (go.isActiveObject())
if (go.IsActiveObject())
{
EnsureGridLoadedForActiveObject(new_cell, go);
@@ -1424,7 +1424,7 @@ namespace Game.Maps
}
// in diff. grids but active GameObject
if (go.isActiveObject())
if (go.IsActiveObject())
{
EnsureGridLoadedForActiveObject(new_cell, go);
@@ -1476,7 +1476,7 @@ namespace Game.Maps
}
// in diff. grids but active AreaTrigger
if (at.isActiveObject())
if (at.IsActiveObject())
{
EnsureGridLoadedForActiveObject(new_cell, at);
@@ -3549,7 +3549,7 @@ namespace Game.Maps
if (obj == null)
Log.outError(LogFilter.Scripts, "{0} {1} object is NULL.", scriptInfo.GetDebugInfo(),
isSource ? "source" : "target");
else if (!obj.isTypeMask(TypeMask.Unit))
else if (!obj.IsTypeMask(TypeMask.Unit))
Log.outError(LogFilter.Scripts,
"{0} {1} object is not unit (TypeId: {2}, Entry: {3}, GUID: {4}), skipping.", scriptInfo.GetDebugInfo(), isSource ? "source" : "target", obj.GetTypeId(), obj.GetEntry(), obj.GetGUID().ToString());
else
@@ -3627,7 +3627,7 @@ namespace Game.Maps
Log.outError(LogFilter.Scripts, "{0} door guid is not specified.", scriptInfo.GetDebugInfo());
else if (source == null)
Log.outError(LogFilter.Scripts, "{0} source object is NULL.", scriptInfo.GetDebugInfo());
else if (!source.isTypeMask(TypeMask.Unit))
else if (!source.IsTypeMask(TypeMask.Unit))
Log.outError(LogFilter.Scripts,
"{0} source object is not unit (TypeId: {1}, Entry: {2}, GUID: {3}), skipping.", scriptInfo.GetDebugInfo(), source.GetTypeId(), source.GetEntry(), source.GetGUID().ToString());
else
@@ -3646,7 +3646,7 @@ namespace Game.Maps
{
pDoor.UseDoorOrButton((uint)nTimeToToggle);
if (target != null && target.isTypeMask(TypeMask.GameObject))
if (target != null && target.IsTypeMask(TypeMask.GameObject))
{
GameObject goTarget = target.ToGameObject();
if (goTarget != null && goTarget.GetGoType() == GameObjectTypes.Button)
@@ -3947,7 +3947,7 @@ namespace Game.Maps
}
// Check that GO is not spawned
if (!pGO.isSpawned())
if (!pGO.IsSpawned())
{
int nTimeToDespawn = Math.Max(5, (int)step.script.RespawnGameObject.DespawnDelay);
pGO.SetLootState(LootState.Ready);
@@ -4055,13 +4055,13 @@ namespace Game.Maps
break;
}
if (uSource == null || !uSource.isTypeMask(TypeMask.Unit))
if (uSource == null || !uSource.IsTypeMask(TypeMask.Unit))
{
Log.outError(LogFilter.Scripts, "{0} no source unit found for spell {1}", step.script.GetDebugInfo(), step.script.CastSpell.SpellID);
break;
}
if (uTarget == null || !uTarget.isTypeMask(TypeMask.Unit))
if (uTarget == null || !uTarget.IsTypeMask(TypeMask.Unit))
{
Log.outError(LogFilter.Scripts, "{0} no target unit found for spell {1}", step.script.GetDebugInfo(), step.script.CastSpell.SpellID);
break;
@@ -4180,7 +4180,7 @@ namespace Game.Maps
Log.outError(LogFilter.Scripts, "{0} creature is already dead (Entry: {1}, GUID: {2})", step.script.GetDebugInfo(), cSource.GetEntry(), cSource.GetGUID().ToString());
else
{
cSource.setDeathState(DeathState.JustDied);
cSource.SetDeathState(DeathState.JustDied);
if (step.script.Kill.RemoveCorpse == 1)
cSource.RemoveCorpse();
}
+1 -3
View File
@@ -18,8 +18,6 @@
using Framework.Constants;
using Game.Entities;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Concurrent;
namespace Game.Maps
{
@@ -101,7 +99,7 @@ namespace Game.Maps
{
map.AddToGrid(obj, new Cell(cellCoord));
obj.AddToWorld();
if (obj.isActiveObject())
if (obj.IsActiveObject())
map.AddToActive(obj);
++count;