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

@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server.Multis;
@ -264,7 +263,7 @@ namespace Server.Items
public override void OnDoubleClick(Mobile from)
{
if (m_Tree != null && !m_Tree.Deleted)
if (m_Tree?.Deleted == false)
m_Tree.OnDoubleClick(from);
}
@ -298,4 +297,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -11,8 +11,7 @@ namespace Server.Items
{
}
public CandyCane(int itemID)
: base(itemID)
public CandyCane(int itemID) : base(itemID, 1)
{
Stackable = false;
LootType = LootType.Blessed;
@ -81,7 +80,7 @@ namespace Server.Items
{
--Eaten;
if (Eater == null || Eater.Deleted || Eaten <= 0)
if (Eater?.Deleted != false || Eaten <= 0)
{
Stop();
m_ToothAches.Remove(Eater);
@ -127,7 +126,7 @@ namespace Server.Items
[Constructible]
public GingerBreadCookie()
: base(Utility.RandomBool() ? 0x2be1 : 0x2be2)
: base(Utility.RandomBool() ? 0x2be1 : 0x2be2, 1)
{
Stackable = false;
LootType = LootType.Blessed;

View file

@ -103,24 +103,24 @@ namespace Server.Items
AddLabel(45, 15, 0, "Choose a Potted Plant:");
AddItem(45, 75, 0x11C8);
AddButton(55, 50, 0x845, 0x846, 1, GumpButtonType.Reply, 0);
AddButton(55, 50, 0x845, 0x846, 1);
AddItem(100, 75, 0x11C9);
AddButton(115, 50, 0x845, 0x846, 2, GumpButtonType.Reply, 0);
AddButton(115, 50, 0x845, 0x846, 2);
AddItem(160, 75, 0x11CA);
AddButton(175, 50, 0x845, 0x846, 3, GumpButtonType.Reply, 0);
AddButton(175, 50, 0x845, 0x846, 3);
AddItem(225, 75, 0x11CB);
AddButton(235, 50, 0x845, 0x846, 4, GumpButtonType.Reply, 0);
AddButton(235, 50, 0x845, 0x846, 4);
AddItem(280, 75, 0x11CC);
AddButton(295, 50, 0x845, 0x846, 5, GumpButtonType.Reply, 0);
AddButton(295, 50, 0x845, 0x846, 5);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Deed == null || m_Deed.Deleted)
if (m_Deed?.Deleted != false)
return;
Mobile from = sender.Mobile;
@ -150,4 +150,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -64,7 +64,7 @@ namespace Server.Items
public class Spam : Food
{
[Constructible]
public Spam() : base(0x1044)
public Spam() : base(0x1044, 1)
{
Stackable = false;
LootType = LootType.Blessed;
@ -86,4 +86,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -191,21 +191,21 @@ namespace Server.Items
AddLabel(45, 15, 0, "Select One:");
AddItem(35, 75, 0x456E);
AddButton(65, 50, 0x845, 0x846, 1, GumpButtonType.Reply, 0);
AddButton(65, 50, 0x845, 0x846, 1);
AddItem(120, 75, 0x4578);
AddButton(135, 50, 0x845, 0x846, 2, GumpButtonType.Reply, 0);
AddButton(135, 50, 0x845, 0x846, 2);
AddItem(190, 75, 0x457A);
AddButton(205, 50, 0x845, 0x846, 3, GumpButtonType.Reply, 0);
AddButton(205, 50, 0x845, 0x846, 3);
AddItem(250, 75, 0x457C);
AddButton(275, 50, 0x845, 0x846, 4, GumpButtonType.Reply, 0);
AddButton(275, 50, 0x845, 0x846, 4);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Deed == null || m_Deed.Deleted)
if (m_Deed?.Deleted != false)
return;
Mobile from = sender.Mobile;
@ -216,10 +216,12 @@ namespace Server.Items
return;
}
Item statue = null;
Item statue;
switch (info.ButtonID)
{
default:
return;
case 1:
statue = new SnowStatuePegasus();
break;
@ -234,9 +236,6 @@ namespace Server.Items
break;
}
if (statue == null)
return;
if (!from.PlaceInBackpack(statue))
{
statue.Delete();
@ -249,4 +248,4 @@ namespace Server.Items
}
}
}
}
}

View file

@ -6,7 +6,7 @@ namespace Server.Items
private string m_Title;
[Constructible]
public Snowman() : this(Utility.RandomDyedHue(), GetRandomTitle())
public Snowman() : this(Utility.RandomDyedHue())
{
}
@ -156,4 +156,4 @@ namespace Server.Items
Utility.Intern(ref m_Title);
}
}
}
}

View file

@ -43,7 +43,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(this);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
if (from.InRange(GetWorldLocation(), 1))
{
@ -101,7 +101,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(this);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
if (from.InRange(GetWorldLocation(), 3))
{
@ -129,11 +129,11 @@ namespace Server.Items
AddBackground(0, 0, 220, 170, 0x13BE);
AddBackground(10, 10, 200, 150, 0xBB8);
AddHtmlLocalized(20, 30, 180, 60, 1062839, false, false); // Do you wish to re-deed this decoration?
AddHtmlLocalized(55, 100, 160, 25, 1011011, false, false); // CONTINUE
AddButton(20, 100, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(55, 125, 160, 25, 1011012, false, false); // CANCEL
AddButton(20, 125, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0);
AddHtmlLocalized(20, 30, 180, 60, 1062839); // Do you wish to re-deed this decoration?
AddHtmlLocalized(55, 100, 160, 25, 1011011); // CONTINUE
AddButton(20, 100, 0xFA5, 0xFA7, 1);
AddHtmlLocalized(55, 125, 160, 25, 1011012); // CANCEL
AddButton(20, 125, 0xFA5, 0xFA7, 0);
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -199,7 +199,7 @@ namespace Server.Items
{
BaseHouse house = BaseHouse.FindHouseAt(from);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
from.SendLocalizedMessage(1062838); // Where would you like to place this decoration?
from.BeginTarget(-1, true, TargetFlags.None, Placement_OnTarget);
@ -224,7 +224,7 @@ namespace Server.Items
BaseHouse house = BaseHouse.FindHouseAt(loc, from.Map, 16);
if (house != null && house.IsCoOwner(from))
if (house?.IsCoOwner(from) == true)
{
bool northWall = BaseAddon.IsWall(loc.X, loc.Y - 1, loc.Z, from.Map);
bool westWall = BaseAddon.IsWall(loc.X - 1, loc.Y, loc.Z, from.Map);
@ -292,8 +292,8 @@ namespace Server.Items
AddItem(90, 30, 0x232D);
AddItem(180, 30, 0x232C);
AddButton(50, 35, 0x868, 0x869, 1, GumpButtonType.Reply, 0);
AddButton(145, 35, 0x868, 0x869, 2, GumpButtonType.Reply, 0);
AddButton(50, 35, 0x868, 0x869, 1);
AddButton(145, 35, 0x868, 0x869, 2);
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -313,4 +313,4 @@ namespace Server.Items
}
}
}
}
}