Clean up: Bugs, LINQ, constructors, default values, and null checks (#18)
This commit is contained in:
parent
e748af4430
commit
513e54f70e
1094 changed files with 15913 additions and 21892 deletions
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue