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

@ -78,8 +78,8 @@ namespace Server.Spells.Third
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile)
m_Owner.Target((Mobile)o);
if (o is Mobile mobile)
m_Owner.Target(mobile);
}
protected override void OnTargetFinish(Mobile from)

View file

@ -72,8 +72,8 @@ namespace Server.Spells.Third
protected override void OnTarget(Mobile from, object o)
{
if (o is LockableContainer)
m_Owner.Target((LockableContainer)o);
if (o is LockableContainer container)
m_Owner.Target(container);
else
from.SendLocalizedMessage(501762); // Target must be an unlocked chest.
}

View file

@ -75,17 +75,15 @@ namespace Server.Spells.Third
double total = Caster.Skills[SkillName.Magery].Value;
if (Caster is PlayerMobile)
if (Caster is PlayerMobile pm)
{
PlayerMobile pm = (PlayerMobile)Caster;
if (pm.DuelContext != null && pm.DuelContext.Started && !pm.DuelContext.Finished &&
!pm.DuelContext.Ruleset.GetOption("Skills", "Poisoning"))
{
}
else
{
total += Caster.Skills[SkillName.Poisoning].Value;
total += pm.Skills[SkillName.Poisoning].Value;
}
}
else
@ -133,7 +131,7 @@ namespace Server.Spells.Third
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile) m_Owner.Target((Mobile)o);
if (o is Mobile mobile) m_Owner.Target(mobile);
}
protected override void OnTargetFinish(Mobile from)

View file

@ -55,7 +55,7 @@ namespace Server.Spells.Third
{
item.OnSnoop(Caster);
}
else if (item is Corpse && !((Corpse)item).CheckLoot(Caster, null))
else if (item is Corpse corpse && !corpse.CheckLoot(Caster, null))
{
}
else if (Caster.Region.OnDoubleClick(Caster, item))
@ -82,10 +82,10 @@ namespace Server.Spells.Third
protected override void OnTarget(Mobile from, object o)
{
if (o is ITelekinesisable)
m_Owner.Target((ITelekinesisable)o);
else if (o is Container)
m_Owner.Target((Container)o);
if (o is ITelekinesisable telekinesisable)
m_Owner.Target(telekinesisable);
else if (o is Container container)
m_Owner.Target(container);
else
from.SendLocalizedMessage(501857); // This spell won't work on that!
}

View file

@ -130,9 +130,7 @@ namespace Server.Spells.Third
protected override void OnTarget(Mobile from, object o)
{
IPoint3D p = o as IPoint3D;
if (p != null)
if (o is IPoint3D p)
m_Owner.Target(p);
}

View file

@ -37,9 +37,7 @@ namespace Server.Spells.Third
protected override void OnTarget(Mobile from, object o)
{
IPoint3D loc = o as IPoint3D;
if (loc == null)
if (!(o is IPoint3D loc))
return;
if (m_Owner.CheckSequence())
@ -81,7 +79,7 @@ namespace Server.Spells.Third
int level = (int)(from.Skills[SkillName.Magery].Value * 0.8) - 4;
if (level >= cont.RequiredSkill &&
!(cont is TreasureMapChest && ((TreasureMapChest)cont).Level > 2))
!(cont is TreasureMapChest chest && chest.Level > 2))
{
cont.Locked = false;

View file

@ -156,11 +156,9 @@ namespace Server.Spells.Third
public override bool OnMoveOver(Mobile m)
{
int noto;
if (m is PlayerMobile)
{
noto = Notoriety.Compute(m_Caster, m);
int noto = Notoriety.Compute(m_Caster, m);
if (noto == Notoriety.Enemy || noto == Notoriety.Ally)
return false;
}
@ -203,8 +201,8 @@ namespace Server.Spells.Third
protected override void OnTarget(Mobile from, object o)
{
if (o is IPoint3D)
m_Owner.Target((IPoint3D)o);
if (o is IPoint3D d)
m_Owner.Target(d);
}
protected override void OnTargetFinish(Mobile from)