Adds style cop (#109)

This commit is contained in:
Kamron Batman 2020-04-26 00:16:02 -07:00 committed by GitHub
parent 3e715bcb60
commit 556a17aba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1725 changed files with 33831 additions and 38046 deletions

View file

@ -16,11 +16,11 @@ namespace Server.Regions
public class BaseRegion : Region
{
private static List<Rectangle3D> m_RectBuffer1 = new List<Rectangle3D>();
private static List<Rectangle3D> m_RectBuffer2 = new List<Rectangle3D>();
private static readonly List<Rectangle3D> m_RectBuffer1 = new List<Rectangle3D>();
private static readonly List<Rectangle3D> m_RectBuffer2 = new List<Rectangle3D>();
private static List<int> m_SpawnBuffer1 = new List<int>();
private static List<Item> m_SpawnBuffer2 = new List<Item>();
private static readonly List<int> m_SpawnBuffer1 = new List<int>();
private static readonly List<Item> m_SpawnBuffer2 = new List<Item>();
private bool m_ExcludeFromParentSpawns;
private Rectangle3D[] m_Rectangles;
@ -55,7 +55,6 @@ namespace Server.Regions
ReadBoolean(xml["logoutDelay"], "active", ref logoutDelayActive, false);
NoLogoutDelay = !logoutDelayActive;
XmlElement spawning = xml["spawning"];
if (spawning != null)
{
@ -65,7 +64,6 @@ namespace Server.Regions
ReadEnum(spawning, "zLevel", ref zLevel, false);
SpawnZLevel = zLevel;
List<SpawnEntry> list = new List<SpawnEntry>();
foreach (XmlNode node in spawning.ChildNodes)
@ -121,7 +119,7 @@ namespace Server.Regions
set => m_RuneName = value;
}
public bool NoLogoutDelay{ get; set; }
public bool NoLogoutDelay { get; set; }
public SpawnEntry[] Spawns
{
@ -136,7 +134,7 @@ namespace Server.Regions
}
}
public SpawnZLevel SpawnZLevel{ get; set; }
public SpawnZLevel SpawnZLevel { get; set; }
public bool ExcludeFromParentSpawns
{
@ -395,7 +393,6 @@ namespace Server.Regions
}
}
Sector sector = map.GetSector(x, y);
for (int j = 0; j < sector.Items.Count; j++)
@ -425,7 +422,6 @@ namespace Server.Regions
}
}
if (m_SpawnBuffer1.Count == 0)
{
m_SpawnBuffer1.Clear();
@ -437,45 +433,44 @@ namespace Server.Regions
switch (SpawnZLevel)
{
case SpawnZLevel.Lowest:
{
z = int.MaxValue;
for (int j = 0; j < m_SpawnBuffer1.Count; j++)
{
int l = m_SpawnBuffer1[j];
z = int.MaxValue;
if (l < z)
z = l;
for (int j = 0; j < m_SpawnBuffer1.Count; j++)
{
int l = m_SpawnBuffer1[j];
if (l < z)
z = l;
}
break;
}
break;
}
case SpawnZLevel.Highest:
{
z = int.MinValue;
for (int j = 0; j < m_SpawnBuffer1.Count; j++)
{
int l = m_SpawnBuffer1[j];
z = int.MinValue;
if (l > z)
z = l;
for (int j = 0; j < m_SpawnBuffer1.Count; j++)
{
int l = m_SpawnBuffer1[j];
if (l > z)
z = l;
}
break;
}
break;
}
default: // SpawnZLevel.Random
{
int index = Utility.Random(m_SpawnBuffer1.Count);
z = m_SpawnBuffer1[index];
{
int index = Utility.Random(m_SpawnBuffer1.Count);
z = m_SpawnBuffer1[index];
break;
}
break;
}
}
m_SpawnBuffer1.Clear();
if (!Find(new Point3D(x, y, z), map).AcceptsSpawnsFrom(this))
{
m_SpawnBuffer2.Clear();

View file

@ -25,7 +25,7 @@ namespace Server.Regions
set => m_EntranceLocation = value;
}
public Map EntranceMap{ get; set; }
public Map EntranceMap { get; set; }
public override bool AllowHousing(Mobile from, Point3D p) => false;

View file

@ -9,10 +9,10 @@ namespace Server.Regions
{
public class GuardedRegion : BaseRegion
{
private static object[] m_GuardParams = new object[1];
private static readonly object[] m_GuardParams = new object[1];
private Dictionary<Mobile, GuardTimer> m_GuardCandidates = new Dictionary<Mobile, GuardTimer>();
private Type m_GuardType;
private readonly Dictionary<Mobile, GuardTimer> m_GuardCandidates = new Dictionary<Mobile, GuardTimer>();
private readonly Type m_GuardType;
public GuardedRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area) => m_GuardType = DefaultGuardType;
@ -42,7 +42,7 @@ namespace Server.Regions
Disabled = disabled;
}
public bool Disabled{ get; set; }
public bool Disabled { get; set; }
public virtual bool AllowReds => Core.AOS;
@ -298,7 +298,7 @@ namespace Server.Regions
foreach (Mobile m in eable)
if (IsGuardCandidate(m) &&
(!AllowReds && m.Kills >= 5 && m.Region.IsPartOf(this) || m_GuardCandidates.ContainsKey(m)))
((!AllowReds && m.Kills >= 5 && m.Region.IsPartOf(this)) || m_GuardCandidates.ContainsKey(m)))
{
if (m_GuardCandidates.TryGetValue(m, out GuardTimer timer))
{
@ -317,16 +317,16 @@ namespace Server.Regions
public bool IsGuardCandidate(Mobile m)
{
if (m is BaseGuard || !m.Alive || m.AccessLevel > AccessLevel.Player || m.Blessed ||
m is BaseCreature creature && creature.IsInvulnerable || IsDisabled())
(m is BaseCreature creature && creature.IsInvulnerable) || IsDisabled())
return false;
return !AllowReds && m.Kills >= 5 || m.Criminal;
return (!AllowReds && m.Kills >= 5) || m.Criminal;
}
private class GuardTimer : Timer
{
private Mobile m_Mobile;
private Dictionary<Mobile, GuardTimer> m_Table;
private readonly Mobile m_Mobile;
private readonly Dictionary<Mobile, GuardTimer> m_Table;
public GuardTimer(Mobile m, Dictionary<Mobile, GuardTimer> table) : base(TimeSpan.FromSeconds(15.0))
{

View file

@ -23,7 +23,7 @@ namespace Server.Regions
GoLocation = new Point3D(house.X + ban.X, house.Y + ban.Y, house.Z + ban.Z);
}
public BaseHouse House{ get; }
public BaseHouse House { get; }
public static void Initialize()
{

View file

@ -7,7 +7,7 @@ namespace Server.Regions
/* - False: this uses 'stupid OSI' house placement checking: part of the house may be placed here provided that the center is not in the region
* - True: this uses 'smart RunUO' house placement checking: no part of the house may be in the region
*/
private bool m_SmartChecking;
private readonly bool m_SmartChecking;
public NoHousingRegion(XmlElement xml, Map map, Region parent) : base(xml, map, parent)
{

View file

@ -19,46 +19,46 @@ namespace Server.Regions
switch (xml.Name)
{
case "object":
{
Type type = null;
if (!Region.ReadType(xml, "type", ref type))
return null;
if (typeof(Mobile).IsAssignableFrom(type)) return SpawnMobile.Get(type);
if (typeof(Item).IsAssignableFrom(type)) return SpawnItem.Get(type);
Console.WriteLine("Invalid type '{0}' in a SpawnDefinition", type.FullName);
return null;
}
case "group":
{
string group = null;
if (!Region.ReadString(xml, "name", ref group))
return null;
if (!SpawnGroup.Table.TryGetValue(group, out SpawnGroup def))
{
Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group);
Type type = null;
if (!Region.ReadType(xml, "type", ref type))
return null;
if (typeof(Mobile).IsAssignableFrom(type)) return SpawnMobile.Get(type);
if (typeof(Item).IsAssignableFrom(type)) return SpawnItem.Get(type);
Console.WriteLine("Invalid type '{0}' in a SpawnDefinition", type.FullName);
return null;
}
case "group":
{
string group = null;
if (!Region.ReadString(xml, "name", ref group))
return null;
return def;
}
if (!SpawnGroup.Table.TryGetValue(group, out SpawnGroup def))
{
Console.WriteLine("Could not find group '{0}' in a SpawnDefinition", group);
return null;
}
return def;
}
case "treasureChest":
{
int itemID = 0xE43;
Region.ReadInt32(xml, "itemID", ref itemID, false);
{
int itemID = 0xE43;
Region.ReadInt32(xml, "itemID", ref itemID, false);
BaseTreasureChest.TreasureLevel level = BaseTreasureChest.TreasureLevel.Level2;
BaseTreasureChest.TreasureLevel level = BaseTreasureChest.TreasureLevel.Level2;
Region.ReadEnum(xml, "level", ref level, false);
Region.ReadEnum(xml, "level", ref level, false);
return new SpawnTreasureChest(itemID, level);
}
return new SpawnTreasureChest(itemID, level);
}
default:
{
return null;
}
{
return null;
}
}
}
}
@ -73,11 +73,11 @@ namespace Server.Regions
m_Init = false;
}
public Type Type{ get; }
public Type Type { get; }
public abstract int Height{ get; }
public abstract bool Land{ get; }
public abstract bool Water{ get; }
public abstract int Height { get; }
public abstract bool Land { get; }
public abstract bool Water { get; }
protected void EnsureInit()
{
@ -119,7 +119,7 @@ namespace Server.Regions
public class SpawnMobile : SpawnType
{
private static Dictionary<Type, SpawnMobile> m_Table = new Dictionary<Type, SpawnMobile>();
private static readonly Dictionary<Type, SpawnMobile> m_Table = new Dictionary<Type, SpawnMobile>();
private bool m_Land;
private bool m_Water;
@ -192,7 +192,7 @@ namespace Server.Regions
public class SpawnItem : SpawnType
{
private static Dictionary<Type, SpawnItem> m_Table = new Dictionary<Type, SpawnItem>();
private static readonly Dictionary<Type, SpawnItem> m_Table = new Dictionary<Type, SpawnItem>();
protected int m_Height;
@ -251,9 +251,9 @@ namespace Server.Regions
Level = level;
}
public int ItemID{ get; }
public int ItemID { get; }
public BaseTreasureChest.TreasureLevel Level{ get; }
public BaseTreasureChest.TreasureLevel Level { get; }
protected override void Init()
{
@ -271,14 +271,14 @@ namespace Server.Regions
Weight = weight;
}
public SpawnDefinition SpawnDefinition{ get; }
public SpawnDefinition SpawnDefinition { get; }
public int Weight{ get; }
public int Weight { get; }
}
public class SpawnGroup : SpawnDefinition
{
private int m_TotalWeight;
private readonly int m_TotalWeight;
static SpawnGroup()
{
@ -337,11 +337,11 @@ namespace Server.Regions
m_TotalWeight += elements[i].Weight;
}
public static Dictionary<string, SpawnGroup> Table{ get; } = new Dictionary<string, SpawnGroup>();
public static Dictionary<string, SpawnGroup> Table { get; } = new Dictionary<string, SpawnGroup>();
public string Name{ get; }
public string Name { get; }
public SpawnGroupElement[] Elements{ get; }
public SpawnGroupElement[] Elements { get; }
public static void Register(SpawnGroup group)
{

View file

@ -9,7 +9,6 @@ namespace Server.Regions
public static readonly TimeSpan DefaultMinSpawnTime = TimeSpan.FromMinutes(2.0);
public static readonly TimeSpan DefaultMaxSpawnTime = TimeSpan.FromMinutes(5.0);
public static readonly Direction InvalidDirection = Direction.Running;
private static List<IEntity> m_RemoveList;
@ -38,8 +37,7 @@ namespace Server.Regions
Table[id] = this;
}
public static Dictionary<int, SpawnEntry> Table{ get; } = new Dictionary<int, SpawnEntry>();
public static Dictionary<int, SpawnEntry> Table { get; } = new Dictionary<int, SpawnEntry>();
// When a creature's AI is deactivated (PlayerRangeSensitive optimization) does it return home?
public bool ReturnOnDeactivate => true;
@ -47,23 +45,23 @@ namespace Server.Regions
// Are unlinked and untamed creatures removed after 20 hours?
public bool RemoveIfUntamed => true;
public int ID{ get; }
public int ID { get; }
public BaseRegion Region{ get; }
public BaseRegion Region { get; }
public Direction Direction{ get; }
public Direction Direction { get; }
public SpawnDefinition Definition{ get; }
public SpawnDefinition Definition { get; }
public List<ISpawnable> SpawnedObjects{ get; }
public List<ISpawnable> SpawnedObjects { get; }
public int Max{ get; private set; }
public int Max { get; private set; }
public TimeSpan MinSpawnTime{ get; }
public TimeSpan MinSpawnTime { get; }
public TimeSpan MaxSpawnTime{ get; }
public TimeSpan MaxSpawnTime { get; }
public bool Running{ get; private set; }
public bool Running { get; private set; }
public bool Complete => SpawnedObjects.Count >= Max;
public bool Spawning => Running && !Complete;
@ -72,9 +70,9 @@ namespace Server.Regions
public bool UnlinkOnTaming => false;
Region ISpawner.Region => Region;
public Point3D HomeLocation{ get; }
public Point3D HomeLocation { get; }
public int HomeRange{ get; }
public int HomeRange { get; }
void ISpawner.Remove(ISpawnable spawn)
{