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 HangingSkeleton() : this(0x1596)
{
}
[Constructible]
public HangingSkeleton(int itemID) : base(itemID)
public HangingSkeleton(int itemID = 0x1596) : base(itemID)
{
LootType = LootType.Blessed;
Movable = false;
@ -86,7 +81,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, 1049783)); // Do you wish to re-deed this decoration?
@ -160,14 +155,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.CloseGump<InternalGump>();
from.SendGump(new InternalGump(this));
@ -231,34 +226,29 @@ namespace Server.Items
AddPage(1);
AddItem(130, 70, 0x1A03);
AddButton(150, 50, 0x845, 0x846, 0x1A03, GumpButtonType.Reply, 0);
AddButton(150, 50, 0x845, 0x846, 0x1A03);
AddItem(190, 70, 0x1A05);
AddButton(210, 50, 0x845, 0x846, 0x1A05, GumpButtonType.Reply, 0);
AddButton(210, 50, 0x845, 0x846, 0x1A05);
AddItem(250, 70, 0x1A09);
AddButton(270, 50, 0x845, 0x846, 0x1A09, GumpButtonType.Reply, 0);
AddButton(270, 50, 0x845, 0x846, 0x1A09);
AddItem(310, 70, 0x1B1E);
AddButton(330, 50, 0x845, 0x846, 0x1B1E, GumpButtonType.Reply, 0);
AddButton(330, 50, 0x845, 0x846, 0x1B1E);
AddItem(370, 70, 0x1B7F);
AddButton(390, 50, 0x845, 0x846, 0x1B7F, GumpButtonType.Reply, 0);
AddButton(390, 50, 0x845, 0x846, 0x1B7F);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if ((m_Skeleton == null) | m_Skeleton.Deleted)
if (m_Skeleton?.Deleted != false || info.ButtonID != 0x1A03 && info.ButtonID != 0x1A05 &&
info.ButtonID != 0x1A09 && info.ButtonID != 0x1B1E && info.ButtonID != 0x1B7F)
return;
Mobile m = sender.Mobile;
if (info.ButtonID == 0x1A03 || info.ButtonID == 0x1A05 || info.ButtonID == 0x1A09 ||
info.ButtonID == 0x1B1E || info.ButtonID == 0x1B7F)
{
m.SendLocalizedMessage(1049780); // Where would you like to place this decoration?
m.Target = new InternalTarget(m_Skeleton, info.ButtonID);
}
sender.Mobile.SendLocalizedMessage(1049780); // Where would you like to place this decoration?
sender.Mobile.Target = new InternalTarget(m_Skeleton, info.ButtonID);
}
}
@ -275,72 +265,68 @@ namespace Server.Items
protected override void OnTarget(Mobile from, object targeted)
{
if (m_Skeleton == null || m_Skeleton.Deleted)
if (m_Skeleton?.Deleted != false)
return;
if (m_Skeleton.IsChildOf(from.Backpack))
if (!m_Skeleton.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(502092); // You must be in your house to do this.
return;
}
Point3D p3d = new Point3D(p);
ItemData id = TileData.ItemTable[m_ItemID & TileData.MaxItemValue];
IPoint3D p = targeted as IPoint3D;
Map map = from.Map;
if (map.CanFit(p3d, id.Height))
{
house = BaseHouse.FindHouseAt(p3d, map, id.Height);
if (p == null || map == null)
return;
if (house != null && house.IsOwner(from))
{
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[m_ItemID & TileData.MaxItemValue];
if (north && west)
{
from.CloseGump<FacingGump>();
from.SendGump(new FacingGump(m_Skeleton, m_ItemID, p3d, house));
}
else if (north || west)
{
HangingSkeleton banner = new HangingSkeleton(west ? GetWestItemID(m_ItemID) : m_ItemID);
if (!map.CanFit(p3d, id.Height))
{
from.SendLocalizedMessage(500269); // You cannot build that there.
return;
}
house.Addons.Add(banner);
house = BaseHouse.FindHouseAt(p3d, map, id.Height);
banner.IsRewardItem = m_Skeleton.IsRewardItem;
banner.MoveToWorld(p3d, map);
if (house?.IsOwner(from) != true)
{
from.SendLocalizedMessage(1042036); // That location is not in your house.
return;
}
m_Skeleton.Delete();
}
else
{
from.SendLocalizedMessage(1042039); // The banner must be placed next to a wall.
}
}
else
{
from.SendLocalizedMessage(1042036); // That location is not in your house.
}
}
else
{
from.SendLocalizedMessage(500269); // You cannot build that there.
}
}
else
{
from.SendLocalizedMessage(502092); // You must be in your house to do this.
}
bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map);
bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map);
if (north && west)
{
from.CloseGump<FacingGump>();
from.SendGump(new FacingGump(m_Skeleton, m_ItemID, p3d, house));
}
else if (north || west)
{
HangingSkeleton banner = new HangingSkeleton(west ? GetWestItemID(m_ItemID) : m_ItemID);
house.Addons.Add(banner);
banner.IsRewardItem = m_Skeleton.IsRewardItem;
banner.MoveToWorld(p3d, map);
m_Skeleton.Delete();
}
else
{
from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it.
from.SendLocalizedMessage(1042039); // The banner must be placed next to a wall.
}
}
@ -370,13 +356,13 @@ namespace Server.Items
AddItem(90, 30, GetWestItemID(itemID));
AddItem(180, 30, itemID);
AddButton(50, 35, 0x868, 0x869, (int)Buttons.East, GumpButtonType.Reply, 0);
AddButton(145, 35, 0x868, 0x869, (int)Buttons.South, GumpButtonType.Reply, 0);
AddButton(50, 35, 0x868, 0x869, (int)Buttons.East);
AddButton(145, 35, 0x868, 0x869, (int)Buttons.South);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Skeleton == null || m_Skeleton.Deleted || m_House == null)
if (m_Skeleton?.Deleted != false || m_House == null)
return;
HangingSkeleton banner = null;
@ -406,4 +392,4 @@ namespace Server.Items
}
}
}
}
}