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

@ -24,14 +24,9 @@ namespace Server.Items
};
[Constructible]
public LightOfTheWinterSolstice() : this(m_StaffNames[Utility.Random(m_StaffNames.Length)])
public LightOfTheWinterSolstice(string dipper = null) : base(0x236E)
{
}
[Constructible]
public LightOfTheWinterSolstice(string dipper) : base(0x236E)
{
Dipper = dipper;
Dipper = dipper ?? m_StaffNames[Utility.Random(m_StaffNames.Length)];
Weight = 1.0;
LootType = LootType.Blessed;
@ -95,4 +90,4 @@ namespace Server.Items
Dipper = string.Intern(Dipper);
}
}
}
}

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,29 +129,26 @@ 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)
{
if (m_Addon.Deleted)
if (m_Addon.Deleted || info.ButtonID != 1)
return;
if (info.ButtonID == 1)
if (m_From.InRange(m_Addon.GetWorldLocation(), 3))
{
if (m_From.InRange(m_Addon.GetWorldLocation(), 3))
{
m_From.AddToBackpack(m_Addon.Deed);
m_Addon.Delete();
}
else
{
m_From.SendLocalizedMessage(500295); // You are too far away to do that.
}
m_From.AddToBackpack(m_Addon.Deed);
m_Addon.Delete();
}
else
{
m_From.SendLocalizedMessage(500295); // You are too far away to do that.
}
}
}
@ -161,12 +158,7 @@ namespace Server.Items
public class MistletoeDeed : Item
{
[Constructible]
public MistletoeDeed() : this(0)
{
}
[Constructible]
public MistletoeDeed(int hue) : base(0x14F0)
public MistletoeDeed(int hue = 0) : base(0x14F0)
{
Hue = hue;
Weight = 1.0;
@ -213,7 +205,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);
@ -238,7 +230,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);
@ -306,8 +298,8 @@ namespace Server.Items
AddItem(90, 30, 0x2375);
AddItem(180, 30, 0x2374);
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)
@ -327,4 +319,4 @@ namespace Server.Items
}
}
}
}
}