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

@ -115,7 +115,7 @@ namespace Server.Mobiles
public override void OnDamagedBySpell(Mobile from)
{
if (from != null && from.Alive && 0.4 > Utility.RandomDouble()) SendEBolt(from);
if (from?.Alive == true && 0.4 > Utility.RandomDouble()) SendEBolt(from);
if (!FieldActive)
{
@ -144,7 +144,7 @@ namespace Server.Mobiles
attacker.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier");
}
if (attacker != null && attacker.Alive && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble())
if (attacker?.Alive == true && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble())
SendEBolt(attacker);
}
@ -192,4 +192,4 @@ namespace Server.Mobiles
Name = null;
}
}
}
}

View file

@ -105,7 +105,7 @@ namespace Server.Mobiles
public override void OnDamagedBySpell(Mobile from)
{
if (from != null && from.Alive && 0.4 > Utility.RandomDouble()) SendEBolt(from);
if (from?.Alive == true && 0.4 > Utility.RandomDouble()) SendEBolt(from);
if (!FieldActive)
{
@ -134,7 +134,7 @@ namespace Server.Mobiles
attacker.SendAsciiMessage("Your weapon cannot penetrate the creature's magical barrier");
}
if (attacker != null && attacker.Alive && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble())
if (attacker?.Alive == true && attacker.Weapon is BaseRanged && 0.4 > Utility.RandomDouble())
SendEBolt(attacker);
}
@ -182,4 +182,4 @@ namespace Server.Mobiles
Name = null;
}
}
}
}

View file

@ -74,7 +74,7 @@ namespace Server.Mobiles
public override void OnDamage(int amount, Mobile from, bool willKill)
{
if (from != null && !willKill && amount > 5 && from.Player && 5 > Utility.Random(100))
if (!willKill && amount > 5 && from?.Player == true && 5 > Utility.Random(100))
{
string[] toSay =
{
@ -122,4 +122,4 @@ namespace Server.Mobiles
int version = reader.ReadInt();
}
}
}
}

View file

@ -217,7 +217,7 @@ namespace Server.Mobiles
public override void OnThink()
{
if (SummonMaster == null || SummonMaster.Deleted)
if (SummonMaster?.Deleted != false)
{
Delete();
}
@ -252,10 +252,7 @@ namespace Server.Mobiles
private bool Combat(Mobile mobile)
{
Mobile combatant = mobile.Combatant;
if (combatant == null || combatant.Deleted || combatant.IsDeadBondedPet || !combatant.Alive)
return false;
return true;
return combatant?.Deleted == false && !combatant.IsDeadBondedPet && combatant.Alive;
}
public override void OnSingleClick(Mobile from)
@ -282,4 +279,4 @@ namespace Server.Mobiles
int version = reader.ReadInt();
}
}
}
}

View file

@ -1,7 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Server.Items;
using Server.Spells;

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@ -95,9 +94,7 @@ namespace Server.Mobiles
private void DoAreaLeech_Finish()
{
IPooledEnumerable<Mobile> eable = GetMobilesInRange(6);
List<Mobile> list = eable.Where(m => CanBeHarmful(m) && IsEnemy(m)).ToList();
eable.Free();
if (list.Count == 0)

View file

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Items;
using Server.Network;
@ -96,7 +95,7 @@ namespace Server.Mobiles
m_NextAbilityTime = DateTime.UtcNow + TimeSpan.FromSeconds(Utility.RandomMinMax(20, 30));
if (combatant is BaseCreature bc)
if (bc.Controlled && bc.ControlMaster != null && !bc.ControlMaster.Deleted && bc.ControlMaster.Alive)
if (bc.Controlled && bc.ControlMaster?.Deleted == false && bc.ControlMaster.Alive)
if (bc.ControlMaster.Map == Map && bc.ControlMaster.InRange(this, 12) &&
!UnderEffect(bc.ControlMaster))
Combatant = combatant = bc.ControlMaster;