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

@ -11,12 +11,7 @@ namespace Server.Items
private bool m_IsRewardItem;
[Constructible]
public FlamingHead() : this(StoneFaceTrapType.NorthWall)
{
}
[Constructible]
public FlamingHead(StoneFaceTrapType type)
public FlamingHead(StoneFaceTrapType type = StoneFaceTrapType.NorthWall)
{
LootType = LootType.Blessed;
Movable = false;
@ -82,7 +77,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(this);
if (house != null && house.IsOwner(from))
if (house?.IsOwner(from) == true)
{
from.CloseGump<RewardDemolitionGump>();
from.SendGump(new RewardDemolitionGump(this, 1018329)); // Do you wish to re-deed this skull?
@ -156,14 +151,14 @@ namespace Server.Items
public override void OnDoubleClick(Mobile from)
{
if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this, null))
if (m_IsRewardItem && !RewardSystem.CheckIsUsableBy(from, this))
return;
if (IsChildOf(from.Backpack))
{
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house != null && house.IsOwner(from))
if (house?.IsOwner(from) == true)
{
from.SendLocalizedMessage(1042264); // Where would you like to place this head?
from.Target = new InternalTarget(this);
@ -208,76 +203,72 @@ namespace Server.Items
protected override void OnTarget(Mobile from, object targeted)
{
if (m_Head == null || m_Head.Deleted)
if (m_Head?.Deleted != false)
return;
if (m_Head.IsChildOf(from.Backpack))
if (!m_Head.IsChildOf(from.Backpack))
{
BaseHouse house = BaseHouse.FindHouseAt(from);
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it.
return;
}
if (house != null && house.IsOwner(from))
{
IPoint3D p = targeted as IPoint3D;
Map map = from.Map;
BaseHouse house = BaseHouse.FindHouseAt(from);
if (p == null || map == null)
return;
if (house?.IsOwner(from) != true)
{
from.SendLocalizedMessage(502115); // You must be in your house to do this.
return;
}
Point3D p3d = new Point3D(p);
ItemData id = TileData.ItemTable[0x10F5];
IPoint3D p = targeted as IPoint3D;
Map map = from.Map;
house = BaseHouse.FindHouseAt(p3d, map, id.Height);
if (p == null || map == null)
return;
if (house != null && house.IsOwner(from))
{
if (map.CanFit(p3d, id.Height))
{
bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map);
bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map);
Point3D p3d = new Point3D(p);
ItemData id = TileData.ItemTable[0x10F5];
FlamingHead head = null;
house = BaseHouse.FindHouseAt(p3d, map, id.Height);
if (north && west)
head = new FlamingHead(StoneFaceTrapType.NorthWestWall);
else if (north)
head = new FlamingHead(StoneFaceTrapType.NorthWall);
else if (west)
head = new FlamingHead(StoneFaceTrapType.WestWall);
if (house?.IsOwner(from) != true)
{
from.SendLocalizedMessage(1042036); // That location is not in your house.
return;
}
if (north || west)
{
house.Addons.Add(head);
if (!map.CanFit(p3d, id.Height))
{
from.SendLocalizedMessage(1042266); // The head must be placed next to a wall.
return;
}
head.IsRewardItem = m_Head.IsRewardItem;
head.MoveToWorld(p3d, map);
bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map);
bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map);
m_Head.Delete();
}
else
{
from.SendLocalizedMessage(1042266); // The head must be placed next to a wall.
}
}
else
{
from.SendLocalizedMessage(1042266); // The head must be placed next to a wall.
}
}
else
{
from.SendLocalizedMessage(1042036); // That location is not in your house.
}
}
else
{
from.SendLocalizedMessage(502115); // You must be in your house to do this.
}
FlamingHead head = null;
if (north && west)
head = new FlamingHead(StoneFaceTrapType.NorthWestWall);
else if (north)
head = new FlamingHead();
else if (west)
head = new FlamingHead(StoneFaceTrapType.WestWall);
if (north || west)
{
house.Addons.Add(head);
head.IsRewardItem = m_Head.IsRewardItem;
head.MoveToWorld(p3d, map);
m_Head.Delete();
}
else
{
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it.
from.SendLocalizedMessage(1042266); // The head must be placed next to a wall.
}
}
}
}
}
}