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
|
|
@ -16,11 +16,8 @@ namespace Server.Items
|
|||
|
||||
private TreasureResetTimer m_ResetTimer;
|
||||
|
||||
public BaseTreasureChest(int itemID) : this(itemID, TreasureLevel.Level2)
|
||||
{
|
||||
}
|
||||
|
||||
public BaseTreasureChest(int itemID, TreasureLevel level) : base(itemID)
|
||||
public BaseTreasureChest(int itemID, TreasureLevel level = TreasureLevel.Level2)
|
||||
: base(itemID)
|
||||
{
|
||||
Level = level;
|
||||
Locked = true;
|
||||
|
|
@ -212,4 +209,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Server.Commands;
|
||||
|
||||
namespace Server.Items
|
||||
|
|
@ -9,17 +10,7 @@ namespace Server.Items
|
|||
private InternalTimer m_RelockTimer;
|
||||
|
||||
[Constructible]
|
||||
public MarkContainer() : this(false)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public MarkContainer(bool bone) : this(bone, false)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public MarkContainer(bool bone, bool locked) : base(bone ? 0xECA : 0xE79)
|
||||
public MarkContainer(bool bone = false, bool locked = false) : base(bone ? 0xECA : 0xE79)
|
||||
{
|
||||
Movable = false;
|
||||
|
||||
|
|
@ -117,30 +108,26 @@ namespace Server.Items
|
|||
private static bool FindMarkContainer(Point3D p, Map map)
|
||||
{
|
||||
IPooledEnumerable<MarkContainer> eable = map.GetItemsInRange<MarkContainer>(p, 0);
|
||||
|
||||
foreach (Item item in eable)
|
||||
if (item.Z == p.Z)
|
||||
{
|
||||
eable.Free();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool found = eable.Any(item => item.Z == p.Z);
|
||||
eable.Free();
|
||||
return false;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
private static void CreateMalasPassage(int x, int y, int z, int xTarget, int yTarget, int zTarget, bool bone,
|
||||
bool locked)
|
||||
bool locked)
|
||||
{
|
||||
Point3D location = new Point3D(x, y, z);
|
||||
|
||||
if (FindMarkContainer(location, Map.Malas))
|
||||
return;
|
||||
|
||||
MarkContainer cont = new MarkContainer(bone, locked);
|
||||
cont.TargetMap = Map.Malas;
|
||||
cont.Target = new Point3D(xTarget, yTarget, zTarget);
|
||||
cont.Description = "strange location";
|
||||
MarkContainer cont = new MarkContainer(bone, locked)
|
||||
{
|
||||
TargetMap = Map.Malas,
|
||||
Target = new Point3D(xTarget, yTarget, zTarget),
|
||||
Description = "strange location"
|
||||
};
|
||||
|
||||
cont.MoveToWorld(location, Map.Malas);
|
||||
}
|
||||
|
|
@ -148,7 +135,6 @@ namespace Server.Items
|
|||
public void StopTimer()
|
||||
{
|
||||
m_RelockTimer?.Stop();
|
||||
|
||||
m_RelockTimer = null;
|
||||
}
|
||||
|
||||
|
|
@ -243,4 +229,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,29 +38,14 @@ namespace Server.Items
|
|||
|
||||
public override int DefaultMaxWeight => 0;
|
||||
|
||||
public override bool Decays
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_House != null && m_Owner != null && !m_Owner.Deleted)
|
||||
return !m_House.IsCoOwner(m_Owner);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public override bool Decays => m_House == null || m_Owner?.Deleted != false || !m_House.IsCoOwner(m_Owner);
|
||||
|
||||
public override TimeSpan DecayTime => TimeSpan.FromMinutes(30.0);
|
||||
|
||||
public void OnChop(Mobile from)
|
||||
{
|
||||
if (m_House != null && !m_House.Deleted && m_Owner != null && !m_Owner.Deleted)
|
||||
{
|
||||
if (from == m_Owner || m_House.IsOwner(from))
|
||||
Chop(from);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_House?.Deleted != false || m_Owner?.Deleted != false || from == m_Owner || m_House.IsOwner(from))
|
||||
Chop(from);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
|
|
@ -95,7 +80,7 @@ namespace Server.Items
|
|||
|
||||
private void Validate()
|
||||
{
|
||||
if (m_Owner != null && m_House != null && !m_House.IsCoOwner(m_Owner))
|
||||
if (m_Owner != null && m_House?.IsCoOwner(m_Owner) == false)
|
||||
{
|
||||
Console.WriteLine("Warning: Destroying strongbox of {0}", m_Owner.Name);
|
||||
Destroy();
|
||||
|
|
@ -127,11 +112,9 @@ namespace Server.Items
|
|||
|
||||
public override bool IsAccessibleTo(Mobile m)
|
||||
{
|
||||
if (m_Owner == null || m_Owner.Deleted || m_House == null || m_House.Deleted ||
|
||||
m.AccessLevel >= AccessLevel.GameMaster)
|
||||
return true;
|
||||
|
||||
return m == m_Owner && m_House.IsCoOwner(m) && base.IsAccessibleTo(m);
|
||||
return m_Owner?.Deleted != false || m_House?.Deleted != false ||
|
||||
m.AccessLevel >= AccessLevel.GameMaster ||
|
||||
m == m_Owner && m_House.IsCoOwner(m) && base.IsAccessibleTo(m);
|
||||
}
|
||||
|
||||
private void Chop(Mobile from)
|
||||
|
|
@ -153,4 +136,4 @@ namespace Server.Items
|
|||
return metalBox;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,11 @@ namespace Server.Items
|
|||
private Timer m_Timer;
|
||||
|
||||
[Constructible]
|
||||
public TreasureMapChest(int level) : this(null, level, false)
|
||||
public TreasureMapChest(int level) : this(null, level)
|
||||
{
|
||||
}
|
||||
|
||||
public TreasureMapChest(Mobile owner, int level, bool temporary) : base(0xE40)
|
||||
public TreasureMapChest(Mobile owner, int level, bool temporary = false) : base(0xE40)
|
||||
{
|
||||
Owner = owner;
|
||||
Level = level;
|
||||
|
|
@ -346,14 +346,12 @@ namespace Server.Items
|
|||
if (m.AccessLevel >= AccessLevel.GameMaster || Owner == null || m == Owner)
|
||||
return true;
|
||||
|
||||
Party p = Party.Get(Owner);
|
||||
|
||||
if (p != null && p.Contains(m))
|
||||
if (Party.Get(Owner)?.Contains(m) == true)
|
||||
return true;
|
||||
|
||||
Map map = Map;
|
||||
|
||||
if (map != null && (map.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
if ((map?.Rules & MapRules.HarmfulRestrictions) == 0)
|
||||
{
|
||||
if (criminalAction)
|
||||
m.CriminalAction(true);
|
||||
|
|
@ -518,16 +516,14 @@ namespace Server.Items
|
|||
|
||||
AddBackground(30, 0, 240, 240, 2620);
|
||||
|
||||
AddHtmlLocalized(45, 15, 200, 80, 1048125, 0xFFFFFF, false,
|
||||
false); // When this treasure chest is removed, any items still inside of it will be lost.
|
||||
AddHtmlLocalized(45, 95, 200, 60, 1048126, 0xFFFFFF, false,
|
||||
false); // Are you certain you're ready to remove this chest?
|
||||
AddHtmlLocalized(45, 15, 200, 80, 1048125, 0xFFFFFF); // When this treasure chest is removed, any items still inside of it will be lost.
|
||||
AddHtmlLocalized(45, 95, 200, 60, 1048126, 0xFFFFFF); // Are you certain you're ready to remove this chest?
|
||||
|
||||
AddButton(40, 153, 4005, 4007, 1, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(75, 155, 180, 40, 1048127, 0xFFFFFF, false, false); // Remove the Treasure Chest
|
||||
AddButton(40, 153, 4005, 4007, 1);
|
||||
AddHtmlLocalized(75, 155, 180, 40, 1048127, 0xFFFFFF); // Remove the Treasure Chest
|
||||
|
||||
AddButton(40, 195, 4005, 4007, 2, GumpButtonType.Reply, 0);
|
||||
AddHtmlLocalized(75, 197, 180, 35, 1006045, 0xFFFFFF, false, false); // Cancel
|
||||
AddButton(40, 195, 4005, 4007, 2);
|
||||
AddHtmlLocalized(75, 197, 180, 35, 1006045, 0xFFFFFF); // Cancel
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
|
|
@ -575,4 +571,4 @@ namespace Server.Items
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue