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

@ -176,14 +176,10 @@ namespace Server.Items
public virtual bool HasAccess(Mobile from)
{
if (from == null || from.Deleted)
return false;
if (from.AccessLevel >= AccessLevel.GameMaster)
return true;
BaseHouse house = BaseHouse.FindHouseAt(this);
return house != null && house.IsCoOwner(from);
return from?.Deleted == false && (
from.AccessLevel >= AccessLevel.GameMaster ||
BaseHouse.FindHouseAt(this)?.IsCoOwner(from) == true
);
}
public override bool OnDragDrop(Mobile from, Item dropped)
@ -1020,7 +1016,7 @@ namespace Server.Items
{
private Aquarium m_Aquarium;
public GMAddFood(Aquarium aquarium) : base(6231, -1) // GM Add Food
public GMAddFood(Aquarium aquarium) : base(6231) // GM Add Food
{
m_Aquarium = aquarium;
}
@ -1039,7 +1035,7 @@ namespace Server.Items
{
private Aquarium m_Aquarium;
public GMAddWater(Aquarium aquarium) : base(6232, -1) // GM Add Water
public GMAddWater(Aquarium aquarium) : base(6232) // GM Add Water
{
m_Aquarium = aquarium;
}
@ -1058,7 +1054,7 @@ namespace Server.Items
{
private Aquarium m_Aquarium;
public GMForceEvaluate(Aquarium aquarium) : base(6233, -1) // GM Force Evaluate
public GMForceEvaluate(Aquarium aquarium) : base(6233) // GM Force Evaluate
{
m_Aquarium = aquarium;
}
@ -1076,7 +1072,7 @@ namespace Server.Items
{
private Aquarium m_Aquarium;
public GMOpen(Aquarium aquarium) : base(6234, -1) // GM Open Container
public GMOpen(Aquarium aquarium) : base(6234) // GM Open Container
{
m_Aquarium = aquarium;
}
@ -1094,7 +1090,7 @@ namespace Server.Items
{
private Aquarium m_Aquarium;
public GMFill(Aquarium aquarium) : base(6236, -1) // GM Fill Food and Water
public GMFill(Aquarium aquarium) : base(6236) // GM Fill Food and Water
{
m_Aquarium = aquarium;
}
@ -1170,4 +1166,4 @@ namespace Server.Items
int version = reader.ReadInt();
}
}
}
}

View file

@ -35,46 +35,46 @@ namespace Server.Items
// item name
if (item.LabelNumber != 0)
AddHtmlLocalized(20, 217, 250, 20, item.LabelNumber, 0xFFFFFF, false, false); // Name
AddHtmlLocalized(20, 217, 250, 20, item.LabelNumber, 0xFFFFFF); // Name
// item details
if (item is BaseFish fish)
AddHtmlLocalized(20, 239, 315, 20, fish.GetDescription(), 0xFFFFFF, false, false);
AddHtmlLocalized(20, 239, 315, 20, fish.GetDescription(), 0xFFFFFF);
else
AddHtmlLocalized(20, 239, 315, 20, 1073634, 0xFFFFFF, false, false); // An aquarium decoration
AddHtmlLocalized(20, 239, 315, 20, 1073634, 0xFFFFFF); // An aquarium decoration
// item image
AddItem(150, 80, item.ItemID, item.Hue);
// item number / all items
AddHtml(20, 195, 250, 20, $"<BASEFONT COLOR=#FFFFFF>{page}/{m_Aquarium.Items.Count}</BASEFONT>", false, false);
AddHtml(20, 195, 250, 20, $"<BASEFONT COLOR=#FFFFFF>{page}/{m_Aquarium.Items.Count}</BASEFONT>");
// remove item
if (edit)
{
AddBackground(230, 195, 100, 26, 0x13BE);
AddButton(235, 200, 0x845, 0x846, page, GumpButtonType.Reply, 0);
AddHtmlLocalized(260, 198, 60, 26, 1073838, 0x0, false, false); // Remove
AddButton(235, 200, 0x845, 0x846, page);
AddHtmlLocalized(260, 198, 60, 26, 1073838, 0x0); // Remove
}
// next page
if (page < m_Aquarium.Items.Count)
{
AddButton(195, 280, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page + 1);
AddHtmlLocalized(230, 283, 100, 18, 1044045, 0xFFFFFF, false, false); // NEXT PAGE
AddHtmlLocalized(230, 283, 100, 18, 1044045, 0xFFFFFF); // NEXT PAGE
}
// previous page
if (page > 1)
{
AddButton(45, 280, 0xFAE, 0xFAF, 0, GumpButtonType.Page, page - 1);
AddHtmlLocalized(80, 283, 100, 18, 1044044, 0xFFFFFF, false, false); // PREV PAGE
AddHtmlLocalized(80, 283, 100, 18, 1044044, 0xFFFFFF); // PREV PAGE
}
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Aquarium == null || m_Aquarium.Deleted)
if (m_Aquarium?.Deleted != false)
return;
bool edit = m_Aquarium.HasAccess(sender.Mobile);
@ -86,4 +86,4 @@ namespace Server.Items
sender.Mobile.SendGump(new AquariumGump(m_Aquarium, edit));
}
}
}
}

View file

@ -142,29 +142,29 @@ namespace Server.Items
public override void OnClick()
{
if (m_Bowl == null || m_Bowl.Deleted || !m_Bowl.IsAccessibleTo(Owner.From))
if (m_Bowl?.Deleted != false || !m_Bowl.IsAccessibleTo(Owner.From))
return;
BaseFish fish = m_Bowl.Fish;
if (fish != null)
if (fish == null)
return;
if (fish.IsLockedDown) // for legacy fish bowls
{
if (fish.IsLockedDown) // for legacy fish bowls
{
Owner.From.SendLocalizedMessage(1010449); // You may not use this object while it is locked down.
}
else if (!Owner.From.PlaceInBackpack(fish))
{
Owner.From.SendLocalizedMessage(1074496); // There is no room in your pack for the creature.
}
else
{
Owner.From.SendLocalizedMessage(1074495); // The creature has been removed from the fish bowl.
fish.StartTimer();
m_Bowl.InvalidateProperties();
}
Owner.From.SendLocalizedMessage(1010449); // You may not use this object while it is locked down.
}
else if (!Owner.From.PlaceInBackpack(fish))
{
Owner.From.SendLocalizedMessage(1074496); // There is no room in your pack for the creature.
}
else
{
Owner.From.SendLocalizedMessage(1074495); // The creature has been removed from the fish bowl.
fish.StartTimer();
m_Bowl.InvalidateProperties();
}
}
}
}
}
}