Fixes random NPEs (#378)

This commit is contained in:
Kamron Batman 2021-01-01 02:16:23 -08:00 committed by GitHub
parent 582e1877b8
commit cc91fe2b10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 14 deletions

View file

@ -298,8 +298,11 @@ namespace Server.Mobiles
if (pet?.Deleted != false)
{
pet.IsStabled = false;
pet.StabledBy = null;
if (pet != null)
{
pet.IsStabled = false;
pet.StabledBy = null;
}
from.Stabled.RemoveAt(i);
--i;
continue;

View file

@ -80,7 +80,7 @@ namespace Server.Items
{
if (m_Boat?.Contains(from) != true)
{
m_Boat.TillerMan?.Say(502490); // You must be on the ship to open the hold.
m_Boat?.TillerMan?.Say(502490); // You must be on the ship to open the hold.
}
else if (m_Boat.IsMoving)
{

View file

@ -18,10 +18,9 @@ namespace Server.Spells.Bushido
public override bool Validate(Mobile from)
{
var isValid = base.Validate(from);
if (isValid)
if (isValid && from is PlayerMobile pm)
{
var ThePlayer = from as PlayerMobile;
ThePlayer.ExecutesLightningStrike = BaseMana;
pm.ExecutesLightningStrike = BaseMana;
}
return isValid;
@ -57,10 +56,10 @@ namespace Server.Spells.Bushido
public override void OnClearMove(Mobile attacker)
{
var
ThePlayer =
attacker as PlayerMobile; // this can be deletet if the PlayerMobile parts are moved to Server.Mobile
ThePlayer.ExecutesLightningStrike = 0;
if (attacker is PlayerMobile pm)
{
pm.ExecutesLightningStrike = 0;
}
}
}
}

View file

@ -289,7 +289,11 @@ namespace Server.Spells.Fourth
while (m_Queue.Count > 0)
{
var m = (Mobile)m_Queue.Dequeue();
var m = m_Queue.Dequeue() as Mobile;
if (m == null)
{
continue;
}
if (SpellHelper.CanRevealCaster(m))
{

View file

@ -39,9 +39,7 @@ namespace Server.Spells.Ninjitsu
var from = Caster.Location;
var to = new Point3D(p);
var pm = Caster as PlayerMobile; // IsStealthing should be moved to Server.Mobiles
if (!pm.IsStealthing)
if ((Caster as PlayerMobile)?.IsStealthing != true)
{
Caster.SendLocalizedMessage(1063087); // You must be in stealth mode to use this ability.
}