Fixes bad expressions, bad bool checks in loops, a few null pointer exceptions, and optimizes constructors.

This commit is contained in:
Kamron Batman 2018-09-15 23:16:45 -07:00
parent 8da55d6043
commit f93c3b992e
62 changed files with 318 additions and 634 deletions

View file

@ -150,12 +150,7 @@ namespace Server.Mobiles
m_Mobile.UseSkill(SkillName.SpiritSpeak);
}
else
{
spell = new GreaterHealSpell(m_Mobile, null);
if (spell == null)
spell = new HealSpell(m_Mobile, null);
}
}
else if (m_Mobile.Hits < m_Mobile.HitsMax - 10)
{
@ -933,7 +928,7 @@ namespace Server.Mobiles
{
double prio = m_Mobile.GetDistanceToSqrt(m);
if (!activeOnly && (inactive == null || prio < inactPrio))
if (inactive == null || prio < inactPrio)
{
inactive = m;
inactPrio = prio;

View file

@ -96,7 +96,7 @@ namespace Server.Mobiles
UnmountMe();
RemoveFollowers();
m_Rider = value;
m_Rider = null;
}
else
{

View file

@ -154,7 +154,7 @@ namespace Server.Mobiles
{
object[] objs = t.GetCustomAttributes(typeof(FriendlyNameAttribute), false);
if (objs != null && objs.Length > 0)
if (objs.Length > 0)
{
FriendlyNameAttribute friendly = objs[0] as FriendlyNameAttribute;

View file

@ -55,7 +55,7 @@ namespace Server.Mobiles
public override void OnDamage(int amount, Mobile from, bool willKill)
{
if (from != null && !willKill && amount > 3 && from != null && !InRange(from, 7))
if (from != null && !willKill && amount > 3 && !InRange(from, 7))
{
MovingEffect(from, 0xF51, 10, 0, false, false);
SpellHelper.Damage(TimeSpan.FromSeconds(1.0), from, this, Utility.RandomMinMax(30, 40) - (Core.AOS ? 0 : 10),

View file

@ -292,11 +292,7 @@ namespace Server.Mobiles
{
private PlagueBeastLord m_Lord;
public DecayTimer(PlagueBeastLord lord) : this(lord, 0, 120)
{
}
public DecayTimer(PlagueBeastLord lord, int count, int deadline) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1))
public DecayTimer(PlagueBeastLord lord, int count = 0, int deadline = 120) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1))
{
m_Lord = lord;
Count = count;

View file

@ -571,7 +571,7 @@ namespace Server.Mobiles
private static bool CheckBlock(MountBlock block)
{
return block is MountBlock && block.m_Timer.Running;
return block?.m_Timer.Running == true;
}
public void SetMountBlock(BlockMountType type, TimeSpan duration, bool dismount)
@ -640,9 +640,7 @@ namespace Server.Mobiles
if (ns == null)
return;
int global, personal;
ComputeLightLevels(out global, out personal);
ComputeLightLevels(out int global, out int personal);
if (!forceResend)
forceResend = global != m_LastGlobalLight || personal != m_LastPersonalLight;