Some cleanups. (might break build for scripts as they are a WIP)

This commit is contained in:
hondacrx
2023-10-08 10:35:31 -04:00
parent fa10b981bd
commit cda53c8e7f
208 changed files with 2266 additions and 2329 deletions
+2 -2
View File
@@ -16,12 +16,12 @@ namespace Game.Movement
if (unit == _target)
return;
if (_target)
if (_target != null)
_target.FollowerRemoved(this);
_target = unit;
if (_target)
if (_target != null)
_target.FollowerAdded(this);
}
@@ -55,7 +55,7 @@ namespace Game.Movement
public override bool Update(Unit owner, uint diff)
{
// owner might be dead or gone (can we even get nullptr here?)
if (!owner || !owner.IsAlive())
if (owner == null || !owner.IsAlive())
return false;
// our target might have gone away
@@ -162,7 +162,7 @@ namespace Game.Movement
bool success = _path.CalculatePath(x, y, z, owner.CanFly());
if (!success || _path.GetPathType().HasAnyFlag(PathType.NoPath))
{
if (cOwner)
if (cOwner != null)
cOwner.SetCannotReachTarget(true);
owner.StopMoving();
@@ -172,11 +172,11 @@ namespace Game.Movement
if (shortenPath)
_path.ShortenPathUntilDist(target, maxTarget);
if (cOwner)
if (cOwner != null)
cOwner.SetCannotReachTarget(false);
bool walk = false;
if (cOwner && !cOwner.IsPet())
if (cOwner != null && !cOwner.IsPet())
{
switch (cOwner.GetMovementTemplate().GetChase())
{
@@ -25,7 +25,7 @@ namespace Game.Movement
RemoveFlag(MovementGeneratorFlags.InitializationPending | MovementGeneratorFlags.Transitory | MovementGeneratorFlags.Deactivated);
AddFlag(MovementGeneratorFlags.Initialized);
if (!owner || !owner.IsAlive())
if (owner == null || !owner.IsAlive())
return;
// TODO: UNIT_FIELD_FLAGS should not be handled by generators
@@ -45,7 +45,7 @@ namespace Game.Movement
public override bool DoUpdate(T owner, uint diff)
{
if (!owner || !owner.IsAlive())
if (owner == null || !owner.IsAlive())
return false;
if (owner.HasUnitState(UnitState.NotMove) || owner.IsMovementPreventedByCasting())
@@ -124,7 +124,7 @@ namespace Game.Movement
{
owner.RemoveUnitFlag(UnitFlags.Confused);
owner.ClearUnitState(UnitState.ConfusedMove);
if (owner.GetVictim())
if (owner.GetVictim() != null)
owner.SetTarget(owner.GetVictim().GetGUID());
}
}
@@ -189,7 +189,7 @@ namespace Game.Movement
Pet oPet = owner.ToPet();
if (oPet != null)
{
if (!_abstractFollower.GetTarget() || _abstractFollower.GetTarget().GetGUID() == owner.GetOwnerGUID())
if (_abstractFollower.GetTarget() == null || _abstractFollower.GetTarget().GetGUID() == owner.GetOwnerGUID())
{
oPet.UpdateSpeed(UnitMoveType.Run);
oPet.UpdateSpeed(UnitMoveType.Walk);
@@ -56,7 +56,7 @@ namespace Game.Movement
public override bool Update(Unit owner, uint diff)
{
if (!owner || HasFlag(MovementGeneratorFlags.Finalized))
if (owner == null || HasFlag(MovementGeneratorFlags.Finalized))
return false;
// Cyclic splines never expire, so update the duration only if it's not cyclic
@@ -87,7 +87,7 @@ namespace Game.Movement
if (_speed.HasValue)
init.SetVelocity(_speed.Value);
if (_faceTarget)
if (_faceTarget != null)
init.SetFacing(_faceTarget);
if (_spellEffectExtra != null)
@@ -59,7 +59,7 @@ namespace Game.Movement
public override bool DoUpdate(Creature owner, uint diff)
{
if (!owner || !owner.IsAlive())
if (owner == null || !owner.IsAlive())
return true;
if (HasFlag(MovementGeneratorFlags.Finalized | MovementGeneratorFlags.Paused))
@@ -160,7 +160,7 @@ namespace Game.Movement
public override bool DoUpdate(Creature owner, uint diff)
{
if (!owner || !owner.IsAlive())
if (owner == null || !owner.IsAlive())
return true;
if (HasFlag(MovementGeneratorFlags.Finalized | MovementGeneratorFlags.Paused) || _path == null || _path.nodes.Empty())
@@ -363,7 +363,7 @@ namespace Game.Movement
trans.CalculatePassengerPosition(ref x, ref y, ref z, ref o);
owner.SetHomePosition(x, y, z, o);
}
// else if (vehicle) - this should never happen, vehicle offsets are const
// else if (vehicle != null) - this should never happen, vehicle offsets are const
}
AddFlag(MovementGeneratorFlags.Finalized);
+5 -5
View File
@@ -288,7 +288,7 @@ namespace Game.Movement
public void Update(uint diff)
{
if (!_owner)
if (_owner == null)
return;
if (HasFlag(MotionMasterFlags.InitializationPending | MotionMasterFlags.Initializing))
@@ -556,7 +556,7 @@ namespace Game.Movement
public void MoveFollow(Unit target, float dist, ChaseAngle angle, TimeSpan? duration = null, MovementSlot slot = MovementSlot.Active)
{
// Ignore movement request if target not exist
if (!target || target == _owner)
if (target == null || target == _owner)
return;
Add(new FollowMovementGenerator(target, dist, angle, duration), slot);
@@ -567,7 +567,7 @@ namespace Game.Movement
public void MoveChase(Unit target, ChaseRange? dist = null, ChaseAngle? angle = null)
{
// Ignore movement request if target not exist
if (!target || target == _owner)
if (target == null || target == _owner)
return;
Add(new ChaseMovementGenerator(target, dist, angle));
@@ -583,7 +583,7 @@ namespace Game.Movement
public void MoveFleeing(Unit enemy, TimeSpan time = default)
{
if (!enemy)
if (enemy == null)
return;
if (_owner.IsCreature())
@@ -899,7 +899,7 @@ namespace Game.Movement
public void MoveAlongSplineChain(uint pointId, uint dbChainId, bool walk)
{
Creature owner = _owner.ToCreature();
if (!owner)
if (owner == null)
{
Log.outError(LogFilter.Misc, "MotionMaster.MoveAlongSplineChain: non-creature {0} tried to walk along DB spline chain. Ignoring.", _owner.GetGUID().ToString());
return;
+1 -1
View File
@@ -47,7 +47,7 @@ namespace Game.Movement
{
if (!exp)
{
if (unit)
if (unit != null)
Log.outError(LogFilter.Movement, $"MoveSplineInitArgs::Validate: expression '{exp}' failed for {(verbose ? unit.GetDebugInfo() : unit.GetGUID().ToString())}");
else
Log.outError(LogFilter.Movement, $"MoveSplineInitArgs::Validate: expression '{exp}' failed for cyclic spline continuation");