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
|
|
@ -36,7 +36,7 @@ namespace Server.Misc
|
|||
GiftGiver giver = m_Givers[i];
|
||||
|
||||
if (now < giver.Start || now >= giver.Finish)
|
||||
continue; // not in the correct timefream
|
||||
continue; // not in the correct time frame
|
||||
|
||||
if (acct.Created > giver.Start - giver.MinimumAge)
|
||||
continue; // newly created account
|
||||
|
|
@ -66,12 +66,11 @@ namespace Server.Misc
|
|||
|
||||
public virtual GiftResult GiveGift(Mobile mob, Item item)
|
||||
{
|
||||
if (mob.PlaceInBackpack(item))
|
||||
if (!WeightOverloading.IsOverloaded(mob))
|
||||
return GiftResult.Backpack;
|
||||
if (mob.PlaceInBackpack(item) && !WeightOverloading.IsOverloaded(mob))
|
||||
return GiftResult.Backpack;
|
||||
|
||||
mob.BankBox.DropItem(item);
|
||||
return GiftResult.BankBox;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace Server.Misc
|
|||
{
|
||||
Mobile from = e.Mobile;
|
||||
|
||||
if (from == null || from.AccessLevel < AccessLevel.Counselor)
|
||||
if (from?.AccessLevel < AccessLevel.Counselor)
|
||||
return;
|
||||
|
||||
if (HasDisconnected(from))
|
||||
|
|
|
|||
|
|
@ -20,39 +20,39 @@ namespace Server.Misc
|
|||
|
||||
private static void EventSink_Speech(SpeechEventArgs args)
|
||||
{
|
||||
if (!args.Handled)
|
||||
if (args.Handled)
|
||||
return;
|
||||
|
||||
if (Insensitive.StartsWith(args.Speech, "set"))
|
||||
{
|
||||
if (Insensitive.StartsWith(args.Speech, "set"))
|
||||
{
|
||||
Mobile from = args.Mobile;
|
||||
Mobile from = args.Mobile;
|
||||
|
||||
string[] split = args.Speech.Split(' ');
|
||||
string[] split = args.Speech.Split(' ');
|
||||
|
||||
if (split.Length == 3)
|
||||
try
|
||||
{
|
||||
string name = split[1];
|
||||
double value = Convert.ToDouble(split[2]);
|
||||
if (split.Length == 3)
|
||||
try
|
||||
{
|
||||
string name = split[1];
|
||||
double value = Convert.ToDouble(split[2]);
|
||||
|
||||
if (Insensitive.Equals(name, "str"))
|
||||
ChangeStrength(from, (int)value);
|
||||
else if (Insensitive.Equals(name, "dex"))
|
||||
ChangeDexterity(from, (int)value);
|
||||
else if (Insensitive.Equals(name, "int"))
|
||||
ChangeIntelligence(from, (int)value);
|
||||
else
|
||||
ChangeSkill(from, name, value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
else if (Insensitive.Equals(args.Speech, "help"))
|
||||
{
|
||||
args.Mobile.SendGump(new TCHelpGump());
|
||||
|
||||
args.Handled = true;
|
||||
}
|
||||
if (Insensitive.Equals(name, "str"))
|
||||
ChangeStrength(from, (int)value);
|
||||
else if (Insensitive.Equals(name, "dex"))
|
||||
ChangeDexterity(from, (int)value);
|
||||
else if (Insensitive.Equals(name, "int"))
|
||||
ChangeIntelligence(from, (int)value);
|
||||
else
|
||||
ChangeSkill(from, name, value);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
else if (Insensitive.Equals(args.Speech, "help"))
|
||||
{
|
||||
args.Mobile.SendGump(new TCHelpGump());
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -160,16 +160,16 @@ namespace Server.Misc
|
|||
AddPage(0);
|
||||
AddBackground(0, 0, 160, 120, 5054);
|
||||
|
||||
AddButton(10, 10, 0xFB7, 0xFB9, 1, GumpButtonType.Reply, 0);
|
||||
AddButton(10, 10, 0xFB7, 0xFB9, 1);
|
||||
AddLabel(45, 10, 0x34, "RunUO");
|
||||
|
||||
AddButton(10, 35, 0xFB7, 0xFB9, 2, GumpButtonType.Reply, 0);
|
||||
AddButton(10, 35, 0xFB7, 0xFB9, 2);
|
||||
AddLabel(45, 35, 0x34, "List of skills");
|
||||
|
||||
AddButton(10, 60, 0xFB7, 0xFB9, 3, GumpButtonType.Reply, 0);
|
||||
AddButton(10, 60, 0xFB7, 0xFB9, 3);
|
||||
AddLabel(45, 60, 0x34, "Command list");
|
||||
|
||||
AddButton(10, 85, 0xFB1, 0xFB3, 0, GumpButtonType.Reply, 0);
|
||||
AddButton(10, 85, 0xFB1, 0xFB3, 0);
|
||||
AddLabel(45, 85, 0x34, "Close");
|
||||
}
|
||||
|
||||
|
|
@ -228,4 +228,4 @@ namespace Server.Misc
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Server.Items
|
|||
{
|
||||
Container pack = from.Backpack;
|
||||
|
||||
if (pack != null && pack.ConsumeTotal(typeof(Gold), 250))
|
||||
if (pack?.ConsumeTotal(typeof(Gold), 250) == true)
|
||||
{
|
||||
m_GamblePot += 150;
|
||||
InvalidateProperties();
|
||||
|
|
@ -74,7 +74,7 @@ namespace Server.Items
|
|||
else if (roll <= 20) // Chance for a regbag
|
||||
{
|
||||
from.SendMessage(0x35, "You win a bag of reagents!");
|
||||
from.AddToBackpack(new BagOfReagents(50));
|
||||
from.AddToBackpack(new BagOfReagents());
|
||||
}
|
||||
else if (roll <= 40) // Chance for gold
|
||||
{
|
||||
|
|
@ -123,4 +123,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Server.Items
|
|||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
BagOfingots ingotBag = new BagOfingots(5000);
|
||||
BagOfingots ingotBag = new BagOfingots();
|
||||
|
||||
if (!from.AddToBackpack(ingotBag))
|
||||
ingotBag.Delete();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Server.Items
|
|||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
BagOfReagents regBag = new BagOfReagents(50);
|
||||
BagOfReagents regBag = new BagOfReagents();
|
||||
|
||||
if (!from.AddToBackpack(regBag))
|
||||
regBag.Delete();
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace Server.Items
|
|||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
SmithBag SmithBag = new SmithBag(5000);
|
||||
SmithBag SmithBag = new SmithBag();
|
||||
|
||||
if (!from.AddToBackpack(SmithBag))
|
||||
SmithBag.Delete();
|
||||
|
|
|
|||
|
|
@ -1,18 +1,14 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class AlchemyBag : Bag
|
||||
{
|
||||
[Constructible]
|
||||
public AlchemyBag() : this(1)
|
||||
public AlchemyBag(int amount = 5000)
|
||||
{
|
||||
Movable = true;
|
||||
Hue = 0x250;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public AlchemyBag(int amount)
|
||||
{
|
||||
DropItem(new MortarPestle(5));
|
||||
DropItem(new MortarPestle(Math.Max(amount / 1000, 1)));
|
||||
DropItem(new BagOfReagents(5000));
|
||||
DropItem(new Bottle(5000));
|
||||
}
|
||||
|
|
@ -37,4 +33,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@ namespace Server.Items
|
|||
public class BagOfingots : Bag
|
||||
{
|
||||
[Constructible]
|
||||
public BagOfingots() : this(5000)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public BagOfingots(int amount)
|
||||
public BagOfingots(int amount = 5000)
|
||||
{
|
||||
DropItem(new DullCopperIngot(amount));
|
||||
DropItem(new ShadowIronIngot(amount));
|
||||
|
|
@ -31,7 +26,7 @@ namespace Server.Items
|
|||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
|
|
@ -41,4 +36,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,11 @@ namespace Server.Items
|
|||
public class ScribeBag : Bag
|
||||
{
|
||||
[Constructible]
|
||||
public ScribeBag() : this(1)
|
||||
public ScribeBag(int amount = 5000)
|
||||
{
|
||||
Movable = true;
|
||||
Hue = 0x105;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public ScribeBag(int amount)
|
||||
{
|
||||
DropItem(new BagOfReagents(5000));
|
||||
DropItem(new BlankScroll(500));
|
||||
DropItem(new BagOfReagents(amount));
|
||||
DropItem(new BlankScroll(amount));
|
||||
}
|
||||
|
||||
public ScribeBag(Serial serial) : base(serial)
|
||||
|
|
@ -36,4 +30,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@ namespace Server.Items
|
|||
public class SmithBag : Bag
|
||||
{
|
||||
[Constructible]
|
||||
public SmithBag() : this(5000)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public SmithBag(int amount)
|
||||
public SmithBag(int amount = 5000)
|
||||
{
|
||||
DropItem(new DullCopperIngot(amount));
|
||||
DropItem(new ShadowIronIngot(amount));
|
||||
|
|
@ -31,7 +26,7 @@ namespace Server.Items
|
|||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write(0); // version
|
||||
writer.Write(0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
|
|
@ -41,4 +36,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
using System;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class TailorBag : Bag
|
||||
{
|
||||
[Constructible]
|
||||
public TailorBag() : this(1)
|
||||
public TailorBag(int amount = 500)
|
||||
{
|
||||
Movable = true;
|
||||
Hue = 0x315;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public TailorBag(int amount)
|
||||
{
|
||||
DropItem(new SewingKit(5));
|
||||
DropItem(new SewingKit(Math.Max(amount / 100, 1)));
|
||||
DropItem(new Scissors());
|
||||
DropItem(new Hides(500));
|
||||
DropItem(new BoltOfCloth(20));
|
||||
DropItem(new Hides(amount));
|
||||
DropItem(new BoltOfCloth(Math.Max(amount / 25, 1)));
|
||||
DropItem(new DyeTub());
|
||||
DropItem(new DyeTub());
|
||||
DropItem(new BlackDyeTub());
|
||||
|
|
@ -42,4 +38,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue