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.ContextMenus;
using Server.Engines.BulkOrders;
@ -30,7 +29,7 @@ namespace Server.Mobiles
private List<IBuyItemInfo> m_ArmorBuyInfo = new List<IBuyItemInfo>();
private List<IShopSellInfo> m_ArmorSellInfo = new List<IShopSellInfo>();
public BaseVendor(string title)
public BaseVendor(string title = null)
: base(AIType.AI_Vendor, FightMode.None, 2, 1, 0.5, 2)
{
LoadSBInfo();
@ -219,9 +218,7 @@ namespace Server.Mobiles
buyer.PlaySound(0x32);
cont = buyer.Backpack;
if (cont == null)
cont = buyer.BankBox;
cont = buyer.Backpack ?? buyer.BankBox;
foreach (BuyItemResponse buy in validBuy)
{

View file

@ -225,7 +225,7 @@ namespace Server.Mobiles
{
get
{
if (m_Cache == null || m_Cache.Deleted)
if (m_Cache?.Deleted != false)
m_Cache = new DisplayCache();
return m_Cache;

View file

@ -103,7 +103,7 @@ namespace Server.Mobiles
{
BaseCreature pet = from.Stabled[i] as BaseCreature;
if (pet == null || pet.Deleted)
if (pet?.Deleted != false)
{
pet.IsStabled = false;
pet.StabledBy = null;
@ -123,7 +123,7 @@ namespace Server.Mobiles
public void EndClaimList(Mobile from, BaseCreature pet)
{
if (pet == null || pet.Deleted || from.Map != Map || !from.Stabled.Contains(pet) || !from.CheckAlive())
if (pet?.Deleted != false || from.Map != Map || !from.Stabled.Contains(pet) || !from.CheckAlive())
return;
if (!from.InRange(this, 14))
@ -153,8 +153,8 @@ namespace Server.Mobiles
Container bank = from.FindBankNoCreate();
if ((from.Backpack == null || from.Backpack.GetAmount(typeof(Gold)) < 30) &&
(bank == null || bank.GetAmount(typeof(Gold)) < 30))
if (!(from.Backpack?.GetAmount(typeof(Gold)) >= 30) &&
!(bank?.GetAmount(typeof(Gold)) >= 30))
{
SayTo(from, 1042556); // Thou dost not have enough gold, not even in thy bank account.
}
@ -201,8 +201,7 @@ namespace Server.Mobiles
SayTo( from, 1048053 ); // You can't stable that!
}
*/
else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack != null &&
pet.Backpack.Items.Count > 0)
else if ((pet is PackLlama || pet is PackHorse || pet is Beetle) && pet.Backpack?.Items.Count > 0)
{
SayTo(from, 1042563); // You need to unload your pet.
}
@ -218,8 +217,8 @@ namespace Server.Mobiles
{
Container bank = from.FindBankNoCreate();
if (from.Backpack != null && from.Backpack.ConsumeTotal(typeof(Gold), 30) ||
bank != null && bank.ConsumeTotal(typeof(Gold), 30))
if (from.Backpack?.ConsumeTotal(typeof(Gold), 30) == true ||
bank?.ConsumeTotal(typeof(Gold), 30) == true)
{
pet.ControlTarget = null;
pet.ControlOrder = OrderType.Stay;
@ -248,12 +247,7 @@ namespace Server.Mobiles
}
}
public void Claim(Mobile from)
{
Claim(from, null);
}
public void Claim(Mobile from, string petName)
public void Claim(Mobile from, string petName = null)
{
if (Deleted || !from.CheckAlive())
return;
@ -267,7 +261,7 @@ namespace Server.Mobiles
{
BaseCreature pet = from.Stabled[i] as BaseCreature;
if (pet == null || pet.Deleted)
if (pet?.Deleted != false)
{
pet.IsStabled = false;
pet.StabledBy = null;
@ -414,18 +408,17 @@ namespace Server.Mobiles
AddBackground(0, 0, 325, 50 + list.Count * 20, 9250);
AddAlphaRegion(5, 5, 315, 40 + list.Count * 20);
AddHtml(15, 15, 275, 20, "<BASEFONT COLOR=#FFFFFF>Select a pet to retrieve from the stables:</BASEFONT>",
false, false);
AddHtml(15, 15, 275, 20, "<BASEFONT COLOR=#FFFFFF>Select a pet to retrieve from the stables:</BASEFONT>");
for (int i = 0; i < list.Count; ++i)
{
BaseCreature pet = list[i];
if (pet == null || pet.Deleted)
if (pet?.Deleted != false)
continue;
AddButton(15, 39 + i * 20, 10006, 10006, i + 1, GumpButtonType.Reply, 0);
AddHtml(32, 35 + i * 20, 275, 18, $"<BASEFONT COLOR=#C0C0EE>{pet.Name}</BASEFONT>", false, false);
AddButton(15, 39 + i * 20, 10006, 10006, i + 1);
AddHtml(32, 35 + i * 20, 275, 18, $"<BASEFONT COLOR=#C0C0EE>{pet.Name}</BASEFONT>");
}
}
@ -475,4 +468,4 @@ namespace Server.Mobiles
}
}
}
}
}

View file

@ -153,7 +153,7 @@ namespace Server.Mobiles
AddBackground(50, 10, 450, 100 + canAfford * 25, 2600);
AddHtmlLocalized(100, 40, 350, 20, 1018356, false, false); // Choose your hairstyle change:
AddHtmlLocalized(100, 40, 350, 20, 1018356); // Choose your hairstyle change:
int index = 0;
@ -161,11 +161,11 @@ namespace Server.Mobiles
if (balance >= sellList[i].Price && (!sellList[i].FacialHair || !isFemale))
{
if (sellList[i].TitleString != null)
AddHtml(140, 75 + index * 25, 300, 20, sellList[i].TitleString, false, false);
AddHtml(140, 75 + index * 25, 300, 20, sellList[i].TitleString);
else
AddHtmlLocalized(140, 75 + index * 25, 300, 20, sellList[i].Title, false, false);
AddHtmlLocalized(140, 75 + index * 25, 300, 20, sellList[i].Title);
AddButton(100, 75 + index++ * 25, 4005, 4007, 1 + i, GumpButtonType.Reply, 0);
AddButton(100, 75 + index++ * 25, 4005, 4007, 1 + i);
}
}
@ -205,6 +205,7 @@ namespace Server.Mobiles
}
catch
{
// ignored
}
else
m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState);
@ -291,10 +292,10 @@ namespace Server.Mobiles
AddBackground(100, 10, 350, 370, 2600);
AddBackground(120, 54, 110, 270, 5100);
AddHtmlLocalized(155, 25, 240, 30, 1011013, false, false); // <center>Hair Color Selection Menu</center>
AddHtmlLocalized(155, 25, 240, 30, 1011013); // <center>Hair Color Selection Menu</center>
AddHtmlLocalized(150, 330, 220, 35, 1011014, false, false); // Dye my hair this color!
AddButton(380, 330, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(150, 330, 220, 35, 1011014); // Dye my hair this color!
AddButton(380, 330, 4005, 4007, 1);
for (int i = 0; i < entries.Length; ++i)
{
@ -447,18 +448,16 @@ namespace Server.Mobiles
AddBackground(0, 0, 81 + tableWidth * offsetWidth, 105 + tableHeight * offsetHeight, 2600);
AddButton(45, 45 + tableHeight * offsetHeight, 4005, 4007, 1, GumpButtonType.Reply, 0);
AddHtmlLocalized(77, 45 + tableHeight * offsetHeight, 90, 35, 1006044, false, false); // Ok
AddButton(45, 45 + tableHeight * offsetHeight, 4005, 4007, 1);
AddHtmlLocalized(77, 45 + tableHeight * offsetHeight, 90, 35, 1006044); // Ok
AddButton(81 + tableWidth * offsetWidth - 180, 45 + tableHeight * offsetHeight, 4005, 4007, 0,
GumpButtonType.Reply, 0);
AddHtmlLocalized(81 + tableWidth * offsetWidth - 148, 45 + tableHeight * offsetHeight, 90, 35, 1006045, false,
false); // Cancel
AddButton(81 + tableWidth * offsetWidth - 180, 45 + tableHeight * offsetHeight, 4005, 4007, 0);
AddHtmlLocalized(81 + tableWidth * offsetWidth - 148, 45 + tableHeight * offsetHeight, 90, 35, 1006045); // Cancel
if (!facialHair)
AddHtmlLocalized(50, 15, 350, 20, 1018353, false, false); // <center>New Hairstyle</center>
AddHtmlLocalized(50, 15, 350, 20, 1018353); // <center>New Hairstyle</center>
else
AddHtmlLocalized(55, 15, 200, 20, 1018354, false, false); // <center>New Beard</center>
AddHtmlLocalized(55, 15, 200, 20, 1018354); // <center>New Beard</center>
for (int i = 0; i < entries.Length; ++i)
{
@ -475,13 +474,12 @@ namespace Server.Mobiles
else if (!facialHair)
{
AddRadio(40 + (xTable + 1) * offsetWidth, 240, 208, 209, false, i);
AddHtmlLocalized(60 + (xTable + 1) * offsetWidth, 240, 85, 35, 1011064, false, false); // Bald
AddHtmlLocalized(60 + (xTable + 1) * offsetWidth, 240, 85, 35, 1011064); // Bald
}
else
{
AddRadio(40 + xTable * offsetWidth, 70 + yTable * offsetHeight, 208, 209, false, i);
AddHtmlLocalized(60 + xTable * offsetWidth, 70 + yTable * offsetHeight, 85, 35, 1011064, false,
false); // Bald
AddHtmlLocalized(60 + xTable * offsetWidth, 70 + yTable * offsetHeight, 85, 35, 1011064); // Bald
}
}
}
@ -573,4 +571,4 @@ namespace Server.Mobiles
}
}
}
}
}

View file

@ -62,12 +62,12 @@ namespace Server.Mobiles
public override void OnClick()
{
if (!Core.ML || m_Vendor == null || m_Vendor.Deleted)
if (!Core.ML || m_Vendor?.Deleted != false)
return;
WeaponEngravingTool tool = WeaponEngravingTool.Find(m_From);
if (tool != null && tool.UsesRemaining <= 0)
if (tool?.UsesRemaining <= 0)
{
if (Banker.GetBalance(m_From) >= 100000)
m_From.SendGump(new WeaponEngravingTool.ConfirmGump(tool, m_Vendor));
@ -82,4 +82,4 @@ namespace Server.Mobiles
}
}
}
}
}

View file

@ -78,7 +78,7 @@ namespace Server.Mobiles
if (Banker.Deposit(from, price))
{
// For the deed I have placed gold in your bankbox :
PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008000, AffixType.Append, price.ToString(), "");
PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008000, AffixType.Append, price.ToString());
deed.Delete();
return true;
@ -104,7 +104,7 @@ namespace Server.Mobiles
if (price > 0)
{
// I will pay you gold for this deed :
PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008001, AffixType.Append, price.ToString(), "");
PublicOverheadMessage(MessageType.Regular, 0x3B2, 1008001, AffixType.Append, price.ToString());
PublicOverheadMessage(MessageType.Regular, 0x3B2,
500610); // Simply hand me the deed if you wish to sell it.

View file

@ -303,7 +303,7 @@ namespace Server.Mobiles
{
if (!(dropped is Gold g))
return false;
if (g.Amount > 50)
{
PrivateOverheadMessage(MessageType.Regular, 0x3B2, false, "I cannot accept so large a tip!",
@ -334,7 +334,7 @@ namespace Server.Mobiles
public bool IsOwner(Mobile from)
{
if (from == null || from.Deleted || Deleted)
if (from?.Deleted != false || Deleted)
return false;
if (from.AccessLevel > AccessLevel.GameMaster)
@ -604,7 +604,7 @@ namespace Server.Mobiles
new Entry("Waiter", true),
new Entry("Warrior"),
new Entry("Watchman"),
new Entry("No Title", null, false)
new Entry("No Title", null)
};
private PlayerBarkeeper m_Barkeeper;
@ -664,7 +664,7 @@ namespace Server.Mobiles
AddImage(180, 25, 10460);
AddImage(434, 25, 10460);
AddHtml(223, 32, 200, 40, "BARKEEP CUSTOMIZATION MENU", false, false);
AddHtml(223, 32, 200, 40, "BARKEEP CUSTOMIZATION MENU");
AddBackground(243, 433, 150, 30, 5054);
AddImage(240, 433, 10460);
@ -673,22 +673,22 @@ namespace Server.Mobiles
AddImage(80, 398, 2151);
AddItem(72, 406, 2543);
AddHtml(110, 412, 180, 25, "sells food and drink", false, false);
AddHtml(110, 412, 180, 25, "sells food and drink");
}
private void RenderPage(Entry[] entries, int page)
{
AddPage(1 + page);
AddHtml(430, 70, 180, 25, $"Page {page + 1} of {(entries.Length + 19) / 20}", false, false);
AddHtml(430, 70, 180, 25, $"Page {page + 1} of {(entries.Length + 19) / 20}");
for (int count = 0, i = page * 20; count < 20 && i < entries.Length; ++count, ++i)
{
Entry entry = entries[i];
AddButton(80 + count / 10 * 260, 100 + count % 10 * 30, 4005, 4007, 2 + i, GumpButtonType.Reply, 0);
AddButton(80 + count / 10 * 260, 100 + count % 10 * 30, 4005, 4007, 2 + i);
AddHtml(120 + count / 10 * 260, 100 + count % 10 * 30, entry.m_Vendor ? 148 : 180, 25, entry.m_Description,
true, false);
true);
if (entry.m_Vendor)
{
@ -698,10 +698,10 @@ namespace Server.Mobiles
}
AddButton(340, 400, 4005, 4007, 0, GumpButtonType.Page, 1 + (page + 1) % ((entries.Length + 19) / 20));
AddHtml(380, 400, 180, 25, "More Job Titles", false, false);
AddHtml(380, 400, 180, 25, "More Job Titles");
AddButton(338, 437, 4014, 4016, 1, GumpButtonType.Reply, 0);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddButton(338, 437, 4014, 4016, 1);
AddHtml(290, 440, 35, 40, "Back");
}
public override void OnResponse(NetState sender, RelayInfo info)
@ -732,15 +732,11 @@ namespace Server.Mobiles
public string m_Title;
public bool m_Vendor;
public Entry(string desc) : this(desc, $"the {desc.ToLower()}", false)
public Entry(string desc, bool vendor = false) : this(desc, $"the {desc.ToLower()}", vendor)
{
}
public Entry(string desc, bool vendor) : this(desc, $"the {desc.ToLower()}", vendor)
{
}
public Entry(string desc, string title, bool vendor)
public Entry(string desc, string title, bool vendor = false)
{
m_Description = desc;
m_Title = title;
@ -807,7 +803,7 @@ namespace Server.Mobiles
AddImage(434, 25, 10460);
AddImage(560, 20, 1417);
AddHtml(223, 32, 200, 40, "BARKEEP CUSTOMIZATION MENU", false, false);
AddHtml(223, 32, 200, 40, "BARKEEP CUSTOMIZATION MENU");
AddBackground(243, 433, 150, 30, 5054);
AddImage(240, 433, 10460);
@ -819,16 +815,16 @@ namespace Server.Mobiles
AddPage(1);
AddButton(130, 120, 4005, 4007, 0, GumpButtonType.Page, 2);
AddHtml(170, 120, 200, 40, "Message Control", false, false);
AddHtml(170, 120, 200, 40, "Message Control");
AddButton(130, 200, 4005, 4007, 0, GumpButtonType.Page, 8);
AddHtml(170, 200, 200, 40, "Customize your barkeep", false, false);
AddHtml(170, 200, 200, 40, "Customize your barkeep");
AddButton(130, 280, 4005, 4007, 0, GumpButtonType.Page, 3);
AddHtml(170, 280, 200, 40, "Dismiss your barkeep", false, false);
AddHtml(170, 280, 200, 40, "Dismiss your barkeep");
AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Reply, 0);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddButton(338, 437, 4014, 4016, 0);
AddHtml(290, 440, 35, 40, "Back");
AddItem(574, 43, 5360);
}
@ -838,19 +834,19 @@ namespace Server.Mobiles
AddPage(2);
AddButton(130, 120, 4005, 4007, 0, GumpButtonType.Page, 4);
AddHtml(170, 120, 380, 20, "Add or change a message and keyword", false, false);
AddHtml(170, 120, 380, 20, "Add or change a message and keyword");
AddButton(130, 200, 4005, 4007, 0, GumpButtonType.Page, 5);
AddHtml(170, 200, 380, 20, "Remove a message and keyword from your barkeep", false, false);
AddHtml(170, 200, 380, 20, "Remove a message and keyword from your barkeep");
AddButton(130, 280, 4005, 4007, 0, GumpButtonType.Page, 6);
AddHtml(170, 280, 380, 20, "Add or change your barkeeper's tip message", false, false);
AddHtml(170, 280, 380, 20, "Add or change your barkeeper's tip message");
AddButton(130, 360, 4005, 4007, 0, GumpButtonType.Page, 7);
AddHtml(170, 360, 380, 20, "Delete your barkeepers tip message", false, false);
AddHtml(170, 360, 380, 20, "Delete your barkeepers tip message");
AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 1);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddHtml(290, 440, 35, 40, "Back");
AddItem(580, 46, 4030);
}
@ -859,16 +855,16 @@ namespace Server.Mobiles
{
AddPage(3);
AddHtml(170, 160, 380, 20, "Are you sure you want to dismiss your barkeeper?", false, false);
AddHtml(170, 160, 380, 20, "Are you sure you want to dismiss your barkeeper?");
AddButton(205, 280, 4005, 4007, GetButtonID(0, 0), GumpButtonType.Reply, 0);
AddHtml(240, 280, 100, 20, @"Yes", false, false);
AddButton(205, 280, 4005, 4007, GetButtonID(0, 0));
AddHtml(240, 280, 100, 20, @"Yes");
AddButton(395, 280, 4005, 4007, 0, GumpButtonType.Reply, 0);
AddHtml(430, 280, 100, 20, "No", false, false);
AddButton(395, 280, 4005, 4007, 0);
AddHtml(430, 280, 100, 20, "No");
AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 1);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddHtml(290, 440, 35, 40, "Back");
AddItem(574, 43, 5360);
AddItem(584, 34, 6579);
@ -878,7 +874,7 @@ namespace Server.Mobiles
{
AddPage(4);
AddHtml(250, 60, 500, 25, "Add or change a message", false, false);
AddHtml(250, 60, 500, 25, "Add or change a message");
BarkeeperRumor[] rumors = m_Barkeeper.Rumors;
@ -886,16 +882,16 @@ namespace Server.Mobiles
{
BarkeeperRumor rumor = rumors[i];
AddHtml(100, 70 + i * 120, 50, 20, "Message", false, false);
AddHtml(100, 90 + i * 120, 450, 40, rumor == null ? "No current message" : rumor.Message, true, false);
AddHtml(100, 130 + i * 120, 50, 20, "Keyword", false, false);
AddHtml(100, 150 + i * 120, 450, 40, rumor == null ? "None" : rumor.Keyword, true, false);
AddHtml(100, 70 + i * 120, 50, 20, "Message");
AddHtml(100, 90 + i * 120, 450, 40, rumor == null ? "No current message" : rumor.Message, true);
AddHtml(100, 130 + i * 120, 50, 20, "Keyword");
AddHtml(100, 150 + i * 120, 450, 40, rumor == null ? "None" : rumor.Keyword, true);
AddButton(60, 90 + i * 120, 4005, 4007, GetButtonID(1, i), GumpButtonType.Reply, 0);
AddButton(60, 90 + i * 120, 4005, 4007, GetButtonID(1, i));
}
AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 2);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddHtml(290, 440, 35, 40, "Back");
AddItem(580, 46, 4030);
}
@ -904,7 +900,7 @@ namespace Server.Mobiles
{
AddPage(5);
AddHtml(190, 60, 500, 25, "Choose the message you would like to remove", false, false);
AddHtml(190, 60, 500, 25, "Choose the message you would like to remove");
BarkeeperRumor[] rumors = m_Barkeeper.Rumors;
@ -912,16 +908,16 @@ namespace Server.Mobiles
{
BarkeeperRumor rumor = rumors[i];
AddHtml(100, 70 + i * 120, 50, 20, "Message", false, false);
AddHtml(100, 90 + i * 120, 450, 40, rumor == null ? "No current message" : rumor.Message, true, false);
AddHtml(100, 130 + i * 120, 50, 20, "Keyword", false, false);
AddHtml(100, 150 + i * 120, 450, 40, rumor == null ? "None" : rumor.Keyword, true, false);
AddHtml(100, 70 + i * 120, 50, 20, "Message");
AddHtml(100, 90 + i * 120, 450, 40, rumor == null ? "No current message" : rumor.Message, true);
AddHtml(100, 130 + i * 120, 50, 20, "Keyword");
AddHtml(100, 150 + i * 120, 450, 40, rumor == null ? "None" : rumor.Keyword, true);
AddButton(60, 90 + i * 120, 4005, 4007, GetButtonID(2, i), GumpButtonType.Reply, 0);
AddButton(60, 90 + i * 120, 4005, 4007, GetButtonID(2, i));
}
AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 2);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddHtml(290, 440, 35, 40, "Back");
AddItem(580, 46, 4030);
}
@ -935,14 +931,14 @@ namespace Server.Mobiles
{
AddPage(6);
AddHtml(250, 95, 500, 20, "Change this tip message", false, false);
AddHtml(100, 190, 50, 20, "Message", false, false);
AddHtml(100, 210, 450, 40, m_Barkeeper.TipMessage ?? "No current message", true, false);
AddHtml(250, 95, 500, 20, "Change this tip message");
AddHtml(100, 190, 50, 20, "Message");
AddHtml(100, 210, 450, 40, m_Barkeeper.TipMessage ?? "No current message", true);
AddButton(60, 210, 4005, 4007, GetButtonID(3, 0), GumpButtonType.Reply, 0);
AddButton(60, 210, 4005, 4007, GetButtonID(3, 0));
AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 2);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddHtml(290, 440, 35, 40, "Back");
AddItem(580, 46, 4030);
}
@ -951,14 +947,14 @@ namespace Server.Mobiles
{
AddPage(7);
AddHtml(250, 95, 500, 20, "Remove this tip message", false, false);
AddHtml(100, 190, 50, 20, "Message", false, false);
AddHtml(100, 210, 450, 40, m_Barkeeper.TipMessage ?? "No current message", true, false);
AddHtml(250, 95, 500, 20, "Remove this tip message");
AddHtml(100, 190, 50, 20, "Message");
AddHtml(100, 210, 450, 40, m_Barkeeper.TipMessage ?? "No current message", true);
AddButton(60, 210, 4005, 4007, GetButtonID(4, 0), GumpButtonType.Reply, 0);
AddButton(60, 210, 4005, 4007, GetButtonID(4, 0));
AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 2);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddHtml(290, 440, 35, 40, "Back");
AddItem(580, 46, 4030);
}
@ -967,19 +963,19 @@ namespace Server.Mobiles
{
AddPage(8);
AddButton(130, 120, 4005, 4007, GetButtonID(5, 0), GumpButtonType.Reply, 0);
AddHtml(170, 120, 120, 20, "Title", false, false);
AddButton(130, 120, 4005, 4007, GetButtonID(5, 0));
AddHtml(170, 120, 120, 20, "Title");
if (m_Barkeeper.BodyValue != 0x340 && m_Barkeeper.BodyValue != 0x402)
{
AddButton(130, 200, 4005, 4007, GetButtonID(5, 1), GumpButtonType.Reply, 0);
AddHtml(170, 200, 120, 20, "Appearance", false, false);
AddButton(130, 200, 4005, 4007, GetButtonID(5, 1));
AddHtml(170, 200, 120, 20, "Appearance");
AddButton(130, 280, 4005, 4007, GetButtonID(5, 2), GumpButtonType.Reply, 0);
AddHtml(170, 280, 120, 20, "Male / Female", false, false);
AddButton(130, 280, 4005, 4007, GetButtonID(5, 2));
AddHtml(170, 280, 120, 20, "Male / Female");
AddButton(338, 437, 4014, 4016, 0, GumpButtonType.Page, 1);
AddHtml(290, 440, 35, 40, "Back", false, false);
AddHtml(290, 440, 35, 40, "Back");
}
AddItem(580, 44, 4033);
@ -1053,4 +1049,4 @@ namespace Server.Mobiles
}
}
}
}
}

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;

View file

@ -97,7 +97,7 @@ namespace Server.Mobiles
public bool IsLandlord(Mobile m)
{
return House != null && House.IsOwner(m);
return House?.IsOwner(m) == true;
}
public void ComputeRentalExpireDelay(out int days, out int hours)
@ -134,7 +134,7 @@ namespace Server.Mobiles
public override void Destroy(bool toBackpack)
{
if (RentalGold > 0 && House != null && House.IsAosRules)
if (RentalGold > 0 && House?.IsAosRules == true)
{
if (House.MovingCrate == null)
House.MovingCrate = new MovingCrate(House);
@ -374,4 +374,4 @@ namespace Server.Mobiles
}
}
}
}
}