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

@ -26,14 +26,8 @@ namespace Server.Mobiles
{
Item = item;
Price = price;
if (description != null)
m_Description = description;
else
m_Description = "";
m_Description = description ?? "";
Created = created;
Valid = true;
}
@ -57,10 +51,7 @@ namespace Server.Mobiles
get => m_Description;
set
{
if (value != null)
m_Description = value;
else
m_Description = "";
m_Description = value ?? "";
if (Valid)
Item.InvalidateProperties();
@ -111,7 +102,7 @@ namespace Server.Mobiles
{
BaseHouse house = vendor.House;
if (house != null && house.IsAosRules && !house.CheckAosStorage(1 + item.TotalItems + plusItems))
if (house?.IsAosRules == true && !house.CheckAosStorage(1 + item.TotalItems + plusItems))
{
if (message)
m.SendLocalizedMessage(1061839); // This action would exceed the secure storage limit of the house.
@ -142,13 +133,9 @@ namespace Server.Mobiles
public override bool CheckTarget(Mobile from, Target targ, object targeted)
{
if (!base.CheckTarget(from, targ, targeted))
return false;
if (from.AccessLevel >= AccessLevel.GameMaster)
return true;
return targ.GetType().IsDefined(typeof(PlayerVendorTargetAttribute), false);
return base.CheckTarget(from, targ, targeted) &&
(from.AccessLevel >= AccessLevel.GameMaster ||
targ.GetType().IsDefined(typeof(PlayerVendorTargetAttribute), false));
}
public override void GetChildContextMenuEntries(Mobile from, List<ContextMenuEntry> list, Item item)
@ -317,10 +304,7 @@ namespace Server.Mobiles
get => m_ShopName;
set
{
if (value == null)
m_ShopName = "";
else
m_ShopName = value;
m_ShopName = value ?? "";
InvalidateProperties();
}
@ -515,7 +499,7 @@ namespace Server.Mobiles
{
FixDresswear();
if (House != null && !House.IsOwner(Owner))
if (House?.IsOwner(Owner) == false)
Destroy(false);
}
@ -604,7 +588,7 @@ namespace Server.Mobiles
if (list.Count > 0 || HoldGold > 0) // No case 1
{
if ((!toBackpack || Map == Map.Internal) && House != null && House.IsAosRules) // Case 2
if ((!toBackpack || Map == Map.Internal) && House?.IsAosRules == true) // Case 2
{
if (House.IsOwner(Owner)) // Move to moving crate
{
@ -844,7 +828,7 @@ namespace Server.Mobiles
bool newItem = GetVendorItem(item) == null;
if (Backpack != null && Backpack.TryDropItem(from, item, false))
if (Backpack?.TryDropItem(from, item, false) == true)
{
if (newItem)
OnItemGiven(from, item);
@ -918,7 +902,7 @@ namespace Server.Mobiles
if (ownerOnly)
return IsOwner(from);
if (House != null && House.IsBanned(from) && !IsOwner(from))
if (House?.IsBanned(from) == true && !IsOwner(from))
{
from.SendLocalizedMessage(
1062674); // You can't shop from this home as you have been banned from this establishment.
@ -1051,7 +1035,7 @@ namespace Server.Mobiles
{
Container pack = Backpack;
if (pack != null && pack.Items.Count > 0)
if (pack?.Items.Count > 0)
{
SayTo(from, 1038325); // You cannot dismiss me while I am holding your goods.
return;
@ -1156,7 +1140,7 @@ namespace Server.Mobiles
}
else if (e.HasKeyword(0x3D) || e.HasKeyword(0x172) && WasNamed(e.Speech)) // vendor browse, *browse
{
if (House != null && House.IsBanned(from) && !IsOwner(from))
if (House?.IsBanned(from) == true && !IsOwner(from))
{
SayTo(from, 1062674); // You can't shop from this home as you have been banned from this establishment.
}
@ -1553,7 +1537,7 @@ namespace Server.Mobiles
public override void OnDelete()
{
if (Vendor != null && !Vendor.Deleted)
if (Vendor?.Deleted == false)
{
Vendor.MoveToWorld(Location, Map);
Vendor.Placeholder = null;