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

@ -31,11 +31,7 @@ namespace Server.Items
protected CraftResource m_Resource;
private int m_StrReq = -1;
public BaseClothing(int itemID, Layer layer) : this(itemID, layer, 0)
{
}
public BaseClothing(int itemID, Layer layer, int hue) : base(itemID)
public BaseClothing(int itemID, Layer layer, int hue = 0) : base(itemID)
{
Layer = layer;
Hue = hue;
@ -172,7 +168,7 @@ namespace Server.Items
CraftContext context = craftSystem.GetContext(from);
if (context != null && context.DoNotColor)
if (context?.DoNotColor == true)
Hue = 0;
return quality;
@ -210,18 +206,12 @@ namespace Server.Items
CraftItem item = system.CraftItems.SearchFor(GetType());
if (item != null && item.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2)
if (item?.Resources.Count == 1 && item.Resources.GetAt(0).Amount >= 2)
try
{
Type resourceType = null;
CraftResourceInfo info = CraftResources.GetInfo(m_Resource);
if (info != null && info.ResourceTypes.Length > 0)
resourceType = info.ResourceTypes[0];
if (resourceType == null)
resourceType = item.Resources.GetAt(0).ItemType;
Type resourceType = info.ResourceTypes?[0] ?? item.Resources.GetAt(0).ItemType;
Item res = (Item)Activator.CreateInstance(resourceType);
@ -573,12 +563,7 @@ namespace Server.Items
private string GetNameString()
{
string name = Name;
if (name == null)
name = $"#{LabelNumber}";
return name;
return Name ?? $"#{LabelNumber}";
}
public override void AddNameProperty(ObjectPropertyList list)
@ -1070,4 +1055,4 @@ namespace Server.Items
#endregion
}
}
}