Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)

This commit is contained in:
Kamron Batman 2019-03-11 14:29:59 -07:00 • committed by GitHub
parent e748af4430
commit 513e54f70e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1094 changed files with 15913 additions and 21892 deletions

View file

@ -25,37 +25,38 @@ namespace Server.Mobiles
public virtual void RangeCheck()
{
if (!Deleted && ControlMaster != null && !ControlMaster.Deleted)
if (Deleted || ControlMaster?.Deleted != false)
return;
int range = RangeHome - 2;
if (InRange(ControlMaster.Location, RangeHome))
return;
Mobile master = ControlMaster;
Point3D m_Loc = Point3D.Zero;
if (Map != master.Map)
return;
int x = X > master.X ? master.X + range : master.X - range;
int y = Y > master.Y ? master.Y + range : master.Y - range;
for (int i = 0; i < 10; i++)
{
int range = RangeHome - 2;
m_Loc.X = x + Utility.RandomMinMax(-1, 1);
m_Loc.Y = y + Utility.RandomMinMax(-1, 1);
if (!InRange(ControlMaster.Location, RangeHome))
{
Mobile master = ControlMaster;
m_Loc.Z = Map.GetAverageZ(m_Loc.X, m_Loc.Y);
Point3D m_Loc = Point3D.Zero;
if (Map.CanSpawnMobile(m_Loc)) break;
if (Map == master.Map)
{
int x = X > master.X ? master.X + range : master.X - range;
int y = Y > master.Y ? master.Y + range : master.Y - range;
for (int i = 0; i < 10; i++)
{
m_Loc.X = x + Utility.RandomMinMax(-1, 1);
m_Loc.Y = y + Utility.RandomMinMax(-1, 1);
m_Loc.Z = Map.GetAverageZ(m_Loc.X, m_Loc.Y);
if (Map.CanSpawnMobile(m_Loc)) break;
m_Loc = master.Location;
}
if (!Deleted) SetLocation(m_Loc, true);
}
}
m_Loc = master.Location;
}
if (!Deleted)
SetLocation(m_Loc, true);
}
public override void OnThink()
@ -63,7 +64,7 @@ namespace Server.Mobiles
Mobile master = ControlMaster;
if (Deleted) return;
if (master == null || master.Deleted)
if (master?.Deleted != false)
{
DropPackContents();
EndRelease(null);
@ -75,7 +76,7 @@ namespace Server.Mobiles
if (m_LastHidden != master.Hidden)
Hidden = m_LastHidden = master.Hidden;
if (AIObject != null && AIObject.WalkMobileRange(master, 5, true, 1, 1))
if (AIObject?.WalkMobileRange(master, 5, true, 1, 1) == true)
{
Warmode = master.Warmode;
Combatant = master.Combatant;
@ -107,7 +108,7 @@ namespace Server.Mobiles
public virtual void EndRelease(Mobile from)
{
if (from == null || !Deleted && Controlled && from == ControlMaster && from.CheckAlive())
if (from?.CheckAlive() != false && !Deleted && Controlled && from == ControlMaster)
{
Effects.SendLocationParticles(EffectItem.Create(Location, Map, EffectItem.DefaultDuration), 0x3728, 1, 13,
2100, 3, 5042, 0);
@ -171,4 +172,4 @@ namespace Server.Mobiles
}
}
}
}
}