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
|
|
@ -3,12 +3,7 @@ namespace Server.Items
|
|||
public class BlankScroll : Item, ICommodity
|
||||
{
|
||||
[Constructible]
|
||||
public BlankScroll() : this(1)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public BlankScroll(int amount) : base(0xEF3)
|
||||
public BlankScroll(int amount = 1) : base(0xEF3)
|
||||
{
|
||||
Stackable = true;
|
||||
Weight = 1.0;
|
||||
|
|
@ -36,4 +31,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,12 +3,7 @@ namespace Server.Items
|
|||
public class Bottle : Item, ICommodity
|
||||
{
|
||||
[Constructible]
|
||||
public Bottle() : this(1)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public Bottle(int amount) : base(0xF0E)
|
||||
public Bottle(int amount = 1) : base(0xF0E)
|
||||
{
|
||||
Stackable = true;
|
||||
Weight = 1.0;
|
||||
|
|
@ -37,4 +32,4 @@ namespace Server.Items
|
|||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,26 +11,22 @@ namespace Server.Items
|
|||
[DispellableField]
|
||||
public class Moongate : Item
|
||||
{
|
||||
|
||||
[Constructible]
|
||||
public Moongate() : this(Point3D.Zero, null)
|
||||
public Moongate(bool dispellable = true) :
|
||||
this(Point3D.Zero, null, dispellable)
|
||||
{
|
||||
Dispellable = true;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public Moongate(bool bDispellable) : this(Point3D.Zero, null)
|
||||
{
|
||||
Dispellable = bDispellable;
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public Moongate(Point3D target, Map targetMap) : base(0xF6C)
|
||||
public Moongate(Point3D target, Map targetMap = null, bool dispellable = true) : base(0xF6C)
|
||||
{
|
||||
Movable = false;
|
||||
Light = LightType.Circle300;
|
||||
|
||||
Target = target;
|
||||
TargetMap = targetMap;
|
||||
Dispellable = dispellable;
|
||||
}
|
||||
|
||||
public Moongate(Serial serial) : base(serial)
|
||||
|
|
@ -202,12 +198,7 @@ namespace Server.Items
|
|||
|
||||
public static bool IsInTown(Point3D p, Map map)
|
||||
{
|
||||
if (map == null)
|
||||
return false;
|
||||
|
||||
GuardedRegion reg = Region.Find(p, map).GetRegion<GuardedRegion>();
|
||||
|
||||
return reg != null && !reg.IsDisabled();
|
||||
return map != null && Region.Find(p, map).GetRegion<GuardedRegion>()?.IsDisabled() == false;
|
||||
}
|
||||
|
||||
private class DelayTimer : Timer
|
||||
|
|
@ -233,12 +224,12 @@ namespace Server.Items
|
|||
public class ConfirmationMoongate : Moongate
|
||||
{
|
||||
[Constructible]
|
||||
public ConfirmationMoongate() : this(Point3D.Zero, null)
|
||||
public ConfirmationMoongate() : this(Point3D.Zero)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public ConfirmationMoongate(Point3D target, Map targetMap) : base(target, targetMap)
|
||||
public ConfirmationMoongate(Point3D target, Map targetMap = null) : base(target, targetMap)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +345,7 @@ namespace Server.Items
|
|||
AddImageTiled(10, 10, 400, 20, 2624);
|
||||
AddAlphaRegion(10, 10, 400, 20);
|
||||
|
||||
AddHtmlLocalized(10, 10, 400, 20, 1062051, 30720, false, false); // Gate Warning
|
||||
AddHtmlLocalized(10, 10, 400, 20, 1062051, 30720); // Gate Warning
|
||||
|
||||
AddImageTiled(10, 40, 400, 200, 2624);
|
||||
AddAlphaRegion(10, 40, 400, 200);
|
||||
|
|
@ -369,11 +360,11 @@ namespace Server.Items
|
|||
AddImageTiled(10, 250, 400, 20, 2624);
|
||||
AddAlphaRegion(10, 250, 400, 20);
|
||||
|
||||
AddButton(10, 250, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767, false, false); // OKAY
|
||||
AddButton(10, 250, 4005, 4007, 1);
|
||||
AddHtmlLocalized(40, 250, 170, 20, 1011036, 32767); // OKAY
|
||||
|
||||
AddButton(210, 250, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767, false, false); // CANCEL
|
||||
AddButton(210, 250, 4005, 4007, 0);
|
||||
AddHtmlLocalized(240, 250, 170, 20, 1011012, 32767); // CANCEL
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -383,14 +374,13 @@ namespace Server.Items
|
|||
AddBackground(10, 10, 400, 380, 3000);
|
||||
|
||||
AddHtml(20, 40, 380, 60,
|
||||
@"Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here", false,
|
||||
false);
|
||||
@"Dost thou wish to step into the moongate? Continue to enter the gate, Cancel to stay here");
|
||||
|
||||
AddHtmlLocalized(55, 110, 290, 20, 1011012, false, false); // CANCEL
|
||||
AddButton(20, 110, 4005, 4007, 0, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(55, 110, 290, 20, 1011012); // CANCEL
|
||||
AddButton(20, 110, 4005, 4007, 0);
|
||||
|
||||
AddHtmlLocalized(55, 140, 290, 40, 1011011, false, false); // CONTINUE
|
||||
AddButton(20, 140, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(55, 140, 290, 40, 1011011); // CONTINUE
|
||||
AddButton(20, 140, 4005, 4007, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -400,4 +390,4 @@ namespace Server.Items
|
|||
m_Gate.EndConfirmation(m_From);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ namespace Server.Items
|
|||
{
|
||||
Container pack = from.Backpack;
|
||||
|
||||
if (pack != null && pack.ConsumeTotal(typeof(Bottle), 1))
|
||||
if (pack?.ConsumeTotal(typeof(Bottle)) == true)
|
||||
{
|
||||
from.SendLocalizedMessage(502242); // You pour some of the keg's contents into an empty bottle...
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ namespace Server.Items
|
|||
|
||||
Bottle bottle = new Bottle(amount);
|
||||
|
||||
if (pack == null || !pack.TryDropItem(m, bottle, false))
|
||||
if (pack?.TryDropItem(m, bottle, false) != true)
|
||||
{
|
||||
bottle.Delete();
|
||||
return false;
|
||||
|
|
@ -339,4 +339,4 @@ namespace Server.Items
|
|||
TileData.ItemTable[0x1940].Height = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace Server.Items
|
|||
{
|
||||
get
|
||||
{
|
||||
if (m_House != null && m_House.Deleted)
|
||||
if (m_House?.Deleted == true)
|
||||
House = null;
|
||||
|
||||
return m_House;
|
||||
|
|
@ -90,7 +90,7 @@ namespace Server.Items
|
|||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
if (m_House != null && !m_House.Deleted)
|
||||
if (m_House?.Deleted == false)
|
||||
{
|
||||
writer.Write(1); // version
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ namespace Server.Items
|
|||
|
||||
Map map = m_House.Map;
|
||||
|
||||
if (map != null && !map.CanFit(x, y, z, 16, false, false))
|
||||
if (map?.CanFit(x, y, z, 16, false, false) == false)
|
||||
z = map.GetAverageZ(x, y);
|
||||
|
||||
Target = new Point3D(x, y, z);
|
||||
|
|
@ -305,4 +305,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue