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

@ -8,14 +8,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Scripts", "Projects\Scripts
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Analyze|Any CPU = Analyze|Any CPU
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5E93BB35-3661-4822-9A8A-859726BAD87F}.Analyze|Any CPU.ActiveCfg = Analyze|Any CPU
{5E93BB35-3661-4822-9A8A-859726BAD87F}.Analyze|Any CPU.Build.0 = Analyze|Any CPU
{5E93BB35-3661-4822-9A8A-859726BAD87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5E93BB35-3661-4822-9A8A-859726BAD87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E93BB35-3661-4822-9A8A-859726BAD87F}.Debug|Any CPU.Build.0 = Debug|Any CPU {5E93BB35-3661-4822-9A8A-859726BAD87F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E93BB35-3661-4822-9A8A-859726BAD87F}.Release|Any CPU.ActiveCfg = Release|Any CPU {5E93BB35-3661-4822-9A8A-859726BAD87F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E93BB35-3661-4822-9A8A-859726BAD87F}.Release|Any CPU.Build.0 = Release|Any CPU {5E93BB35-3661-4822-9A8A-859726BAD87F}.Release|Any CPU.Build.0 = Release|Any CPU
{83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Analyze|Any CPU.ActiveCfg = Analyze|Any CPU
{83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Analyze|Any CPU.Build.0 = Analyze|Any CPU
{83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU {83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU {83CF2484-BCCB-4B7C-9C5F-7AB43AEA5E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU

View file

@ -23,7 +23,7 @@ namespace Server.Accounting
private TimeSpan m_TotalGameTime; private TimeSpan m_TotalGameTime;
private List<AccountComment> m_Comments; private List<AccountComment> m_Comments;
private List<AccountTag> m_Tags; private List<AccountTag> m_Tags;
private Mobile[] m_Mobiles; private readonly Mobile[] m_Mobiles;
/// <summary> /// <summary>
/// Deletes the account, all characters of the account, and all houses of those characters /// Deletes the account, all characters of the account, and all houses of those characters
@ -500,7 +500,7 @@ namespace Server.Accounting
private class YoungTimer : Timer private class YoungTimer : Timer
{ {
private Account m_Account; private readonly Account m_Account;
public YoungTimer(Account account) public YoungTimer(Account account)
: base(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0)) : base(TimeSpan.FromMinutes(1.0), TimeSpan.FromMinutes(1.0))
@ -529,8 +529,8 @@ namespace Server.Accounting
m_Mobiles = new Mobile[7]; m_Mobiles = new Mobile[7];
IPRestrictions = new string[0]; IPRestrictions = Array.Empty<string>();
LoginIPs = new IPAddress[0]; LoginIPs = Array.Empty<IPAddress>();
Accounts.Add(this); Accounts.Add(this);
} }
@ -644,7 +644,7 @@ namespace Server.Accounting
} }
else else
{ {
stringList = new string[0]; stringList = Array.Empty<string>();
} }
return stringList; return stringList;
@ -687,7 +687,7 @@ namespace Server.Accounting
} }
else else
{ {
list = new IPAddress[0]; list = Array.Empty<IPAddress>();
} }
return list; return list;
@ -824,11 +824,13 @@ namespace Server.Accounting
if (ns != null) LogAccess(ns.Address); if (ns != null) LogAccess(ns.Address);
} }
public void LogAccess( IPAddress ipAddress ) { public void LogAccess(IPAddress ipAddress)
{
if (IPLimiter.IsExempt(ipAddress)) if (IPLimiter.IsExempt(ipAddress))
return; return;
if ( LoginIPs.Length == 0 ) { if (LoginIPs.Length == 0)
{
if (AccountHandler.IPTable.ContainsKey(ipAddress)) if (AccountHandler.IPTable.ContainsKey(ipAddress))
AccountHandler.IPTable[ipAddress]++; AccountHandler.IPTable[ipAddress]++;
else else
@ -859,7 +861,8 @@ namespace Server.Accounting
/// <returns>True if allowed, false if not.</returns> /// <returns>True if allowed, false if not.</returns>
public bool CheckAccess(NetState ns) => ns != null && CheckAccess(ns.Address); public bool CheckAccess(NetState ns) => ns != null && CheckAccess(ns.Address);
public bool CheckAccess( IPAddress ipAddress ) { public bool CheckAccess(IPAddress ipAddress)
{
bool hasAccess = HasAccess(ipAddress); bool hasAccess = HasAccess(ipAddress);
if (hasAccess) if (hasAccess)
@ -1077,7 +1080,6 @@ namespace Server.Accounting
public int CompareTo(IAccount other) => other == null ? 1 : Username.CompareTo(other.Username); public int CompareTo(IAccount other) => other == null ? 1 : Username.CompareTo(other.Username);
#region Gold Account
/// <summary> /// <summary>
/// This amount represents the current amount of Gold owned by the player. /// This amount represents the current amount of Gold owned by the player.
/// The value does not include the value of Platinum and ranges from /// The value does not include the value of Platinum and ranges from
@ -1164,7 +1166,5 @@ namespace Server.Accounting
/// </summary> /// </summary>
/// <returns>Total gold, capped at Int32.MaxValue</returns> /// <returns>Total gold, capped at Int32.MaxValue</returns>
public long GetTotalGold() => TotalGold + TotalPlat * AccountGold.CurrencyThreshold; public long GetTotalGold() => TotalGold + TotalPlat * AccountGold.CurrencyThreshold;
#endregion
} }
} }

View file

@ -10,7 +10,7 @@ namespace Server.Accounting
{ {
public static bool Enabled = true; public static bool Enabled = true;
private static List<InvalidAccountAccessLog> m_List = new List<InvalidAccountAccessLog>(); private static readonly List<InvalidAccountAccessLog> m_List = new List<InvalidAccountAccessLog>();
public static void Initialize() public static void Initialize()
{ {
@ -75,8 +75,7 @@ namespace Server.Accounting
"{0}\t{1}\t{2}", "{0}\t{1}\t{2}",
DateTime.UtcNow, DateTime.UtcNow,
ns, ns,
accessLog.Counts accessLog.Counts);
);
} }
catch catch
{ {

View file

@ -18,14 +18,14 @@ namespace Server.Misc
public class AccountHandler public class AccountHandler
{ {
private static int MaxAccountsPerIP = 1; private static readonly int MaxAccountsPerIP = 1;
private static bool AutoAccountCreation = true; private static readonly bool AutoAccountCreation = true;
private static bool RestrictDeletion = !TestCenter.Enabled; private static readonly bool RestrictDeletion = !TestCenter.Enabled;
private static TimeSpan DeleteDelay = TimeSpan.FromDays(7.0); private static readonly TimeSpan DeleteDelay = TimeSpan.FromDays(7.0);
public static PasswordProtection ProtectPasswords = PasswordProtection.NewCrypt; public static PasswordProtection ProtectPasswords = PasswordProtection.NewCrypt;
private static CityInfo[] StartingCities = private static readonly CityInfo[] StartingCities =
{ {
new CityInfo("New Haven", "New Haven Bank", 1150168, 3667, 2625, 0), new CityInfo("New Haven", "New Haven Bank", 1150168, 3667, 2625, 0),
new CityInfo("Yew", "The Empath Abbey", 1075072, 633, 858, 0), new CityInfo("Yew", "The Empath Abbey", 1075072, 633, 858, 0),
@ -55,7 +55,7 @@ namespace Server.Misc
} }
*/ */
private static bool PasswordCommandEnabled = false; private static readonly bool PasswordCommandEnabled = false;
private static Dictionary<IPAddress, int> m_IPTable; private static Dictionary<IPAddress, int> m_IPTable;
@ -174,10 +174,10 @@ namespace Server.Misc
from.SendMessage( from.SendMessage(
"Your IP address does not match that which created this account. A page has been entered into the help system on your behalf."); "Your IP address does not match that which created this account. A page has been entered into the help system on your behalf.");
from.SendLocalizedMessage(501234, "", /* The next available Counselor/Game Master will respond as soon as possible.
0x35); /* The next available Counselor/Game Master will respond as soon as possible.
* Please check your Journal for messages every few minutes. * Please check your Journal for messages every few minutes.
*/ */
from.SendLocalizedMessage(501234, "", 0x35);
PageQueue.Enqueue(new PageEntry(from, PageQueue.Enqueue(new PageEntry(from,
$"[Automated: Change Password]<br>Desired password: {pass}<br>Current IP address: {ipAddress}<br>Account IP address: {accessList[0]}", $"[Automated: Change Password]<br>Desired password: {pass}<br>Current IP address: {ipAddress}<br>Account IP address: {accessList[0]}",
@ -222,8 +222,7 @@ namespace Server.Misc
state.Send(new CharacterListUpdate(acct)); state.Send(new CharacterListUpdate(acct));
} }
else if (m.AccessLevel == AccessLevel.Player && else if (m.AccessLevel == AccessLevel.Player &&
Region.Find(m.LogoutLocation, m.LogoutMap).IsPartOf<Jail>() Region.Find(m.LogoutLocation, m.LogoutMap).IsPartOf<Jail>()) // Don't need to check current location, if netstate is null, they're logged out
) //Don't need to check current location, if netstate is null, they're logged out
{ {
state.Send(new DeleteResult(DeleteResultType.BadRequest)); state.Send(new DeleteResult(DeleteResultType.BadRequest));
state.Send(new CharacterListUpdate(acct)); state.Send(new CharacterListUpdate(acct));

View file

@ -75,7 +75,6 @@ namespace Server.Accounting
using StreamWriter op = new StreamWriter(filePath); using StreamWriter op = new StreamWriter(filePath);
XmlTextWriter xml = new XmlTextWriter(op) { Formatting = Formatting.Indented, IndentChar = '\t', Indentation = 1 }; XmlTextWriter xml = new XmlTextWriter(op) { Formatting = Formatting.Indented, IndentChar = '\t', Indentation = 1 };
xml.WriteStartDocument(true); xml.WriteStartDocument(true);
xml.WriteStartElement("accounts"); xml.WriteStartElement("accounts");

View file

@ -164,8 +164,6 @@ namespace Server
* */ * */
} }
#region Firewall Entries
public interface IFirewallEntry public interface IFirewallEntry
{ {
bool IsBlocked(IPAddress address); bool IsBlocked(IPAddress address);
@ -173,7 +171,7 @@ namespace Server
public class IPFirewallEntry : IFirewallEntry public class IPFirewallEntry : IFirewallEntry
{ {
private IPAddress m_Address; private readonly IPAddress m_Address;
public IPFirewallEntry(IPAddress address) => m_Address = address; public IPFirewallEntry(IPAddress address) => m_Address = address;
@ -203,8 +201,8 @@ namespace Server
public class CIDRFirewallEntry : IFirewallEntry public class CIDRFirewallEntry : IFirewallEntry
{ {
private int m_CIDRLength; private readonly int m_CIDRLength;
private IPAddress m_CIDRPrefix; private readonly IPAddress m_CIDRPrefix;
public CIDRFirewallEntry(IPAddress cidrPrefix, int cidrLength) public CIDRFirewallEntry(IPAddress cidrPrefix, int cidrLength)
{ {
@ -240,7 +238,7 @@ namespace Server
public class WildcardIPFirewallEntry : IFirewallEntry public class WildcardIPFirewallEntry : IFirewallEntry
{ {
private string m_Entry; private readonly string m_Entry;
private bool m_Valid; private bool m_Valid;
@ -268,7 +266,5 @@ namespace Server
public override int GetHashCode() => m_Entry.GetHashCode(); public override int GetHashCode() => m_Entry.GetHashCode();
} }
#endregion
} }
} }

View file

@ -9,20 +9,20 @@ namespace Server.Commands
{ {
public class Add public class Add
{ {
private static Type m_EntityType = typeof(IEntity); private static readonly Type m_EntityType = typeof(IEntity);
private static Type m_ConstructibleType = typeof(ConstructibleAttribute); private static readonly Type m_ConstructibleType = typeof(ConstructibleAttribute);
private static Type m_EnumType = typeof(Enum); private static readonly Type m_EnumType = typeof(Enum);
private static Type m_TypeType = typeof(Type); private static readonly Type m_TypeType = typeof(Type);
private static Type m_ParsableType = typeof(ParsableAttribute); private static readonly Type m_ParsableType = typeof(ParsableAttribute);
private static Type[] m_ParseTypes = { typeof(string) }; private static readonly Type[] m_ParseTypes = { typeof(string) };
private static object[] m_ParseArgs = new object[1]; private static readonly object[] m_ParseArgs = new object[1];
private static Type[] m_SignedNumerics = private static readonly Type[] m_SignedNumerics =
{ {
typeof(long), typeof(long),
typeof(int), typeof(int),
@ -30,7 +30,7 @@ namespace Server.Commands
typeof(sbyte) typeof(sbyte)
}; };
private static Type[] m_UnsignedNumerics = private static readonly Type[] m_UnsignedNumerics =
{ {
typeof(ulong), typeof(ulong),
typeof(uint), typeof(uint),
@ -198,7 +198,6 @@ namespace Server.Commands
if (!paramList[j].HasDefaultValue) if (!paramList[j].HasDefaultValue)
totalParams += 1; totalParams += 1;
if (args.Length >= totalParams && args.Length <= paramList.Length) if (args.Length >= totalParams && args.Length <= paramList.Length)
{ {
object[] paramValues = ParseValues(paramList, args); object[] paramValues = ParseValues(paramList, args);
@ -667,10 +666,10 @@ namespace Server.Commands
private class TileState private class TileState
{ {
public string[] m_Args; public readonly string[] m_Args;
public int m_FixedZ; public readonly int m_FixedZ;
public bool m_Outline; public readonly bool m_Outline;
public TileZType m_ZType; public readonly TileZType m_ZType;
public TileState(TileZType zType, int fixedZ, string[] args, bool outline) public TileState(TileZType zType, int fixedZ, string[] args, bool outline)
{ {

View file

@ -199,15 +199,15 @@ namespace Server.Commands
{ {
argString = ""; argString = "";
command = Command.ToLower(); command = Command.ToLower();
args = new string[0]; args = Array.Empty<string>();
} }
} }
} }
public class BatchGump : BaseGridGump public class BatchGump : BaseGridGump
{ {
private Batch m_Batch; private readonly Batch m_Batch;
private Mobile m_From; private readonly Mobile m_From;
public BatchGump(Mobile from, Batch batch) : base(30, 30) public BatchGump(Mobile from, Batch batch) : base(30, 30)
{ {
@ -356,8 +356,8 @@ namespace Server.Commands
public class BatchScopeGump : BaseGridGump public class BatchScopeGump : BaseGridGump
{ {
private Batch m_Batch; private readonly Batch m_Batch;
private Mobile m_From; private readonly Mobile m_From;
public BatchScopeGump(Mobile from, Batch batch) : base(30, 30) public BatchScopeGump(Mobile from, Batch batch) : base(30, 30)
{ {

View file

@ -14,10 +14,10 @@ namespace Server
private class PickTarget : Target private class PickTarget : Target
{ {
private BoundingBoxCallback m_Callback; private readonly BoundingBoxCallback m_Callback;
private bool m_First; private readonly bool m_First;
private Map m_Map; private readonly Map m_Map;
private Point3D m_Store; private readonly Point3D m_Store;
public PickTarget(BoundingBoxCallback callback) : this(Point3D.Zero, true, null, callback) public PickTarget(BoundingBoxCallback callback) : this(Point3D.Zero, true, null, callback)
{ {

View file

@ -64,7 +64,7 @@ namespace Server.Commands
} }
} }
private static PropertyInfo[] _mobProps = private static readonly PropertyInfo[] _mobProps =
typeof(Mobile).GetProperties(BindingFlags.Public | BindingFlags.Instance) typeof(Mobile).GetProperties(BindingFlags.Public | BindingFlags.Instance)
.Where(prop => prop.CanRead && prop.CanWrite).ToArray(); .Where(prop => prop.CanRead && prop.CanWrite).ToArray();

View file

@ -1,9 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using Server.Engines.Quests.Haven; using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro; using Server.Engines.Quests.Necro;
using Server.Items; using Server.Items;
@ -12,7 +10,7 @@ using Server.Utilities;
namespace Server.Commands namespace Server.Commands
{ {
public class Decorate public static class Decorate
{ {
private static Mobile m_Mobile; private static Mobile m_Mobile;
private static int m_Count; private static int m_Count;
@ -60,22 +58,22 @@ namespace Server.Commands
public class DecorationList public class DecorationList
{ {
private static Type typeofStatic = typeof(Static); private static readonly Type typeofStatic = typeof(Static);
private static Type typeofLocalizedStatic = typeof(LocalizedStatic); private static readonly Type typeofLocalizedStatic = typeof(LocalizedStatic);
private static Type typeofBaseDoor = typeof(BaseDoor); private static readonly Type typeofBaseDoor = typeof(BaseDoor);
private static Type typeofAnkhWest = typeof(AnkhWest); private static readonly Type typeofAnkhWest = typeof(AnkhWest);
private static Type typeofAnkhNorth = typeof(AnkhNorth); private static readonly Type typeofAnkhNorth = typeof(AnkhNorth);
private static Type typeofBeverage = typeof(BaseBeverage); private static readonly Type typeofBeverage = typeof(BaseBeverage);
private static Type typeofLocalizedSign = typeof(LocalizedSign); private static readonly Type typeofLocalizedSign = typeof(LocalizedSign);
private static Type typeofMarkContainer = typeof(MarkContainer); private static readonly Type typeofMarkContainer = typeof(MarkContainer);
private static Type typeofWarningItem = typeof(WarningItem); private static readonly Type typeofWarningItem = typeof(WarningItem);
private static Type typeofHintItem = typeof(HintItem); private static readonly Type typeofHintItem = typeof(HintItem);
private static Type typeofCannon = typeof(Cannon); private static readonly Type typeofCannon = typeof(Cannon);
private static Type typeofSerpentPillar = typeof(SerpentPillar); private static readonly Type typeofSerpentPillar = typeof(SerpentPillar);
private static Queue<Item> m_DeleteQueue = new Queue<Item>(); private static readonly Queue<Item> m_DeleteQueue = new Queue<Item>();
private static string[] m_EmptyParams = new string[0]; private static readonly string[] m_EmptyParams = Array.Empty<string>();
private List<DecorationEntry> m_Entries; private List<DecorationEntry> m_Entries;
private int m_ItemID; private int m_ItemID;
private string[] m_Params; private string[] m_Params;
@ -934,14 +932,13 @@ namespace Server.Commands
for (int j = 0; j < maps.Length; ++j) for (int j = 0; j < maps.Length; ++j)
{ {
try try
{ {
item ??= Construct(); item ??= Construct();
} }
catch (TypeInitializationException e) catch (TypeInitializationException e)
{ {
Console.WriteLine($"{nameof(Generate)}() failed to load type: {e.TypeName}: {e.InnerException.Message}"); Console.WriteLine($"{nameof(Generate)}() failed to load type: {e.TypeName}: {e.InnerException?.Message}");
continue; continue;
} }
@ -1087,7 +1084,7 @@ namespace Server.Commands
public string Extra { get; } public string Extra { get; }
public void Pop(out string v, ref string line) public static void Pop(out string v, ref string line)
{ {
int space = line.IndexOf(' '); int space = line.IndexOf(' ');

View file

@ -33,7 +33,6 @@ namespace Server.Commands
Generate("Data/Decoration/RuinedMaginciaTram", Map.Trammel); Generate("Data/Decoration/RuinedMaginciaTram", Map.Trammel);
Generate("Data/Decoration/RuinedMaginciaFel", Map.Felucca); Generate("Data/Decoration/RuinedMaginciaFel", Map.Felucca);
m_Mobile.SendMessage("World generating complete. {0} items were generated.", m_Count); m_Mobile.SendMessage("World generating complete. {0} items were generated.", m_Count);
} }
@ -56,22 +55,22 @@ namespace Server.Commands
public class DecorationListMag public class DecorationListMag
{ {
private static Type typeofStatic = typeof(Static); private static readonly Type typeofStatic = typeof(Static);
private static Type typeofLocalizedStatic = typeof(LocalizedStatic); private static readonly Type typeofLocalizedStatic = typeof(LocalizedStatic);
private static Type typeofBaseDoor = typeof(BaseDoor); private static readonly Type typeofBaseDoor = typeof(BaseDoor);
private static Type typeofAnkhWest = typeof(AnkhWest); private static readonly Type typeofAnkhWest = typeof(AnkhWest);
private static Type typeofAnkhNorth = typeof(AnkhNorth); private static readonly Type typeofAnkhNorth = typeof(AnkhNorth);
private static Type typeofBeverage = typeof(BaseBeverage); private static readonly Type typeofBeverage = typeof(BaseBeverage);
private static Type typeofLocalizedSign = typeof(LocalizedSign); private static readonly Type typeofLocalizedSign = typeof(LocalizedSign);
private static Type typeofMarkContainer = typeof(MarkContainer); private static readonly Type typeofMarkContainer = typeof(MarkContainer);
private static Type typeofWarningItem = typeof(WarningItem); private static readonly Type typeofWarningItem = typeof(WarningItem);
private static Type typeofHintItem = typeof(HintItem); private static readonly Type typeofHintItem = typeof(HintItem);
private static Type typeofCannon = typeof(Cannon); private static readonly Type typeofCannon = typeof(Cannon);
private static Type typeofSerpentPillar = typeof(SerpentPillar); private static readonly Type typeofSerpentPillar = typeof(SerpentPillar);
private static Queue m_DeleteQueue = new Queue(); private static readonly Queue m_DeleteQueue = new Queue();
private static string[] m_EmptyParams = new string[0]; private static readonly string[] m_EmptyParams = Array.Empty<string>();
private List<DecorationEntryMag> m_Entries; private List<DecorationEntryMag> m_Entries;
private int m_ItemID; private int m_ItemID;
private string[] m_Params; private string[] m_Params;

View file

@ -243,7 +243,7 @@ namespace Server.Commands
nameBuilder.Append(sanitizedName); nameBuilder.Append(sanitizedName);
fnamBuilder.Append("T"); fnamBuilder.Append("T");
if (DontLink(typeArguments[i])) //if ( DontLink( typeArguments[i].Name ) ) if (DontLink(typeArguments[i]))
linkBuilder.Append($"<font color=\"blue\">{aliasedName}</font>"); linkBuilder.Append($"<font color=\"blue\">{aliasedName}</font>");
else else
linkBuilder.Append( linkBuilder.Append(
@ -416,9 +416,13 @@ namespace Server.Commands
private class TypeInfo private class TypeInfo
{ {
public List<TypeInfo> m_Derived, m_Nested; public List<TypeInfo> m_Derived, m_Nested;
private string m_FileName, m_TypeName, m_LinkName; private readonly string m_FileName;
public Type[] m_Interfaces; private readonly string m_TypeName;
public Type m_Type, m_BaseType, m_Declaring; private readonly string m_LinkName;
public readonly Type[] m_Interfaces;
public readonly Type m_Type;
public readonly Type m_BaseType;
public readonly Type m_Declaring;
public TypeInfo(Type type) public TypeInfo(Type type)
{ {
@ -437,8 +441,6 @@ namespace Server.Commands
public string LinkName(string dirRoot) => m_LinkName.Replace("@directory@", dirRoot); public string LinkName(string dirRoot) => m_LinkName.Replace("@directory@", dirRoot);
} }
#region FileSystem
private static readonly char[] ReplaceChars = "<>".ToCharArray(); private static readonly char[] ReplaceChars = "<>".ToCharArray();
public static string GetFileName(string root, string name, string ext) public static string GetFileName(string root, string name, string ext)
@ -460,7 +462,7 @@ namespace Server.Commands
return file; return file;
} }
private static string m_RootDirectory = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]); private static readonly string m_RootDirectory = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
private static void EnsureDirectory(string path) private static void EnsureDirectory(string path)
{ {
@ -482,11 +484,7 @@ namespace Server.Commands
private static StreamWriter GetWriter(string path) => new StreamWriter(Path.Combine(m_RootDirectory, path)); private static StreamWriter GetWriter(string path) => new StreamWriter(Path.Combine(m_RootDirectory, path));
#endregion private static readonly string[,] m_Aliases =
#region GetPair
private static string[,] m_Aliases =
{ {
{ "System.Object", "<font color=\"blue\">object</font>" }, { "System.Object", "<font color=\"blue\">object</font>" },
{ "System.String", "<font color=\"blue\">string</font>" }, { "System.String", "<font color=\"blue\">string</font>" },
@ -506,7 +504,7 @@ namespace Server.Commands
{ "System.Void", "<font color=\"blue\">void</font>" } { "System.Void", "<font color=\"blue\">void</font>" }
}; };
private static int m_AliasLength = m_Aliases.GetLength(0); private static readonly int m_AliasLength = m_Aliases.GetLength(0);
public static string GetPair(Type varType, string name, bool ignoreRef) public static string GetPair(Type varType, string name, bool ignoreRef)
{ {
@ -600,10 +598,6 @@ namespace Server.Commands
return string.Concat(prepend, aliased, append, name); return string.Concat(prepend, aliased, append, name);
} }
#endregion
#region Root documentation
private static bool Document() private static bool Document()
{ {
try try
@ -634,7 +628,6 @@ namespace Server.Commands
List<Assembly> assemblies = new List<Assembly> { Core.Assembly }; List<Assembly> assemblies = new List<Assembly> { Core.Assembly };
foreach (Assembly asm in AssemblyHandler.Assemblies) foreach (Assembly asm in AssemblyHandler.Assemblies)
assemblies.Add(asm); assemblies.Add(asm);
@ -713,10 +706,6 @@ namespace Server.Commands
html.WriteLine("</html>"); html.WriteLine("</html>");
} }
#endregion
#region BODs
private const int Iron = 0xCCCCDD; private const int Iron = 0xCCCCDD;
private const int DullCopper = 0xAAAAAA; private const int DullCopper = 0xAAAAAA;
private const int ShadowIron = 0x777799; private const int ShadowIron = 0x777799;
@ -763,7 +752,6 @@ namespace Server.Commands
html.WriteLine(" <br><br>"); html.WriteLine(" <br><br>");
html.WriteLine(" <br><br>"); html.WriteLine(" <br><br>");
sbod.Type = typeof(PlateArms); sbod.Type = typeof(PlateArms);
WriteSmithBODHeader(html, "(Small) Armor: Normal"); WriteSmithBODHeader(html, "(Small) Armor: Normal");
@ -923,8 +911,6 @@ namespace Server.Commands
} }
} }
#region Tailor Bods
private static void WriteTailorLBOD(StreamWriter html, string name, SmallBulkEntry[] entries, bool expandCloth, private static void WriteTailorLBOD(StreamWriter html, string name, SmallBulkEntry[] entries, bool expandCloth,
bool expandPlain) bool expandPlain)
{ {
@ -1281,10 +1267,6 @@ namespace Server.Commands
html.WriteLine(" </tr>"); html.WriteLine(" </tr>");
} }
#endregion
#region Smith Bods
private static void WriteSmithLBOD(StreamWriter html, string name, SmallBulkEntry[] entries) private static void WriteSmithLBOD(StreamWriter html, string name, SmallBulkEntry[] entries)
{ {
LargeBOD lbod = new LargeSmithBOD(); LargeBOD lbod = new LargeSmithBOD();
@ -1564,12 +1546,6 @@ namespace Server.Commands
html.WriteLine(" </tr>"); html.WriteLine(" </tr>");
} }
#endregion
#endregion
#region Bodies
public static List<BodyEntry> LoadBodies() public static List<BodyEntry> LoadBodies()
{ {
List<BodyEntry> list = new List<BodyEntry>(); List<BodyEntry> list = new List<BodyEntry>();
@ -1689,10 +1665,6 @@ namespace Server.Commands
html.WriteLine("</html>"); html.WriteLine("</html>");
} }
#endregion
#region Speech
private static void DocumentKeywords() private static void DocumentKeywords()
{ {
List<Dictionary<int, SpeechEntry>> tables = LoadSpeechFile(); List<Dictionary<int, SpeechEntry>> tables = LoadSpeechFile();
@ -1833,10 +1805,6 @@ namespace Server.Commands
return tables; return tables;
} }
#endregion
#region Commands
public class DocCommandEntry public class DocCommandEntry
{ {
public DocCommandEntry(AccessLevel accessLevel, string name, string[] aliases, string usage, string description) public DocCommandEntry(AccessLevel accessLevel, string name, string[] aliases, string usage, string description)
@ -2112,12 +2080,10 @@ namespace Server.Commands
html.WriteLine("</tr>"); html.WriteLine("</tr>");
} }
#endregion private static readonly Type typeofItem = typeof(Item);
private static readonly Type typeofMobile = typeof(Mobile);
#region Constructible Objects private static readonly Type typeofMap = typeof(Map);
private static readonly Type typeofCustomEnum = typeof(CustomEnumAttribute);
private static Type typeofItem = typeof(Item), typeofMobile = typeof(Mobile), typeofMap = typeof(Map);
private static Type typeofCustomEnum = typeof(CustomEnumAttribute);
private static bool IsConstructible(Type t, out bool isItem) => (isItem = typeofItem.IsAssignableFrom(t)) || typeofMobile.IsAssignableFrom(t); private static bool IsConstructible(Type t, out bool isItem) => (isItem = typeofItem.IsAssignableFrom(t)) || typeofMobile.IsAssignableFrom(t);
@ -2226,13 +2192,9 @@ namespace Server.Commands
html.WriteLine("</td></tr>"); html.WriteLine("</td></tr>");
} }
#endregion
#region Tooltips
private const string HtmlNewLine = "&#13;"; private const string HtmlNewLine = "&#13;";
private static object[,] m_Tooltips = private static readonly object[,] m_Tooltips =
{ {
{ typeof(byte), "Numeric value in the range from 0 to 255, inclusive." }, { typeof(byte), "Numeric value in the range from 0 to 255, inclusive." },
{ typeof(sbyte), "Numeric value in the range from negative 128 to positive 127, inclusive." }, { typeof(sbyte), "Numeric value in the range from negative 128 to positive 127, inclusive." },
@ -2319,10 +2281,6 @@ namespace Server.Commands
return ""; return "";
} }
#endregion
#region Const Strings
private const string RefString = "<font color=\"blue\">ref</font> "; private const string RefString = "<font color=\"blue\">ref</font> ";
private const string GetString = " <font color=\"blue\">get</font>;"; private const string GetString = " <font color=\"blue\">get</font>;";
private const string SetString = " <font color=\"blue\">set</font>;"; private const string SetString = " <font color=\"blue\">set</font>;";
@ -2334,10 +2292,6 @@ namespace Server.Commands
private const string CtorString = "(<font color=\"blue\">ctor</font>) "; private const string CtorString = "(<font color=\"blue\">ctor</font>) ";
private const string StaticString = "(<font color=\"blue\">static</font>) "; private const string StaticString = "(<font color=\"blue\">static</font>) ";
#endregion
#region Write[...]
private static void WriteEnum(TypeInfo info, StreamWriter typeHtml) private static void WriteEnum(TypeInfo info, StreamWriter typeHtml)
{ {
Type type = info.m_Type; Type type = info.m_Type;
@ -2600,12 +2554,8 @@ namespace Server.Commands
html.WriteLine(")<br>"); html.WriteLine(")<br>");
} }
#endregion
} }
#region BodyEntry & BodyType
public enum ModelBodyType public enum ModelBodyType
{ {
Invalid = -1, Invalid = -1,
@ -2657,6 +2607,4 @@ namespace Server.Commands
return a?.Name.CompareTo(b?.Name) ?? 1; return a?.Name.CompareTo(b?.Name) ?? 1;
} }
} }
#endregion
} }

View file

@ -1,8 +1,8 @@
using System;
using System.Reflection;
using Server.Items; using Server.Items;
using Server.Targeting; using Server.Targeting;
using Server.Utilities; using Server.Utilities;
using System;
using System.Reflection;
namespace Server.Commands namespace Server.Commands
{ {
@ -54,8 +54,8 @@ namespace Server.Commands
private class DupeTarget : Target private class DupeTarget : Target
{ {
private int m_Amount; private readonly int m_Amount;
private bool m_InBag; private readonly bool m_InBag;
public DupeTarget(bool inbag, int amount) public DupeTarget(bool inbag, int amount)
: base(15, false, TargetFlags.None) : base(15, false, TargetFlags.None)

View file

@ -13,9 +13,9 @@ namespace Server.Commands
{ {
private static CategoryEntry m_RootItems, m_RootMobiles; private static CategoryEntry m_RootItems, m_RootMobiles;
private static Type typeofItem = typeof(Item); private static readonly Type typeofItem = typeof(Item);
private static Type typeofMobile = typeof(Mobile); private static readonly Type typeofMobile = typeof(Mobile);
private static Type typeofConstructible = typeof(ConstructibleAttribute); private static readonly Type typeofConstructible = typeof(ConstructibleAttribute);
public static CategoryEntry Items public static CategoryEntry Items
{ {
@ -286,8 +286,8 @@ namespace Server.Commands
{ {
Parent = parent; Parent = parent;
Title = title; Title = title;
SubCategories = subCats ?? new CategoryEntry[0]; SubCategories = subCats ?? Array.Empty<CategoryEntry>();
Matches = new Type[0]; Matches = Array.Empty<Type>();
Matched = new List<CategoryTypeEntry>(); Matched = new List<CategoryTypeEntry>();
} }

View file

@ -1,10 +1,10 @@
using Server.Items;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
using Server.Items;
using Server.Json; using Server.Json;
namespace Server.Commands namespace Server.Commands
@ -122,7 +122,7 @@ namespace Server.Commands
public int Count { get; private set; } public int Count { get; private set; }
public int DelCount { get; private set; } public int DelCount { get; private set; }
private static bool IsWithinZ(int delta) => -12 <= delta && delta <= 12; private static bool IsWithinZ(int delta) => delta >= -12 && delta <= 12;
public static int DeleteTeleporters(Location location) public static int DeleteTeleporters(Location location)
{ {

View file

@ -12,8 +12,8 @@ namespace Server.Commands.Generic
public abstract class BaseCommand public abstract class BaseCommand
{ {
private List<MessageEntry> m_Responses = new List<MessageEntry>(); private readonly List<MessageEntry> m_Responses = new List<MessageEntry>();
private List<MessageEntry> m_Failures = new List<MessageEntry>(); private readonly List<MessageEntry> m_Failures = new List<MessageEntry>();
public bool ListOptimized { get; set; } public bool ListOptimized { get; set; }
@ -117,7 +117,7 @@ namespace Server.Commands.Generic
private class MessageEntry private class MessageEntry
{ {
public int m_Count; public int m_Count;
public string m_Message; public readonly string m_Message;
public MessageEntry(string message) public MessageEntry(string message)
{ {

View file

@ -348,7 +348,7 @@ namespace Server.Commands.Generic
public class TellCommand : BaseCommand public class TellCommand : BaseCommand
{ {
private bool m_InGump; private readonly bool m_InGump;
public TellCommand(bool inGump) public TellCommand(bool inGump)
{ {
@ -683,8 +683,8 @@ namespace Server.Commands.Generic
public class AliasedSetCommand : BaseCommand public class AliasedSetCommand : BaseCommand
{ {
private string m_Name; private readonly string m_Name;
private string m_Value; private readonly string m_Value;
public AliasedSetCommand(AccessLevel level, string command, string name, string value, ObjectTypes objects) public AliasedSetCommand(AccessLevel level, string command, string name, string value, ObjectTypes objects)
{ {
@ -830,7 +830,7 @@ namespace Server.Commands.Generic
public class KillCommand : BaseCommand public class KillCommand : BaseCommand
{ {
private bool m_Value; private readonly bool m_Value;
public KillCommand(bool value) public KillCommand(bool value)
{ {
@ -916,7 +916,7 @@ namespace Server.Commands.Generic
public class HideCommand : BaseCommand public class HideCommand : BaseCommand
{ {
private bool m_Value; private readonly bool m_Value;
public HideCommand(bool value) public HideCommand(bool value)
{ {
@ -1011,7 +1011,7 @@ namespace Server.Commands.Generic
public class KickCommand : BaseCommand public class KickCommand : BaseCommand
{ {
private bool m_Ban; private readonly bool m_Ban;
public KickCommand(bool ban) public KickCommand(bool ban)
{ {

View file

@ -35,7 +35,7 @@ namespace Server.Commands.Generic
{ {
house = null; house = null;
if (item == null || item is BaseMulti || item is HouseSign || staticsOnly && !(item is Static)) if (item == null || item is BaseMulti || item is HouseSign || (staticsOnly && !(item is Static)))
return DesignInsertResult.InvalidItem; return DesignInsertResult.InvalidItem;
house = BaseHouse.FindHouseAt(item) as HouseFoundation; house = BaseHouse.FindHouseAt(item) as HouseFoundation;
@ -69,8 +69,6 @@ namespace Server.Commands.Generic
return true; return true;
} }
#region Single targeting mode
public override void Execute(CommandEventArgs e, object obj) public override void Execute(CommandEventArgs e, object obj)
{ {
Target t = new DesignInsertTarget(new List<HouseFoundation>(), e.Length < 1 || !e.GetBoolean(0)); Target t = new DesignInsertTarget(new List<HouseFoundation>(), e.Length < 1 || !e.GetBoolean(0));
@ -79,8 +77,8 @@ namespace Server.Commands.Generic
private class DesignInsertTarget : Target private class DesignInsertTarget : Target
{ {
private List<HouseFoundation> m_Foundations; private readonly List<HouseFoundation> m_Foundations;
private bool m_StaticsOnly; private readonly bool m_StaticsOnly;
public DesignInsertTarget(List<HouseFoundation> foundations, bool staticsOnly) public DesignInsertTarget(List<HouseFoundation> foundations, bool staticsOnly)
: base(-1, false, TargetFlags.None) : base(-1, false, TargetFlags.None)
@ -136,10 +134,6 @@ namespace Server.Commands.Generic
} }
} }
#endregion
#region Area targeting mode
public override void ExecuteList(CommandEventArgs e, List<object> list) public override void ExecuteList(CommandEventArgs e, List<object> list)
{ {
Mobile from = e.Mobile; Mobile from = e.Mobile;
@ -197,7 +191,5 @@ namespace Server.Commands.Generic
Flush(from, flushToLog); Flush(from, flushToLog);
} }
#endregion
} }
} }

View file

@ -25,7 +25,6 @@ namespace Server.Commands.Generic
{ {
List<string> columns = new List<string> { "Object" }; List<string> columns = new List<string> { "Object" };
if (e.Length > 0) if (e.Length > 0)
{ {
int offset = 0; int offset = 0;
@ -50,13 +49,13 @@ namespace Server.Commands.Generic
{ {
private const int EntriesPerPage = 15; private const int EntriesPerPage = 15;
private string[] m_Columns; private readonly string[] m_Columns;
private Mobile m_From; private readonly Mobile m_From;
private List<object> m_List; private readonly List<object> m_List;
private int m_Page; private readonly int m_Page;
private object m_Select; private readonly object m_Select;
public InterfaceGump(Mobile from, string[] columns, List<object> list, int page, object select) : base(30, 30) public InterfaceGump(Mobile from, string[] columns, List<object> list, int page, object select) : base(30, 30)
{ {
@ -241,13 +240,13 @@ namespace Server.Commands.Generic
public class InterfaceItemGump : BaseGridGump public class InterfaceItemGump : BaseGridGump
{ {
private string[] m_Columns; private readonly string[] m_Columns;
private Mobile m_From; private readonly Mobile m_From;
private Item m_Item; private readonly Item m_Item;
private List<object> m_List; private readonly List<object> m_List;
private int m_Page; private readonly int m_Page;
public InterfaceItemGump(Mobile from, string[] columns, List<object> list, int page, Item item) : base(30, 30) public InterfaceItemGump(Mobile from, string[] columns, List<object> list, int page, Item item) : base(30, 30)
{ {
@ -376,13 +375,13 @@ namespace Server.Commands.Generic
public class InterfaceMobileGump : BaseGridGump public class InterfaceMobileGump : BaseGridGump
{ {
private string[] m_Columns; private readonly string[] m_Columns;
private Mobile m_From; private readonly Mobile m_From;
private List<object> m_List; private readonly List<object> m_List;
private Mobile m_Mobile; private readonly Mobile m_Mobile;
private int m_Page; private readonly int m_Page;
public InterfaceMobileGump(Mobile from, string[] columns, List<object> list, int page, Mobile mob) public InterfaceMobileGump(Mobile from, string[] columns, List<object> list, int page, Mobile mob)
: base(30, 30) : base(30, 30)

View file

@ -1,8 +1,8 @@
using Server.Utilities;
using System; using System;
using System.Globalization; using System.Globalization;
using System.Reflection; using System.Reflection;
using System.Reflection.Emit; using System.Reflection.Emit;
using Server.Utilities;
namespace Server.Commands.Generic namespace Server.Commands.Generic
{ {
@ -119,8 +119,7 @@ namespace Server.Commands.Generic
BindingFlags.Public | BindingFlags.Static, BindingFlags.Public | BindingFlags.Static,
null, null,
new[] { typeof(string), typeof(NumberStyles) }, new[] { typeof(string), typeof(NumberStyles) },
null null);
);
if (parseNumber != null) if (parseNumber != null)
{ {
@ -142,8 +141,7 @@ namespace Server.Commands.Generic
BindingFlags.Public | BindingFlags.Static, BindingFlags.Public | BindingFlags.Static,
null, null,
new[] { typeof(string) }, new[] { typeof(string) },
null null);
);
parseMethod = parseGeneral; parseMethod = parseGeneral;
parseArgs = new object[] { toParse }; parseArgs = new object[] { toParse };
@ -158,13 +156,11 @@ namespace Server.Commands.Generic
Field = typeBuilder.DefineField( Field = typeBuilder.DefineField(
fieldName, fieldName,
Type, Type,
FieldAttributes.Private | FieldAttributes.InitOnly FieldAttributes.Private | FieldAttributes.InitOnly);
);
// parseMethod.Invoke(null, // parseMethod.Invoke(null,
// parseArgs.Length == 2 ? new object[] {toParse, (int) parseArgs[1]} : new object[] {toParse}); // parseArgs.Length == 2 ? new object[] {toParse, (int) parseArgs[1]} : new object[] {toParse});
il.Emit(OpCodes.Ldarg_0); il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldstr, toParse); il.Emit(OpCodes.Ldstr, toParse);
@ -179,8 +175,7 @@ namespace Server.Commands.Generic
else else
{ {
throw new InvalidOperationException( throw new InvalidOperationException(
$"Unable to convert string \"{Value}\" into type '{Type}'." $"Unable to convert string \"{Value}\" into type '{Type}'.");
);
} }
} }
} }
@ -215,9 +210,9 @@ namespace Server.Commands.Generic
public sealed class StringCondition : PropertyCondition public sealed class StringCondition : PropertyCondition
{ {
private bool m_IgnoreCase; private readonly bool m_IgnoreCase;
private StringOperator m_Operator; private readonly StringOperator m_Operator;
private PropertyValue m_Value; private readonly PropertyValue m_Value;
public StringCondition(Property property, bool not, StringOperator op, object value, bool ignoreCase) public StringCondition(Property property, bool not, StringOperator op, object value, bool ignoreCase)
: base(property, not) : base(property, not)
@ -280,9 +275,7 @@ namespace Server.Commands.Generic
typeof(string), typeof(string),
typeof(string) typeof(string)
}, },
null null));
)
);
emitter.Chain(m_Property); emitter.Chain(m_Property);
m_Value.Load(emitter); m_Value.Load(emitter);
@ -319,9 +312,7 @@ namespace Server.Commands.Generic
{ {
typeof(string) typeof(string)
}, },
null null));
)
);
m_Value.Load(emitter); m_Value.Load(emitter);
@ -347,8 +338,8 @@ namespace Server.Commands.Generic
public sealed class ComparisonCondition : PropertyCondition public sealed class ComparisonCondition : PropertyCondition
{ {
private ComparisonOperator m_Operator; private readonly ComparisonOperator m_Operator;
private PropertyValue m_Value; private readonly PropertyValue m_Value;
public ComparisonCondition(Property property, bool not, ComparisonOperator op, object value) public ComparisonCondition(Property property, bool not, ComparisonOperator op, object value)
: base(property, not) : base(property, not)
@ -369,7 +360,7 @@ namespace Server.Commands.Generic
bool inverse = false; bool inverse = false;
bool couldCompare = bool couldCompare =
emitter.CompareTo(1, delegate { m_Value.Load(emitter); }); emitter.CompareTo(1, () => { m_Value.Load(emitter); });
if (couldCompare) if (couldCompare)
{ {
@ -449,17 +440,12 @@ namespace Server.Commands.Generic
TypeBuilder typeBuilder = assembly.DefineType( TypeBuilder typeBuilder = assembly.DefineType(
$"__conditional{index}", $"__conditional{index}",
TypeAttributes.Public, TypeAttributes.Public,
typeof(object) typeof(object));
);
#region Constructor
{ {
ConstructorBuilder ctor = typeBuilder.DefineConstructor( ConstructorBuilder ctor = typeBuilder.DefineConstructor(
MethodAttributes.Public, MethodAttributes.Public,
CallingConventions.Standard, CallingConventions.Standard,
Type.EmptyTypes Type.EmptyTypes);
);
ILGenerator il = ctor.GetILGenerator(); ILGenerator il = ctor.GetILGenerator();
@ -474,16 +460,9 @@ namespace Server.Commands.Generic
il.Emit(OpCodes.Ret); il.Emit(OpCodes.Ret);
} }
#endregion
#region IComparer
typeBuilder.AddInterfaceImplementation(typeof(IConditional)); typeBuilder.AddInterfaceImplementation(typeof(IConditional));
MethodBuilder compareMethod; MethodBuilder compareMethod;
#region Compare
{ {
MethodEmitter emitter = new MethodEmitter(typeBuilder); MethodEmitter emitter = new MethodEmitter(typeBuilder);
@ -531,17 +510,11 @@ namespace Server.Commands.Generic
new[] new[]
{ {
typeof(object) typeof(object)
} }));
)
);
compareMethod = emitter.Method; compareMethod = emitter.Method;
} }
#endregion
#endregion
Type conditionalType = typeBuilder.CreateType(); Type conditionalType = typeBuilder.CreateType();
return (IConditional)ActivatorUtil.CreateInstance(conditionalType); return (IConditional)ActivatorUtil.CreateInstance(conditionalType);

View file

@ -1,8 +1,8 @@
using Server.Utilities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Reflection.Emit; using System.Reflection.Emit;
using Server.Utilities;
namespace Server.Commands.Generic namespace Server.Commands.Generic
{ {
@ -13,17 +13,12 @@ namespace Server.Commands.Generic
TypeBuilder typeBuilder = assembly.DefineType( TypeBuilder typeBuilder = assembly.DefineType(
"__distinct", "__distinct",
TypeAttributes.Public, TypeAttributes.Public,
typeof(object) typeof(object));
);
#region Constructor
{ {
ConstructorBuilder ctor = typeBuilder.DefineConstructor( ConstructorBuilder ctor = typeBuilder.DefineConstructor(
MethodAttributes.Public, MethodAttributes.Public,
CallingConventions.Standard, CallingConventions.Standard,
Type.EmptyTypes Type.EmptyTypes);
);
ILGenerator il = ctor.GetILGenerator(); ILGenerator il = ctor.GetILGenerator();
@ -36,16 +31,9 @@ namespace Server.Commands.Generic
il.Emit(OpCodes.Ret); il.Emit(OpCodes.Ret);
} }
#endregion
#region IComparer
typeBuilder.AddInterfaceImplementation(typeof(IComparer<T>)); typeBuilder.AddInterfaceImplementation(typeof(IComparer<T>));
MethodBuilder compareMethod; MethodBuilder compareMethod;
#region Compare
{ {
MethodEmitter emitter = new MethodEmitter(typeBuilder); MethodEmitter emitter = new MethodEmitter(typeBuilder);
@ -78,7 +66,7 @@ namespace Server.Commands.Generic
if (i > 0) if (i > 0)
{ {
emitter.LoadLocal(v); emitter.LoadLocal(v);
emitter.BranchIfTrue(end); // if ( v != 0 ) return v; emitter.BranchIfTrue(end);
} }
Property prop = props[i]; Property prop = props[i];
@ -87,7 +75,7 @@ namespace Server.Commands.Generic
emitter.Chain(prop); emitter.Chain(prop);
bool couldCompare = bool couldCompare =
emitter.CompareTo(1, delegate emitter.CompareTo(1, () =>
{ {
emitter.LoadLocal(b); emitter.LoadLocal(b);
emitter.Chain(prop); emitter.Chain(prop);
@ -112,23 +100,12 @@ namespace Server.Commands.Generic
{ {
typeof(T), typeof(T),
typeof(T) typeof(T)
} }) ?? throw new Exception($"No Compare method found for type {typeof(T).FullName}"));
) ?? throw new Exception($"No Compare method found for type {typeof(T).FullName}")
);
compareMethod = emitter.Method; compareMethod = emitter.Method;
} }
#endregion
#endregion
#region IEqualityComparer
typeBuilder.AddInterfaceImplementation(typeof(IEqualityComparer<T>)); typeBuilder.AddInterfaceImplementation(typeof(IEqualityComparer<T>));
#region Equals
{ {
MethodEmitter emitter = new MethodEmitter(typeBuilder); MethodEmitter emitter = new MethodEmitter(typeBuilder);
@ -158,14 +135,8 @@ namespace Server.Commands.Generic
{ {
typeof(T), typeof(T),
typeof(T) typeof(T)
}) ?? throw new Exception($"No Equals method found for type {typeof(T).FullName}"));
} }
) ?? throw new Exception($"No Equals method found for type {typeof(T).FullName}")
);
}
#endregion
#region GetHashCode
{ {
MethodEmitter emitter = new MethodEmitter(typeBuilder); MethodEmitter emitter = new MethodEmitter(typeBuilder);
@ -242,14 +213,8 @@ namespace Server.Commands.Generic
new[] new[]
{ {
typeof(T) typeof(T)
}) ?? throw new Exception($"No GetHashCode method found for type {typeof(T).FullName}"));
} }
) ?? throw new Exception($"No GetHashCode method found for type {typeof(T).FullName}")
);
}
#endregion
#endregion
Type comparerType = typeBuilder.CreateType(); Type comparerType = typeBuilder.CreateType();

View file

@ -1,8 +1,8 @@
using Server.Utilities;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Reflection.Emit; using System.Reflection.Emit;
using Server.Utilities;
namespace Server.Commands.Generic namespace Server.Commands.Generic
{ {
@ -51,17 +51,12 @@ namespace Server.Commands.Generic
TypeBuilder typeBuilder = assembly.DefineType( TypeBuilder typeBuilder = assembly.DefineType(
"__sort", "__sort",
TypeAttributes.Public, TypeAttributes.Public,
typeof(T) typeof(T));
);
#region Constructor
{ {
ConstructorBuilder ctor = typeBuilder.DefineConstructor( ConstructorBuilder ctor = typeBuilder.DefineConstructor(
MethodAttributes.Public, MethodAttributes.Public,
CallingConventions.Standard, CallingConventions.Standard,
Type.EmptyTypes Type.EmptyTypes);
);
ILGenerator il = ctor.GetILGenerator(); ILGenerator il = ctor.GetILGenerator();
@ -74,13 +69,7 @@ namespace Server.Commands.Generic
il.Emit(OpCodes.Ret); il.Emit(OpCodes.Ret);
} }
#endregion
#region IComparer
typeBuilder.AddInterfaceImplementation(typeof(IComparer<T>)); typeBuilder.AddInterfaceImplementation(typeof(IComparer<T>));
#region Compare
{ {
MethodEmitter emitter = new MethodEmitter(typeBuilder); MethodEmitter emitter = new MethodEmitter(typeBuilder);
@ -113,7 +102,7 @@ namespace Server.Commands.Generic
if (i > 0) if (i > 0)
{ {
emitter.LoadLocal(v); emitter.LoadLocal(v);
emitter.BranchIfTrue(end); // if ( v != 0 ) return v; emitter.BranchIfTrue(end);
} }
OrderInfo orderInfo = orders[i]; OrderInfo orderInfo = orders[i];
@ -125,7 +114,7 @@ namespace Server.Commands.Generic
emitter.Chain(prop); emitter.Chain(prop);
bool couldCompare = bool couldCompare =
emitter.CompareTo(sign, delegate emitter.CompareTo(sign, () =>
{ {
emitter.LoadLocal(b); emitter.LoadLocal(b);
emitter.Chain(prop); emitter.Chain(prop);
@ -150,14 +139,8 @@ namespace Server.Commands.Generic
{ {
typeof(T), typeof(T),
typeof(T) typeof(T)
}) ?? throw new Exception($"No Compare method found for type {typeof(T).FullName}"));
} }
) ?? throw new Exception($"No Compare method found for type {typeof(T).FullName}")
);
}
#endregion
#endregion
Type comparerType = typeBuilder.CreateType(); Type comparerType = typeBuilder.CreateType();
return (IComparer<T>)ActivatorUtil.CreateInstance(comparerType); return (IComparer<T>)ActivatorUtil.CreateInstance(comparerType);

View file

@ -10,7 +10,7 @@ namespace Server.Commands.Generic
private IComparer<object> m_Comparer; private IComparer<object> m_Comparer;
private List<Property> m_Properties; private readonly List<Property> m_Properties;
public DistinctExtension() => m_Properties = new List<Property>(); public DistinctExtension() => m_Properties = new List<Property>();

View file

@ -9,7 +9,7 @@ namespace Server.Commands.Generic
private IComparer<object> m_Comparer; private IComparer<object> m_Comparer;
private List<OrderInfo> m_Orders; private readonly List<OrderInfo> m_Orders;
public SortExtension() => m_Orders = new List<OrderInfo>(); public SortExtension() => m_Orders = new List<OrderInfo>();

View file

@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace Server.Commands.Generic namespace Server.Commands.Generic
{ {
@ -48,7 +47,6 @@ namespace Server.Commands.Generic
if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj)) if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj))
objs.Add(obj); objs.Add(obj);
eable.Free(); eable.Free();
ext.Filter(objs); ext.Filter(objs);

View file

@ -12,7 +12,7 @@ namespace Server.Commands.Generic
private IConditional[] m_Conditionals; private IConditional[] m_Conditionals;
private ICondition[][] m_Conditions; private readonly ICondition[][] m_Conditions;
public ObjectConditional(Type objectType, ICondition[][] conditions) public ObjectConditional(Type objectType, ICondition[][] conditions)
{ {

View file

@ -287,7 +287,7 @@ namespace Server.Commands
foreach (Mobile m in World.Mobiles.Values) foreach (Mobile m in World.Mobiles.Values)
if (m is BaseCreature bc) if (m is BaseCreature bc)
if (bc.Controlled && bc.ControlMaster == master || bc.Summoned && bc.SummonMaster == master) if ((bc.Controlled && bc.ControlMaster == master) || (bc.Summoned && bc.SummonMaster == master))
pets.Add(bc); pets.Add(bc);
if (pets.Count > 0) if (pets.Count > 0)
@ -408,7 +408,7 @@ namespace Server.Commands
AutoSave.Save(true); AutoSave.Save(true);
} }
private static bool FixMap(ref Map map, ref Point3D loc, Item item) => map != null && map != Map.Internal || item.RootParent is Mobile m && FixMap(ref map, ref loc, m); private static bool FixMap(ref Map map, ref Point3D loc, Item item) => (map != null && map != Map.Internal) || (item.RootParent is Mobile m && FixMap(ref map, ref loc, m));
private static bool FixMap(ref Map map, ref Point3D loc, Mobile m) private static bool FixMap(ref Map map, ref Point3D loc, Mobile m)
{ {
@ -782,7 +782,7 @@ namespace Server.Commands
private class EquipMenu : ItemListMenu private class EquipMenu : ItemListMenu
{ {
private Mobile m_Mobile; private readonly Mobile m_Mobile;
public EquipMenu(Mobile from, Mobile m, ItemListEntry[] entries) : base("Equipment", entries) public EquipMenu(Mobile from, Mobile m, ItemListEntry[] entries) : base("Equipment", entries)
{ {
@ -804,8 +804,8 @@ namespace Server.Commands
private class EquipDetailsMenu : QuestionMenu private class EquipDetailsMenu : QuestionMenu
{ {
private Item m_Item; private readonly Item m_Item;
private Mobile m_Mobile; private readonly Mobile m_Mobile;
public EquipDetailsMenu(Mobile m, Item item) : base($"{item.Layer}: {item.GetType().Name}", public EquipDetailsMenu(Mobile m, Item item) : base($"{item.Layer}: {item.GetType().Name}",
new[] { "Move", "Delete", "Props" }) new[] { "Move", "Delete", "Props" })

View file

@ -106,7 +106,6 @@ namespace Server.Commands
} }
} }
for (int i = 0; i < TargetCommands.AllCommands.Count; ++i) for (int i = 0; i < TargetCommands.AllCommands.Count; ++i)
{ {
BaseCommand command = TargetCommands.AllCommands[i]; BaseCommand command = TargetCommands.AllCommands[i];
@ -221,9 +220,9 @@ namespace Server.Commands
public class CommandListGump : BaseGridGump public class CommandListGump : BaseGridGump
{ {
private const int EntriesPerPage = 15; private const int EntriesPerPage = 15;
private List<CommandInfo> m_List; private readonly List<CommandInfo> m_List;
private int m_Page; private readonly int m_Page;
public CommandListGump(int page, Mobile from, List<CommandInfo> list) public CommandListGump(int page, Mobile from, List<CommandInfo> list)
: base(30, 30) : base(30, 30)
@ -334,7 +333,6 @@ namespace Server.Commands
} }
} }
public class CommandInfoGump : Gump public class CommandInfoGump : Gump
{ {
public CommandInfoGump(CommandInfo info, int width = 320, int height = 200) public CommandInfoGump(CommandInfo info, int width = 320, int height = 200)

View file

@ -1,8 +1,8 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using Server.Commands.Generic; using Server.Commands.Generic;
using Server.Items; using Server.Items;
using Server.Targeting; using Server.Targeting;
using System.Globalization;
namespace Server.Commands namespace Server.Commands
{ {

View file

@ -7,7 +7,7 @@ namespace Server.Commands
{ {
public class CommandLogging public class CommandLogging
{ {
private static char[] m_NotSafe = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' }; private static readonly char[] m_NotSafe = { '\\', '/', ':', '*', '?', '"', '<', '>', '|' };
public static bool Enabled { get; set; } = true; public static bool Enabled { get; set; } = true;
public static StreamWriter Output { get; private set; } public static StreamWriter Output { get; private set; }

View file

@ -6,7 +6,7 @@ using Server.Diagnostics;
namespace Server.Commands namespace Server.Commands
{ {
public class Profiling public static class Profiling
{ {
public static void Initialize() public static void Initialize()
{ {
@ -243,7 +243,8 @@ namespace Server.Commands
{ {
parms[0]++; parms[0]++;
parms[1] += item.Amount; parms[1] += item.Amount;
} else }
else
table[type] = new[] { 1, item.Amount }; table[type] = new[] { 1, item.Amount };
} }

View file

@ -18,25 +18,25 @@ namespace Server.Commands
public static class Properties public static class Properties
{ {
private static Type typeofCPA = typeof(CPA); private static readonly Type typeofCPA = typeof(CPA);
private static Type typeofSerial = typeof(Serial); private static readonly Type typeofSerial = typeof(Serial);
private static Type typeofType = typeof(Type); private static readonly Type typeofType = typeof(Type);
private static Type typeofChar = typeof(char); private static readonly Type typeofChar = typeof(char);
private static Type typeofString = typeof(string); private static readonly Type typeofString = typeof(string);
private static Type typeofText = typeof(TextDefinition); private static readonly Type typeofText = typeof(TextDefinition);
private static Type typeofTimeSpan = typeof(TimeSpan); private static readonly Type typeofTimeSpan = typeof(TimeSpan);
private static Type typeofParsable = typeof(ParsableAttribute); private static readonly Type typeofParsable = typeof(ParsableAttribute);
private static Type[] m_ParseTypes = { typeof(string) }; private static readonly Type[] m_ParseTypes = { typeof(string) };
private static object[] m_ParseParams = new object[1]; private static readonly object[] m_ParseParams = new object[1];
private static Type[] m_NumericTypes = private static readonly Type[] m_NumericTypes =
{ {
typeof(byte), typeof(sbyte), typeof(byte), typeof(sbyte),
typeof(short), typeof(ushort), typeof(short), typeof(ushort),

View file

@ -6,7 +6,7 @@ namespace Server.Commands
{ {
public class SignParser public class SignParser
{ {
private static Queue<Item> m_ToDelete = new Queue<Item>(); private static readonly Queue<Item> m_ToDelete = new Queue<Item>();
public static void Initialize() public static void Initialize()
{ {
@ -119,10 +119,10 @@ namespace Server.Commands
private class SignEntry private class SignEntry
{ {
public int m_ItemID; public readonly int m_ItemID;
public Point3D m_Location; public readonly Point3D m_Location;
public int m_Map; public readonly int m_Map;
public string m_Text; public readonly string m_Text;
public SignEntry(string text, Point3D pt, int itemID, int mapLoc) public SignEntry(string text, Point3D pt, int itemID, int mapLoc)
{ {

View file

@ -58,7 +58,7 @@ namespace Server.Commands
public class AllSkillsTarget : Target public class AllSkillsTarget : Target
{ {
private double m_Value; private readonly double m_Value;
public AllSkillsTarget(double value) : base(-1, false, TargetFlags.None) => m_Value = value; public AllSkillsTarget(double value) : base(-1, false, TargetFlags.None) => m_Value = value;
@ -82,9 +82,9 @@ namespace Server.Commands
public class SkillTarget : Target public class SkillTarget : Target
{ {
private bool m_Set; private readonly bool m_Set;
private SkillName m_Skill; private readonly SkillName m_Skill;
private double m_Value; private readonly double m_Value;
public SkillTarget(SkillName skill, double value) : base(-1, false, TargetFlags.None) public SkillTarget(SkillName skill, double value) : base(-1, false, TargetFlags.None)
{ {

View file

@ -28,7 +28,7 @@ namespace Server
"It is strongly recommended that you make backup of the data files mentioned above. " + "It is strongly recommended that you make backup of the data files mentioned above. " +
"Do you wish to proceed?"; "Do you wish to proceed?";
private static Point3D NullP3D = new Point3D(int.MinValue, int.MinValue, int.MinValue); private static readonly Point3D NullP3D = new Point3D(int.MinValue, int.MinValue, int.MinValue);
private static byte[] m_Buffer; private static byte[] m_Buffer;
@ -551,8 +551,9 @@ namespace Server
private class DeltaState private class DeltaState
{ {
public List<Item> m_List; public readonly List<Item> m_List;
public int m_X, m_Y; public readonly int m_X;
public readonly int m_Y;
public DeltaState(Point2D p) public DeltaState(Point2D p)
{ {

View file

@ -72,7 +72,7 @@ namespace Server.Commands
IPooledEnumerable<IEntity> eable; IPooledEnumerable<IEntity> eable;
if (!items && !multis || !mobiles) if ((!items && !multis) || !mobiles)
return; return;
eable = map.GetObjectsInBounds(rect); eable = map.GetObjectsInBounds(rect);

View file

@ -4,8 +4,8 @@ namespace Server.ContextMenus
{ {
public class AddToPartyEntry : ContextMenuEntry public class AddToPartyEntry : ContextMenuEntry
{ {
private Mobile m_From; private readonly Mobile m_From;
private Mobile m_Target; private readonly Mobile m_Target;
public AddToPartyEntry(Mobile from, Mobile target) : base(0197, 12) public AddToPartyEntry(Mobile from, Mobile target) : base(0197, 12)
{ {

View file

@ -18,7 +18,7 @@ namespace Server.ContextMenus
private class InternalTarget : Target private class InternalTarget : Target
{ {
private SpellScroll m_Scroll; private readonly SpellScroll m_Scroll;
public InternalTarget(SpellScroll scroll) : base(3, false, TargetFlags.None) => m_Scroll = scroll; public InternalTarget(SpellScroll scroll) : base(3, false, TargetFlags.None) => m_Scroll = scroll;

View file

@ -4,8 +4,8 @@ namespace Server.ContextMenus
{ {
public class EatEntry : ContextMenuEntry public class EatEntry : ContextMenuEntry
{ {
private Food m_Food; private readonly Food m_Food;
private Mobile m_From; private readonly Mobile m_From;
public EatEntry(Mobile from, Food food) : base(6135, 1) public EatEntry(Mobile from, Food food) : base(6135, 1)
{ {

View file

@ -4,9 +4,9 @@ namespace Server.ContextMenus
{ {
public class EjectPlayerEntry : ContextMenuEntry public class EjectPlayerEntry : ContextMenuEntry
{ {
private Mobile m_From; private readonly Mobile m_From;
private Mobile m_Target; private readonly Mobile m_Target;
private BaseHouse m_TargetHouse; private readonly BaseHouse m_TargetHouse;
public EjectPlayerEntry(Mobile from, Mobile target) : base(6206, 12) public EjectPlayerEntry(Mobile from, Mobile target) : base(6206, 12)
{ {

View file

@ -2,7 +2,7 @@ namespace Server.ContextMenus
{ {
public class OpenBankEntry : ContextMenuEntry public class OpenBankEntry : ContextMenuEntry
{ {
private Mobile m_Banker; private readonly Mobile m_Banker;
public OpenBankEntry(Mobile from, Mobile banker) : base(6105, 12) => m_Banker = banker; public OpenBankEntry(Mobile from, Mobile banker) : base(6105, 12) => m_Banker = banker;

View file

@ -5,9 +5,9 @@ namespace Server.ContextMenus
{ {
public class TeachEntry : ContextMenuEntry public class TeachEntry : ContextMenuEntry
{ {
private Mobile m_From; private readonly Mobile m_From;
private BaseCreature m_Mobile; private readonly BaseCreature m_Mobile;
private SkillName m_Skill; private readonly SkillName m_Skill;
public TeachEntry(SkillName skill, BaseCreature m, Mobile from, bool enabled) : base(6000 + (int)skill) public TeachEntry(SkillName skill, BaseCreature m, Mobile from, bool enabled) : base(6000 + (int)skill)
{ {

View file

@ -4,7 +4,7 @@ namespace Server.Engines.BulkOrders
{ {
public class BODTarget : Target public class BODTarget : Target
{ {
private BaseBOD m_Deed; private readonly BaseBOD m_Deed;
public BODTarget(BaseBOD deed) : base(18, false, TargetFlags.None) => m_Deed = deed; public BODTarget(BaseBOD deed) : base(18, false, TargetFlags.None) => m_Deed = deed;

View file

@ -8,7 +8,7 @@ namespace Server.Engines.BulkOrders
{ {
private const int LabelColor = 0x7FFF; private const int LabelColor = 0x7FFF;
private static int[,] m_MaterialFilters = private static readonly int[,] m_MaterialFilters =
{ {
{ 1044067, 1 }, // Blacksmithy { 1044067, 1 }, // Blacksmithy
{ 1062226, 3 }, // Iron { 1062226, 3 }, // Iron
@ -16,14 +16,12 @@ namespace Server.Engines.BulkOrders
{ 1018333, 5 }, // Shadow Iron { 1018333, 5 }, // Shadow Iron
{ 1018334, 6 }, // Copper { 1018334, 6 }, // Copper
{ 1018335, 7 }, // Bronze { 1018335, 7 }, // Bronze
{ 0, 0 }, // --Blank-- { 0, 0 }, // --Blank--
{ 1018336, 8 }, // Golden { 1018336, 8 }, // Golden
{ 1018337, 9 }, // Agapite { 1018337, 9 }, // Agapite
{ 1018338, 10 }, // Verite { 1018338, 10 }, // Verite
{ 1018339, 11 }, // Valorite { 1018339, 11 }, // Valorite
{ 0, 0 }, // --Blank-- { 0, 0 }, // --Blank--
{ 1044094, 2 }, // Tailoring { 1044094, 2 }, // Tailoring
{ 1044286, 12 }, // Cloth { 1044286, 12 }, // Cloth
{ 1062235, 13 }, // Leather { 1062235, 13 }, // Leather
@ -32,21 +30,21 @@ namespace Server.Engines.BulkOrders
{ 1062238, 16 } // Barbed { 1062238, 16 } // Barbed
}; };
private static int[,] m_TypeFilters = private static readonly int[,] m_TypeFilters =
{ {
{ 1062229, 0 }, // All { 1062229, 0 }, // All
{ 1062224, 1 }, // Small { 1062224, 1 }, // Small
{ 1062225, 2 } // Large { 1062225, 2 } // Large
}; };
private static int[,] m_QualityFilters = private static readonly int[,] m_QualityFilters =
{ {
{ 1062229, 0 }, // All { 1062229, 0 }, // All
{ 1011542, 1 }, // Normal { 1011542, 1 }, // Normal
{ 1060636, 2 } // Exceptional { 1060636, 2 } // Exceptional
}; };
private static int[,] m_AmountFilters = private static readonly int[,] m_AmountFilters =
{ {
{ 1062229, 0 }, // All { 1062229, 0 }, // All
{ 1049706, 1 }, // 10 { 1049706, 1 }, // 10
@ -54,7 +52,7 @@ namespace Server.Engines.BulkOrders
{ 1062239, 3 } // 20 { 1062239, 3 } // 20
}; };
private static int[][,] m_Filters = private static readonly int[][,] m_Filters =
{ {
m_TypeFilters, m_TypeFilters,
m_QualityFilters, m_QualityFilters,
@ -62,15 +60,15 @@ namespace Server.Engines.BulkOrders
m_AmountFilters m_AmountFilters
}; };
private static int[] m_XOffsets_Type = { 0, 75, 170 }; private static readonly int[] m_XOffsets_Type = { 0, 75, 170 };
private static int[] m_XOffsets_Quality = { 0, 75, 170 }; private static readonly int[] m_XOffsets_Quality = { 0, 75, 170 };
private static int[] m_XOffsets_Amount = { 0, 75, 180, 275 }; private static readonly int[] m_XOffsets_Amount = { 0, 75, 180, 275 };
private static int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 }; private static readonly int[] m_XOffsets_Material = { 0, 105, 210, 305, 390, 485 };
private static int[] m_XWidths_Small = { 50, 50, 70, 50 }; private static readonly int[] m_XWidths_Small = { 50, 50, 70, 50 };
private static int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 }; private static readonly int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 };
private BulkOrderBook m_Book; private readonly BulkOrderBook m_Book;
private PlayerMobile m_From; private readonly PlayerMobile m_From;
public BOBFilterGump(PlayerMobile from, BulkOrderBook book) : base(12, 24) public BOBFilterGump(PlayerMobile from, BulkOrderBook book) : base(12, 24)
{ {
@ -132,7 +130,7 @@ namespace Server.Engines.BulkOrders
continue; continue;
bool isSelected = filters[i, 1] == filterValue || bool isSelected = filters[i, 1] == filterValue ||
i % xOffsets.Length == 0 && filterValue == 0; (i % xOffsets.Length == 0 && filterValue == 0);
AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset, AddHtmlLocalized(x + 35 + xOffsets[i % xOffsets.Length], y + i / xOffsets.Length * yOffset,
xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor); xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor);

View file

@ -11,9 +11,9 @@ namespace Server.Engines.BulkOrders
public class BOBGump : Gump public class BOBGump : Gump
{ {
private const int LabelColor = 0x7FFF; private const int LabelColor = 0x7FFF;
private BulkOrderBook m_Book; private readonly BulkOrderBook m_Book;
private PlayerMobile m_From; private readonly PlayerMobile m_From;
private List<IBOBEntry> m_List; private readonly List<IBOBEntry> m_List;
private int m_Page; private int m_Page;
@ -173,7 +173,7 @@ namespace Server.Engines.BulkOrders
if (canDrop) if (canDrop)
AddButton(35, y + 2, 5602, 5606, 5 + i * 2); AddButton(35, y + 2, 5602, 5606, 5 + i * 2);
if (canDrop || canBuy && entry.Price > 0) if (canDrop || (canBuy && entry.Price > 0))
{ {
AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddButton(579, y + 2, 2117, 2118, 6 + i * 2);
AddLabel(495, y, 1152, entry.Price.ToString()); AddLabel(495, y, 1152, entry.Price.ToString());
@ -214,7 +214,7 @@ namespace Server.Engines.BulkOrders
if (canDrop) if (canDrop)
AddButton(35, y + 2, 5602, 5606, 5 + i * 2); AddButton(35, y + 2, 5602, 5606, 5 + i * 2);
if (canDrop || canBuy && smallEntry.Price > 0) if (canDrop || (canBuy && smallEntry.Price > 0))
{ {
AddButton(579, y + 2, 2117, 2118, 6 + i * 2); AddButton(579, y + 2, 2117, 2118, 6 + i * 2);
AddLabel(495, y, 1152, smallEntry.Price.ToString()); AddLabel(495, y, 1152, smallEntry.Price.ToString());
@ -281,22 +281,22 @@ namespace Server.Engines.BulkOrders
return f.Material switch return f.Material switch
{ {
1 => (deedType == BODType.Smith), 1 => deedType == BODType.Smith,
2 => (deedType == BODType.Tailor), 2 => deedType == BODType.Tailor,
3 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron), 3 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron,
4 => (mat == BulkMaterialType.DullCopper), 4 => mat == BulkMaterialType.DullCopper,
5 => (mat == BulkMaterialType.ShadowIron), 5 => mat == BulkMaterialType.ShadowIron,
6 => (mat == BulkMaterialType.Copper), 6 => mat == BulkMaterialType.Copper,
7 => (mat == BulkMaterialType.Bronze), 7 => mat == BulkMaterialType.Bronze,
8 => (mat == BulkMaterialType.Gold), 8 => mat == BulkMaterialType.Gold,
9 => (mat == BulkMaterialType.Agapite), 9 => mat == BulkMaterialType.Agapite,
10 => (mat == BulkMaterialType.Verite), 10 => mat == BulkMaterialType.Verite,
11 => (mat == BulkMaterialType.Valorite), 11 => mat == BulkMaterialType.Valorite,
12 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth), 12 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth,
13 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather), 13 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather,
14 => (mat == BulkMaterialType.Spined), 14 => mat == BulkMaterialType.Spined,
15 => (mat == BulkMaterialType.Horned), 15 => mat == BulkMaterialType.Horned,
16 => (mat == BulkMaterialType.Barbed), 16 => mat == BulkMaterialType.Barbed,
_ => true _ => true
}; };
} }
@ -391,7 +391,6 @@ namespace Server.Engines.BulkOrders
return page; return page;
} }
public object GetMaterialName(BulkMaterialType mat, BODType type, Type itemType) public object GetMaterialName(BulkMaterialType mat, BODType type, Type itemType)
{ {
switch (type) switch (type)
@ -581,10 +580,10 @@ namespace Server.Engines.BulkOrders
private class SetPricePrompt : Prompt private class SetPricePrompt : Prompt
{ {
private BulkOrderBook m_Book; private readonly BulkOrderBook m_Book;
private List<IBOBEntry> m_List; private readonly List<IBOBEntry> m_List;
private IBOBEntry m_Entry; private readonly IBOBEntry m_Entry;
private int m_Page; private readonly int m_Page;
public SetPricePrompt(BulkOrderBook book, IBOBEntry entry, int page, List<IBOBEntry> list) public SetPricePrompt(BulkOrderBook book, IBOBEntry entry, int page, List<IBOBEntry> list)
{ {

View file

@ -79,7 +79,8 @@ namespace Server.Engines.BulkOrders
for (int i = 0; i < Entries.Length; ++i) for (int i = 0; i < Entries.Length; ++i)
entries[i] = new LargeBulkEntry(null, entries[i] = new LargeBulkEntry(null,
new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic)) { Amount = Entries[i].AmountCur }; new SmallBulkEntry(Entries[i].ItemType, Entries[i].Number, Entries[i].Graphic))
{ Amount = Entries[i].AmountCur };
return entries; return entries;
} }

View file

@ -7,11 +7,11 @@ namespace Server.Engines.BulkOrders
{ {
public class BODBuyGump : Gump public class BODBuyGump : Gump
{ {
private BulkOrderBook m_Book; private readonly BulkOrderBook m_Book;
private PlayerMobile m_From; private readonly PlayerMobile m_From;
private IBOBEntry m_Entry; private readonly IBOBEntry m_Entry;
private int m_Page; private readonly int m_Page;
private int m_Price; private readonly int m_Price;
public BODBuyGump(PlayerMobile from, BulkOrderBook book, IBOBEntry entry, int page, int price) : base(100, 200) public BODBuyGump(PlayerMobile from, BulkOrderBook book, IBOBEntry entry, int page, int price) : base(100, 200)
{ {

View file

@ -259,8 +259,8 @@ namespace Server.Engines.BulkOrders
private class NameBookEntry : ContextMenuEntry private class NameBookEntry : ContextMenuEntry
{ {
private Mobile m_From; private readonly Mobile m_From;
private BulkOrderBook m_Book; private readonly BulkOrderBook m_Book;
public NameBookEntry(Mobile from, BulkOrderBook book) : base(6216) public NameBookEntry(Mobile from, BulkOrderBook book) : base(6216)
{ {
@ -280,7 +280,7 @@ namespace Server.Engines.BulkOrders
private class NameBookPrompt : Prompt private class NameBookPrompt : Prompt
{ {
private BulkOrderBook m_Book; private readonly BulkOrderBook m_Book;
public NameBookPrompt(BulkOrderBook book) => m_Book = book; public NameBookPrompt(BulkOrderBook book) => m_Book = book;

View file

@ -27,8 +27,7 @@ namespace Server.Engines.BulkOrders
public override int LabelNumber => 1045151; // a bulk order deed public override int LabelNumber => 1045151; // a bulk order deed
public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) : public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) : base(hue, amountMax, requireExeptional, material) =>
base(hue, amountMax, requireExeptional, material) =>
m_Entries = entries; m_Entries = entries;
public LargeBOD() public LargeBOD()

View file

@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders
{ {
public class LargeBODAcceptGump : Gump public class LargeBODAcceptGump : Gump
{ {
private LargeBOD m_Deed; private readonly LargeBOD m_Deed;
private Mobile m_From; private readonly Mobile m_From;
public LargeBODAcceptGump(Mobile from, LargeBOD deed) : base(50, 50) public LargeBODAcceptGump(Mobile from, LargeBOD deed) : base(50, 50)
{ {

View file

@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders
{ {
public class LargeBODGump : Gump public class LargeBODGump : Gump
{ {
private LargeBOD m_Deed; private readonly LargeBOD m_Deed;
private Mobile m_From; private readonly Mobile m_From;
public LargeBODGump(Mobile from, LargeBOD deed) : base(25, 25) public LargeBODGump(Mobile from, LargeBOD deed) : base(25, 25)
{ {

View file

@ -32,7 +32,6 @@ namespace Server.Engines.BulkOrders
public static SmallBulkEntry[] LargeSwords => GetEntries("Blacksmith", "largeswords"); public static SmallBulkEntry[] LargeSwords => GetEntries("Blacksmith", "largeswords");
public static SmallBulkEntry[] BoneSet => GetEntries("Tailoring", "boneset"); public static SmallBulkEntry[] BoneSet => GetEntries("Tailoring", "boneset");
public static SmallBulkEntry[] Farmer => GetEntries("Tailoring", "farmer"); public static SmallBulkEntry[] Farmer => GetEntries("Tailoring", "farmer");
@ -61,7 +60,6 @@ namespace Server.Engines.BulkOrders
public static SmallBulkEntry[] Wizard => GetEntries("Tailoring", "wizard"); public static SmallBulkEntry[] Wizard => GetEntries("Tailoring", "wizard");
private static Dictionary<string, Dictionary<string, SmallBulkEntry[]>> m_Cache; private static Dictionary<string, Dictionary<string, SmallBulkEntry[]>> m_Cache;
public static SmallBulkEntry[] GetEntries(string type, string name) public static SmallBulkEntry[] GetEntries(string type, string name)

View file

@ -41,7 +41,7 @@ namespace Server.Engines.BulkOrders
int hue = 0x44E; int hue = 0x44E;
int amountMax = Utility.RandomList(10, 15, 20, 20); int amountMax = Utility.RandomList(10, 15, 20, 20);
bool reqExceptional = 0.825 > Utility.RandomDouble(); bool reqExceptional = Utility.RandomDouble() < 0.825;
BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances) BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances)
: BulkMaterialType.None; : BulkMaterialType.None;

View file

@ -69,7 +69,7 @@ namespace Server.Engines.BulkOrders
int hue = 0x483; int hue = 0x483;
int amountMax = Utility.RandomList(10, 15, 20, 20); int amountMax = Utility.RandomList(10, 15, 20, 20);
bool reqExceptional = 0.825 > Utility.RandomDouble(); bool reqExceptional = Utility.RandomDouble() < 0.825;
BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances) BulkMaterialType material = useMaterials ? GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances)
: BulkMaterialType.None; : BulkMaterialType.None;

View file

@ -165,7 +165,7 @@ namespace Server.Engines.BulkOrders
private static readonly ConstructCallback AncientHammer = CreateAncientHammer; private static readonly ConstructCallback AncientHammer = CreateAncientHammer;
public static readonly SmithRewardCalculator Instance = new SmithRewardCalculator(); public static readonly SmithRewardCalculator Instance = new SmithRewardCalculator();
private static int[][][] m_GoldTable = private static readonly int[][][] m_GoldTable =
{ {
new[] // 1-part (regular) new[] // 1-part (regular)
{ {
@ -253,7 +253,7 @@ namespace Server.Engines.BulkOrders
} }
}; };
private RewardType[] m_Types = private readonly RewardType[] m_Types =
{ {
// Armors // Armors
new RewardType(200, typeof(RingmailGloves), typeof(RingmailChest), typeof(RingmailArms), typeof(RingmailLegs)), new RewardType(200, typeof(RingmailGloves), typeof(RingmailChest), typeof(RingmailArms), typeof(RingmailLegs)),
@ -379,8 +379,6 @@ namespace Server.Engines.BulkOrders
return Utility.RandomMinMax(min, max); return Utility.RandomMinMax(min, max);
} }
#region Constructors
private static Item CreateSturdyShovel(int type) => new SturdyShovel(); private static Item CreateSturdyShovel(int type) => new SturdyShovel();
private static Item CreateSturdyPickaxe(int type) => new SturdyPickaxe(); private static Item CreateSturdyPickaxe(int type) => new SturdyPickaxe();
@ -427,8 +425,6 @@ namespace Server.Engines.BulkOrders
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
#endregion
} }
public sealed class TailorRewardCalculator : RewardCalculator public sealed class TailorRewardCalculator : RewardCalculator
@ -443,7 +439,7 @@ namespace Server.Engines.BulkOrders
private static readonly ConstructCallback ClothingBlessDeed = CreateCBD; private static readonly ConstructCallback ClothingBlessDeed = CreateCBD;
public static readonly TailorRewardCalculator Instance = new TailorRewardCalculator(); public static readonly TailorRewardCalculator Instance = new TailorRewardCalculator();
private static int[][][] m_AosGoldTable = private static readonly int[][][] m_AosGoldTable =
{ {
new[] // 1-part (regular) new[] // 1-part (regular)
{ {
@ -495,7 +491,7 @@ namespace Server.Engines.BulkOrders
} }
}; };
private static int[][][] m_OldGoldTable = private static readonly int[][][] m_OldGoldTable =
{ {
new[] // 1-part (regular) new[] // 1-part (regular)
{ {
@ -636,9 +632,7 @@ namespace Server.Engines.BulkOrders
return Utility.RandomMinMax(min, max); return Utility.RandomMinMax(min, max);
} }
#region Constructors private static readonly int[][] m_ClothHues =
private static int[][] m_ClothHues =
{ {
new[] { 0x483, 0x48C, 0x488, 0x48A }, new[] { 0x483, 0x48C, 0x488, 0x48A },
new[] { 0x495, 0x48B, 0x486, 0x485 }, new[] { 0x495, 0x48B, 0x486, 0x485 },
@ -659,7 +653,7 @@ namespace Server.Engines.BulkOrders
throw new InvalidOperationException(); throw new InvalidOperationException();
} }
private static int[] m_SandalHues = private static readonly int[] m_SandalHues =
{ {
0x489, 0x47F, 0x482, 0x489, 0x47F, 0x482,
0x47E, 0x48F, 0x494, 0x47E, 0x48F, 0x494,
@ -718,7 +712,5 @@ namespace Server.Engines.BulkOrders
} }
private static Item CreateCBD(int type) => new ClothingBlessDeed(); private static Item CreateCBD(int type) => new ClothingBlessDeed();
#endregion
} }
} }

View file

@ -121,8 +121,8 @@ namespace Server.Engines.BulkOrders
from.SendLocalizedMessage( from.SendLocalizedMessage(
1045166); // The maximum amount of requested items have already been combined to this deed. 1045166); // The maximum amount of requested items have already been combined to this deed.
} }
else if (Type == null || objectType != Type && !objectType.IsSubclassOf(Type) || else if (Type == null || (objectType != Type && !objectType.IsSubclassOf(Type)) ||
!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing)) (!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing)))
{ {
from.SendLocalizedMessage(1045169); // The item is not in the request. from.SendLocalizedMessage(1045169); // The item is not in the request.
} }

View file

@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders
{ {
public class SmallBODAcceptGump : Gump public class SmallBODAcceptGump : Gump
{ {
private SmallBOD m_Deed; private readonly SmallBOD m_Deed;
private Mobile m_From; private readonly Mobile m_From;
public SmallBODAcceptGump(Mobile from, SmallBOD deed) : base(50, 50) public SmallBODAcceptGump(Mobile from, SmallBOD deed) : base(50, 50)
{ {

View file

@ -5,8 +5,8 @@ namespace Server.Engines.BulkOrders
{ {
public class SmallBODGump : Gump public class SmallBODGump : Gump
{ {
private SmallBOD m_Deed; private readonly SmallBOD m_Deed;
private Mobile m_From; private readonly Mobile m_From;
public SmallBODGump(Mobile from, SmallBOD deed) : base(25, 25) public SmallBODGump(Mobile from, SmallBOD deed) : base(25, 25)
{ {

View file

@ -153,7 +153,6 @@ namespace Server.Engines.BulkOrders
SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)]; SmallBulkEntry entry = validEntries[Utility.Random(validEntries.Count)];
return new SmallSmithBOD(entry, material, amountMax, reqExceptional); return new SmallSmithBOD(entry, material, amountMax, reqExceptional);
} }
public override void Serialize(IGenericWriter writer) public override void Serialize(IGenericWriter writer)

View file

@ -121,7 +121,6 @@ namespace Server.Engines.BulkOrders
bool reqExceptional = excChance > Utility.RandomDouble(); bool reqExceptional = excChance > Utility.RandomDouble();
CraftSystem system = DefTailoring.CraftSystem; CraftSystem system = DefTailoring.CraftSystem;
List<SmallBulkEntry> validEntries = new List<SmallBulkEntry>(); List<SmallBulkEntry> validEntries = new List<SmallBulkEntry>();

View file

@ -168,7 +168,7 @@ namespace Server.Engines.CannedEvil
private class SacrificeTarget : Target private class SacrificeTarget : Target
{ {
private ChampionSkullBrazier m_Brazier; private readonly ChampionSkullBrazier m_Brazier;
public SacrificeTarget(ChampionSkullBrazier brazier) : base(12, false, TargetFlags.None) => m_Brazier = brazier; public SacrificeTarget(ChampionSkullBrazier brazier) : base(12, false, TargetFlags.None) => m_Brazier = brazier;

View file

@ -307,8 +307,6 @@ namespace Server.Engines.CannedEvil
Start(); Start();
} }
#region Scroll of Transcendence
private ScrollofTranscendence CreateRandomSoT(bool felucca) private ScrollofTranscendence CreateRandomSoT(bool felucca)
{ {
int level = Utility.RandomMinMax(1, 5); int level = Utility.RandomMinMax(1, 5);
@ -319,8 +317,6 @@ namespace Server.Engines.CannedEvil
return ScrollofTranscendence.CreateRandom(level, level); return ScrollofTranscendence.CreateRandom(level, level);
} }
#endregion
public static void GiveScrollTo(Mobile killer, SpecialScroll scroll) public static void GiveScrollTo(Mobile killer, SpecialScroll scroll)
{ {
if (scroll == null || killer == null) // sanity if (scroll == null || killer == null) // sanity
@ -437,8 +433,6 @@ namespace Server.Engines.CannedEvil
if (killer is PlayerMobile pm) if (killer is PlayerMobile pm)
{ {
#region Scroll of Transcendence
if (Core.ML) if (Core.ML)
{ {
if (Map == Map.Felucca) if (Map == Map.Felucca)
@ -467,8 +461,6 @@ namespace Server.Engines.CannedEvil
} }
} }
#endregion
int mobSubLevel = GetSubLevelFor(m) + 1; int mobSubLevel = GetSubLevelFor(m) + 1;
if (mobSubLevel >= 0) if (mobSubLevel >= 0)
@ -988,9 +980,9 @@ namespace Server.Engines.CannedEvil
1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you. 1062317); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
} }
public bool IsEligible(Mobile m, Item Artifact) => public bool IsEligible(Mobile m, Item artifact) =>
m.Player && m.Alive && m.Region != null && m.Region == m_Region && m.Player && m.Alive && m.Region != null && m.Region == m_Region &&
m.Backpack?.CheckHold(m, Artifact, false) == true; m.Backpack?.CheckHold(m, artifact, false) == true;
public override void Serialize(IGenericWriter writer) public override void Serialize(IGenericWriter writer)
{ {

View file

@ -4,7 +4,7 @@ namespace Server.Engines.CannedEvil
{ {
public class RestartTimer : Timer public class RestartTimer : Timer
{ {
private ChampionSpawn m_Spawn; private readonly ChampionSpawn m_Spawn;
public RestartTimer(ChampionSpawn spawn, TimeSpan delay) : base(delay) public RestartTimer(ChampionSpawn spawn, TimeSpan delay) : base(delay)
{ {

View file

@ -4,7 +4,7 @@ namespace Server.Engines.CannedEvil
{ {
public class SliceTimer : Timer public class SliceTimer : Timer
{ {
private ChampionSpawn m_Spawn; private readonly ChampionSpawn m_Spawn;
public SliceTimer(ChampionSpawn spawn) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) public SliceTimer(ChampionSpawn spawn) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
{ {

View file

@ -83,7 +83,7 @@ namespace Server.Items
private class InternalTimer : Timer private class InternalTimer : Timer
{ {
private Item m_Item; private readonly Item m_Item;
public InternalTimer(Item item, DateTime end) : base(end - DateTime.UtcNow) => m_Item = item; public InternalTimer(Item item, DateTime end) : base(end - DateTime.UtcNow) => m_Item = item;

View file

@ -6,7 +6,10 @@ namespace Server.Engines.Chat
{ {
private string m_Name; private string m_Name;
private string m_Password; private string m_Password;
private List<ChatUser> m_Users, m_Banned, m_Moderators, m_Voices; private readonly List<ChatUser> m_Users;
private readonly List<ChatUser> m_Banned;
private readonly List<ChatUser> m_Moderators;
private readonly List<ChatUser> m_Voices;
private bool m_VoiceRestricted; private bool m_VoiceRestricted;
public Channel(string name) public Channel(string name)
@ -100,7 +103,6 @@ namespace Server.Engines.Chat
from.Mobile.SendMessage("Your access level is too low to do this."); from.Mobile.SendMessage("Your access level is too low to do this.");
return false; return false;
} }
public bool AddUser(ChatUser user, string password = null) public bool AddUser(ChatUser user, string password = null)
@ -132,7 +134,7 @@ namespace Server.Engines.Chat
m_Users.Add(user); m_Users.Add(user);
user.CurrentChannel = this; user.CurrentChannel = this;
if (user.Mobile.AccessLevel >= AccessLevel.GameMaster || !AlwaysAvailable && m_Users.Count == 1) if (user.Mobile.AccessLevel >= AccessLevel.GameMaster || (!AlwaysAvailable && m_Users.Count == 1))
AddModerator(user); AddModerator(user);
SendUsersTo(user); SendUsersTo(user);

View file

@ -128,9 +128,10 @@ namespace Server.Engines.Chat
Channel channel = user.CurrentChannel; Channel channel = user.CurrentChannel;
if (handler.RequireConference && channel == null) if (handler.RequireConference && channel == null)
user.SendMessage(31); /* You must be in a conference to do this. /* You must be in a conference to do this.
* To join a conference, select one from the Conference menu. * To join a conference, select one from the Conference menu.
*/ */
user.SendMessage(31);
else if (handler.RequireModerator && !user.IsModerator) else if (handler.RequireModerator && !user.IsModerator)
user.SendMessage(29); // You must have operator status to do this. user.SendMessage(29); // You must have operator status to do this.
else else

View file

@ -2,7 +2,7 @@ namespace Server.Engines.Chat
{ {
public class ChatActionHandlers public class ChatActionHandlers
{ {
private static ChatActionHandler[] m_Handlers; private static readonly ChatActionHandler[] m_Handlers;
static ChatActionHandlers() static ChatActionHandlers()
{ {
@ -111,9 +111,10 @@ namespace Server.Engines.Chat
public static void DisallowPrivateMessages(ChatUser from, Channel channel, string param) public static void DisallowPrivateMessages(ChatUser from, Channel channel, string param)
{ {
from.IgnorePrivateMessage = true; from.IgnorePrivateMessage = true;
from.SendMessage(38); /* You will no longer receive private messages. /* You will no longer receive private messages.
* Those who send you a message will be notified that you are blocking incoming messages. * Those who send you a message will be notified that you are blocking incoming messages.
*/ */
from.SendMessage(38);
} }
public static void TogglePrivateMessages(ChatUser from, Channel channel, string param) public static void TogglePrivateMessages(ChatUser from, Channel channel, string param)

View file

@ -9,8 +9,8 @@ namespace Server.Engines.Chat
public const char ModeratorColorCharacter = '1'; public const char ModeratorColorCharacter = '1';
public const char VoicedColorCharacter = '2'; public const char VoicedColorCharacter = '2';
private static List<ChatUser> m_Users = new List<ChatUser>(); private static readonly List<ChatUser> m_Users = new List<ChatUser>();
private static Dictionary<Mobile, ChatUser> m_Table = new Dictionary<Mobile, ChatUser>(); private static readonly Dictionary<Mobile, ChatUser> m_Table = new Dictionary<Mobile, ChatUser>();
public ChatUser(Mobile m) public ChatUser(Mobile m)
{ {

View file

@ -11,15 +11,15 @@ namespace Server.Engines.Chat
EnsureCapacity(13 + (param1.Length + param2.Length) * 2); EnsureCapacity(13 + (param1.Length + param2.Length) * 2);
m_Stream.Write((ushort)(number - 20)); Stream.Write((ushort)(number - 20));
if (who != null) if (who != null)
m_Stream.WriteAsciiFixed(who.Language, 4); Stream.WriteAsciiFixed(who.Language, 4);
else else
m_Stream.Write(0); Stream.Write(0);
m_Stream.WriteBigUniNull(param1); Stream.WriteBigUniNull(param1);
m_Stream.WriteBigUniNull(param2); Stream.WriteBigUniNull(param2);
} }
} }
} }

View file

@ -11,13 +11,14 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF; private const int LabelColor32 = 0xFFFFFF;
private const int BlackColor32 = 0x000008; private const int BlackColor32 = 0x000008;
private static Dictionary<Mobile, List<IgnoreEntry>> m_IgnoreLists = new Dictionary<Mobile, List<IgnoreEntry>>(); private static readonly Dictionary<Mobile, List<IgnoreEntry>> m_IgnoreLists = new Dictionary<Mobile, List<IgnoreEntry>>();
private bool m_Active = true; private bool m_Active = true;
private Mobile m_Challenger, m_Challenged; private readonly Mobile m_Challenger;
private DuelContext m_Context; private readonly Mobile m_Challenged;
private Participant m_Participant; private readonly DuelContext m_Context;
private int m_Slot; private readonly Participant m_Participant;
private readonly int m_Slot;
public AcceptDuelGump(Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot) : base(50, public AcceptDuelGump(Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot) : base(50,
50) 50)
@ -251,9 +252,9 @@ namespace Server.Engines.ConPVP
private class IgnoreEntry private class IgnoreEntry
{ {
private static TimeSpan ExpireDelay = TimeSpan.FromMinutes(15.0); private static readonly TimeSpan ExpireDelay = TimeSpan.FromMinutes(15.0);
public DateTime m_Expire; public DateTime m_Expire;
public Mobile m_Ignored; public readonly Mobile m_Ignored;
public IgnoreEntry(Mobile ignored) public IgnoreEntry(Mobile ignored)
{ {

View file

@ -738,7 +738,7 @@ namespace Server.Engines.ConPVP
private class ArenaEntry private class ArenaEntry
{ {
public Arena m_Arena; public readonly Arena m_Arena;
public int m_VotesAgainst; public int m_VotesAgainst;
public int m_VotesFor; public int m_VotesFor;
@ -747,9 +747,7 @@ namespace Server.Engines.ConPVP
public int Value => m_VotesFor; public int Value => m_VotesFor;
} }
#region Offsets & Rotation private static readonly Point2D[] m_EdgeOffsets =
private static Point2D[] m_EdgeOffsets =
{ {
/* /*
* /\ * /\
@ -772,7 +770,7 @@ namespace Server.Engines.ConPVP
}; };
// nw corner // nw corner
private static Point2D[] m_CornerOffsets = private static readonly Point2D[] m_CornerOffsets =
{ {
/* /*
* /\ * /\
@ -793,7 +791,7 @@ namespace Server.Engines.ConPVP
new Point2D(3, 0) new Point2D(3, 0)
}; };
private static int[][,] m_Rotate = private static readonly int[][,] m_Rotate =
{ {
new[,] { { +1, 0 }, { 0, +1 } }, // west new[,] { { +1, 0 }, { 0, +1 } }, // west
new[,] { { -1, 0 }, { 0, -1 } }, // east new[,] { { -1, 0 }, { 0, -1 } }, // east
@ -804,7 +802,5 @@ namespace Server.Engines.ConPVP
new[,] { { 0, +1 }, { +1, 0 } }, // sw new[,] { { 0, +1 }, { +1, 0 } }, // sw
new[,] { { 0, -1 }, { -1, 0 } } // ne new[,] { { 0, -1 }, { -1, 0 } } // ne
}; };
#endregion
} }
} }

View file

@ -26,8 +26,8 @@ namespace Server.Engines.ConPVP
public class DuelContext public class DuelContext
{ {
private static TimeSpan CombatDelay = TimeSpan.FromSeconds(30.0); private static readonly TimeSpan CombatDelay = TimeSpan.FromSeconds(30.0);
private static TimeSpan AutoTieDelay = TimeSpan.FromMinutes(15.0); private static readonly TimeSpan AutoTieDelay = TimeSpan.FromMinutes(15.0);
private Timer m_AutoTieTimer; private Timer m_AutoTieTimer;
@ -44,7 +44,7 @@ namespace Server.Engines.ConPVP
private Timer m_SDWarnTimer, m_SDActivateTimer; private Timer m_SDWarnTimer, m_SDActivateTimer;
public Tournament m_Tournament; public Tournament m_Tournament;
private List<Item> m_Walls = new List<Item>(); private readonly List<Item> m_Walls = new List<Item>();
private bool m_Yielding; private bool m_Yielding;
@ -139,7 +139,6 @@ namespace Server.Engines.ConPVP
else if (move is SamuraiMove) else if (move is SamuraiMove)
title = "Ninjitsu"; title = "Ninjitsu";
if (title == null || name == null || Ruleset.GetOption(title, name)) if (title == null || name == null || Ruleset.GetOption(title, name))
return true; return true;
@ -1765,7 +1764,7 @@ namespace Server.Engines.ConPVP
BounceInfo bi = inHand.GetBounce(); BounceInfo bi = inHand.GetBounce();
if (bi.m_Parent == mob) if (bi.Parent == mob)
pack.DropItem(inHand); pack.DropItem(inHand);
else else
inHand.Bounce(mob); inHand.Bounce(mob);
@ -2373,7 +2372,7 @@ namespace Server.Engines.ConPVP
private class ArenaMoongate : ConfirmationMoongate private class ArenaMoongate : ConfirmationMoongate
{ {
private ExitTeleporter m_Teleporter; private readonly ExitTeleporter m_Teleporter;
public ArenaMoongate(Point3D target, Map map, ExitTeleporter tp) : base(target, map) public ArenaMoongate(Point3D target, Map map, ExitTeleporter tp) : base(target, map)
{ {

View file

@ -14,16 +14,15 @@ namespace Server.Engines.ConPVP
{ {
private bool m_Flying; private bool m_Flying;
private BRGame m_Game; private readonly BRGame m_Game;
private List<Mobile> m_Helpers; private readonly List<Mobile> m_Helpers;
private Point3DList m_Path = new Point3DList(); private readonly Point3DList m_Path = new Point3DList();
private int m_PathIdx; private int m_PathIdx;
private EffectTimer m_Timer; private readonly EffectTimer m_Timer;
public BRBomb(BRGame game) : public BRBomb(BRGame game) : base(0x103C) // 0x103C = bread, 0x1042 = pie, 0x1364 = rock, 0x13a8 = pillow, 0x2256 = bagball
base(0x103C) // 0x103C = bread, 0x1042 = pie, 0x1364 = rock, 0x13a8 = pillow, 0x2256 = bagball
{ {
Movable = false; Movable = false;
Hue = 0x35; Hue = 0x35;
@ -470,7 +469,7 @@ namespace Server.Engines.ConPVP
point = m_Path[j]; point = m_Path[j];
if (loc.X == point.X && loc.Y == point.Y && if (loc.X == point.X && loc.Y == point.Y &&
(i is Blocker || loc.Z <= point.Z && loc.Z + height >= point.Z)) (i is Blocker || (loc.Z <= point.Z && loc.Z + height >= point.Z)))
{ {
found = true; found = true;
if (j > m_PathIdx) if (j > m_PathIdx)
@ -663,7 +662,7 @@ namespace Server.Engines.ConPVP
private class EffectTimer : Timer private class EffectTimer : Timer
{ {
private BRBomb m_Bomb; private readonly BRBomb m_Bomb;
private int m_Count; private int m_Count;
public EffectTimer(BRBomb bomb) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0)) public EffectTimer(BRBomb bomb) : base(TimeSpan.Zero, TimeSpan.FromSeconds(1.0))
@ -705,8 +704,8 @@ namespace Server.Engines.ConPVP
private class BombTarget : Target private class BombTarget : Target
{ {
private BRBomb m_Bomb; private readonly BRBomb m_Bomb;
private Mobile m_Mob; private readonly Mobile m_Mob;
private bool m_Resend = true; private bool m_Resend = true;
public BombTarget(BRBomb bomb, Mobile from) : base(10, true, TargetFlags.None) public BombTarget(BRBomb bomb, Mobile from) : base(10, true, TargetFlags.None)
@ -1117,7 +1116,7 @@ namespace Server.Engines.ConPVP
private int m_Kills; private int m_Kills;
private int m_Score; private int m_Score;
private BRTeamInfo m_TeamInfo; private readonly BRTeamInfo m_TeamInfo;
public BRPlayerInfo(BRTeamInfo teamInfo, Mobile player) public BRPlayerInfo(BRTeamInfo teamInfo, Mobile player)
{ {

View file

@ -81,7 +81,7 @@ namespace Server.Engines.ConPVP
if (player.Score > 0) if (player.Score > 0)
entries.Add(player); entries.Add(player);
entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; }); entries.Sort((a, b) => b.Score - a.Score);
int height = 0; int height = 0;
@ -510,7 +510,7 @@ namespace Server.Engines.ConPVP
private int m_Kills; private int m_Kills;
private int m_Score; private int m_Score;
private CTFTeamInfo m_TeamInfo; private readonly CTFTeamInfo m_TeamInfo;
public CTFPlayerInfo(CTFTeamInfo teamInfo, Mobile player) public CTFPlayerInfo(CTFTeamInfo teamInfo, Mobile player)
{ {
@ -999,7 +999,7 @@ namespace Server.Engines.ConPVP
teams.Add(teamInfo); teams.Add(teamInfo);
} }
teams.Sort(delegate(CTFTeamInfo a, CTFTeamInfo b) { return b.Score - a.Score; }); teams.Sort((a, b) => b.Score - a.Score);
Tournament tourney = m_Context.m_Tournament; Tournament tourney = m_Context.m_Tournament;

View file

@ -76,7 +76,7 @@ namespace Server.Engines.ConPVP
if (player.Score > 0) if (player.Score > 0)
entries.Add(player); entries.Add(player);
entries.Sort(delegate(IRankedCTF a, IRankedCTF b) { return b.Score - a.Score; }); entries.Sort((a, b) => b.Score - a.Score);
int height = 0; int height = 0;
@ -204,7 +204,7 @@ namespace Server.Engines.ConPVP
private int m_Kills; private int m_Kills;
private int m_Score; private int m_Score;
private DDTeamInfo m_TeamInfo; private readonly DDTeamInfo m_TeamInfo;
public DDPlayerInfo(DDTeamInfo teamInfo, Mobile player) public DDPlayerInfo(DDTeamInfo teamInfo, Mobile player)
{ {

View file

@ -182,7 +182,7 @@ namespace Server.Engines.ConPVP
private class KingTimer : Timer private class KingTimer : Timer
{ {
private int m_Counter; private int m_Counter;
private HillOfTheKing m_Hill; private readonly HillOfTheKing m_Hill;
public KingTimer(HillOfTheKing hill) public KingTimer(HillOfTheKing hill)
: base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0)) : base(TimeSpan.FromSeconds(1.0), TimeSpan.FromSeconds(1.0))
@ -486,7 +486,7 @@ namespace Server.Engines.ConPVP
private int m_Kills; private int m_Kills;
private int m_Score; private int m_Score;
private KHTeamInfo m_TeamInfo; private readonly KHTeamInfo m_TeamInfo;
public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player) public KHPlayerInfo(KHTeamInfo teamInfo, Mobile player)
{ {

View file

@ -67,7 +67,6 @@ namespace Server.Engines.ConPVP
TourneyPart = tourneyPart TourneyPart = tourneyPart
}; };
for (int j = 0; j < tourneyPart.Players.Count; ++j) for (int j = 0; j < tourneyPart.Players.Count; ++j)
duelPart.Add(tourneyPart.Players[j]); duelPart.Add(tourneyPart.Players[j]);

View file

@ -14,14 +14,13 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF; private const int LabelColor32 = 0xFFFFFF;
private bool m_Active; private bool m_Active;
private Mobile m_From; private readonly Mobile m_From;
private List<Mobile> m_Players; private readonly List<Mobile> m_Players;
private Mobile m_Registrar; private readonly Mobile m_Registrar;
private Mobile m_Requested; private readonly Mobile m_Requested;
private Tournament m_Tournament; private readonly Tournament m_Tournament;
public AcceptTeamGump(Mobile from, Mobile requested, Tournament tourney, Mobile registrar, List<Mobile> players) : public AcceptTeamGump(Mobile from, Mobile requested, Tournament tourney, Mobile registrar, List<Mobile> players) : base(50, 50)
base(50, 50)
{ {
m_From = from; m_From = from;
m_Requested = requested; m_Requested = requested;
@ -31,8 +30,6 @@ namespace Server.Engines.ConPVP
m_Active = true; m_Active = true;
#region Rules
Ruleset ruleset = tourney.Ruleset; Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base; Ruleset basedef = ruleset.Base;
@ -66,8 +63,6 @@ namespace Server.Engines.ConPVP
height += 10 + 22 + 25 + 25; height += 10 + 22 + 25 + 25;
#endregion
Closable = false; Closable = false;
AddPage(0); AddPage(0);
@ -124,8 +119,6 @@ namespace Server.Engines.ConPVP
AddImageTiled(32, 88, 264, 1, 9107); AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157); AddImageTiled(42, 90, 264, 1, 9157);
#region Rules
int y = 100; int y = 100;
var groupText = tourney.GroupType switch var groupText = tourney.GroupType switch
@ -144,8 +137,8 @@ namespace Server.Engines.ConPVP
TieType.Random => "Random", TieType.Random => "Random",
TieType.Highest => "Highest advances", TieType.Highest => "Highest advances",
TieType.Lowest => "Lowest advances", TieType.Lowest => "Lowest advances",
TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"), TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances",
TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"), TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated",
_ => null _ => null
}; };
@ -205,8 +198,6 @@ namespace Server.Engines.ConPVP
y += 20; y += 20;
} }
#endregion
y += 8; y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107); AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157); AddImageTiled(42, y + 1, 264, 1, 9157);

View file

@ -72,11 +72,11 @@ namespace Server.Engines.ConPVP
public class ArenaGump : Gump public class ArenaGump : Gump
{ {
private List<Arena> m_Arenas; private readonly List<Arena> m_Arenas;
private int m_ColumnX = 12; private int m_ColumnX = 12;
private Mobile m_From; private readonly Mobile m_From;
private ArenasMoongate m_Gate; private readonly ArenasMoongate m_Gate;
public ArenaGump(Mobile from, ArenasMoongate gate) : base(50, 50) public ArenaGump(Mobile from, ArenasMoongate gate) : base(50, 50)
{ {

View file

@ -14,10 +14,10 @@ namespace Server.Engines.ConPVP
{ {
private const int BlackColor32 = 0x000008; private const int BlackColor32 = 0x000008;
private const int LabelColor32 = 0xFFFFFF; private const int LabelColor32 = 0xFFFFFF;
private Mobile m_From; private readonly Mobile m_From;
private List<Mobile> m_Players; private readonly List<Mobile> m_Players;
private Mobile m_Registrar; private readonly Mobile m_Registrar;
private Tournament m_Tournament; private readonly Tournament m_Tournament;
public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List<Mobile> players) : base(50, 50) public ConfirmSignupGump(Mobile from, Mobile registrar, Tournament tourney, List<Mobile> players) : base(50, 50)
{ {
@ -31,8 +31,6 @@ namespace Server.Engines.ConPVP
m_From.CloseGump<DuelContextGump>(); m_From.CloseGump<DuelContextGump>();
m_From.CloseGump<ConfirmSignupGump>(); m_From.CloseGump<ConfirmSignupGump>();
#region Rules
Ruleset ruleset = tourney.Ruleset; Ruleset ruleset = tourney.Ruleset;
Ruleset basedef = ruleset.Base; Ruleset basedef = ruleset.Base;
@ -69,8 +67,6 @@ namespace Server.Engines.ConPVP
if (tourney.PlayersPerParticipant > 1) if (tourney.PlayersPerParticipant > 1)
height += 36 + tourney.PlayersPerParticipant * 20; height += 36 + tourney.PlayersPerParticipant * 20;
#endregion
Closable = false; Closable = false;
AddPage(0); AddPage(0);
@ -128,8 +124,6 @@ namespace Server.Engines.ConPVP
AddImageTiled(32, 88, 264, 1, 9107); AddImageTiled(32, 88, 264, 1, 9107);
AddImageTiled(42, 90, 264, 1, 9157); AddImageTiled(42, 90, 264, 1, 9157);
#region Rules
int y = 100; int y = 100;
var groupText = tourney.GroupType switch var groupText = tourney.GroupType switch
@ -148,8 +142,8 @@ namespace Server.Engines.ConPVP
TieType.Random => "Random", TieType.Random => "Random",
TieType.Highest => "Highest advances", TieType.Highest => "Highest advances",
TieType.Lowest => "Lowest advances", TieType.Lowest => "Lowest advances",
TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"), TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances",
TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"), TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated",
_ => null _ => null
}; };
@ -209,10 +203,6 @@ namespace Server.Engines.ConPVP
y += 20; y += 20;
} }
#endregion
#region Team
if (tourney.PlayersPerParticipant > 1) if (tourney.PlayersPerParticipant > 1)
{ {
y += 8; y += 8;
@ -244,8 +234,6 @@ namespace Server.Engines.ConPVP
} }
} }
#endregion
y += 8; y += 8;
AddImageTiled(32, y - 1, 264, 1, 9107); AddImageTiled(32, y - 1, 264, 1, 9107);
AddImageTiled(42, y + 1, 264, 1, 9157); AddImageTiled(42, y + 1, 264, 1, 9157);

View file

@ -66,10 +66,10 @@ namespace Server.Engines.ConPVP
public class LadderGump : Gump public class LadderGump : Gump
{ {
private int m_ColumnX = 12; private int m_ColumnX = 12;
private Ladder m_Ladder; private readonly Ladder m_Ladder;
private List<LadderEntry> m_List; private readonly List<LadderEntry> m_List;
private int m_Page; private readonly int m_Page;
public LadderGump(Ladder ladder, int page = 0) : base(50, 50) public LadderGump(Ladder ladder, int page = 0) : base(50, 50)
{ {

View file

@ -178,9 +178,9 @@ namespace Server.Engines.ConPVP
private class ParticipantTarget : Target private class ParticipantTarget : Target
{ {
private DuelContext m_Context; private readonly DuelContext m_Context;
private int m_Index; private readonly int m_Index;
private Participant m_Participant; private readonly Participant m_Participant;
public ParticipantTarget(DuelContext context, Participant p, int index) : base(12, false, TargetFlags.None) public ParticipantTarget(DuelContext context, Participant p, int index) : base(12, false, TargetFlags.None)
{ {

View file

@ -5,11 +5,11 @@ namespace Server.Engines.ConPVP
{ {
public class PickRulesetGump : Gump public class PickRulesetGump : Gump
{ {
private DuelContext m_Context; private readonly DuelContext m_Context;
private Ruleset[] m_Defaults; private readonly Ruleset[] m_Defaults;
private Ruleset[] m_Flavors; private readonly Ruleset[] m_Flavors;
private Mobile m_From; private readonly Mobile m_From;
private Ruleset m_Ruleset; private readonly Ruleset m_Ruleset;
public PickRulesetGump(Mobile from, DuelContext context, Ruleset ruleset) : base(50, 50) public PickRulesetGump(Mobile from, DuelContext context, Ruleset ruleset) : base(50, 50)
{ {

View file

@ -8,8 +8,8 @@ namespace Server.Engines.ConPVP
{ {
public class ReadyUpGump : Gump public class ReadyUpGump : Gump
{ {
private DuelContext m_Context; private readonly DuelContext m_Context;
private Mobile m_From; private readonly Mobile m_From;
public ReadyUpGump(Mobile from, DuelContext context) : base(50, 50) public ReadyUpGump(Mobile from, DuelContext context) : base(50, 50)
{ {
@ -33,8 +33,6 @@ namespace Server.Engines.ConPVP
} }
else else
{ {
#region Participants
AddPage(1); AddPage(1);
List<Participant> parts = context.Participants; List<Participant> parts = context.Participants;
@ -98,10 +96,6 @@ namespace Server.Engines.ConPVP
AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2); AddButton(102, y, 247, 248, 0, GumpButtonType.Page, 2);
AddButton(169, y, 242, 241, 2); AddButton(169, y, 242, 241, 2);
#endregion
#region Rules
AddPage(2); AddPage(2);
Ruleset ruleset = context.Ruleset; Ruleset ruleset = context.Ruleset;
@ -184,8 +178,6 @@ namespace Server.Engines.ConPVP
AddButton(102, y, 247, 248, 1); AddButton(102, y, 247, 248, 1);
AddButton(169, y, 242, 241, 3); AddButton(169, y, 242, 241, 3);
#endregion
} }
} }

View file

@ -6,11 +6,11 @@ namespace Server.Engines.ConPVP
{ {
public class RulesetGump : Gump public class RulesetGump : Gump
{ {
private DuelContext m_DuelContext; private readonly DuelContext m_DuelContext;
private Mobile m_From; private readonly Mobile m_From;
private RulesetLayout m_Page; private readonly RulesetLayout m_Page;
private bool m_ReadOnly; private readonly bool m_ReadOnly;
private Ruleset m_Ruleset; private readonly Ruleset m_Ruleset;
public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly = false) public RulesetGump(Mobile from, Ruleset ruleset, RulesetLayout page, DuelContext duelContext, bool readOnly = false)
: base(readOnly ? 310 : 50, 50) : base(readOnly ? 310 : 50, 50)

View file

@ -24,13 +24,13 @@ namespace Server.Engines.ConPVP
{ {
private const int BlackColor32 = 0x000008; private const int BlackColor32 = 0x000008;
private const int LabelColor32 = 0xFFFFFF; private const int LabelColor32 = 0xFFFFFF;
private Mobile m_From; private readonly Mobile m_From;
private List<object> m_List; private readonly List<object> m_List;
private object m_Object; private readonly object m_Object;
private int m_Page; private readonly int m_Page;
private int m_PerPage; private int m_PerPage;
private Tournament m_Tournament; private readonly Tournament m_Tournament;
private TourneyBracketGumpType m_Type; private readonly TourneyBracketGumpType m_Type;
public TournamentBracketGump(Mobile from, Tournament tourney, TourneyBracketGumpType type, public TournamentBracketGump(Mobile from, Tournament tourney, TourneyBracketGumpType type,
List<object> list = null, int page = 0, object obj = null) : base(50, 50) List<object> list = null, int page = 0, object obj = null) : base(50, 50)
@ -178,8 +178,8 @@ namespace Server.Engines.ConPVP
TieType.Random => "Random", TieType.Random => "Random",
TieType.Highest => "Highest advances", TieType.Highest => "Highest advances",
TieType.Lowest => "Lowest advances", TieType.Lowest => "Lowest advances",
TieType.FullAdvancement => (tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances"), TieType.FullAdvancement => tourney.ParticipantsPerMatch == 2 ? "Both advance" : "Everyone advances",
TieType.FullElimination => (tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated"), TieType.FullElimination => tourney.ParticipantsPerMatch == 2 ? "Both eliminated" : "Everyone eliminated",
_ => null _ => null
}; };
@ -350,7 +350,6 @@ namespace Server.Engines.ConPVP
AddLeftArrow(25, 11, ToButtonID(0, 0)); AddLeftArrow(25, 11, ToButtonID(0, 0));
AddHtml(25, 35, 250, 20, Center("Rounds")); AddHtml(25, 35, 250, 20, Center("Rounds"));
// List<PyramidLevel> levelsList = m_List != null // List<PyramidLevel> levelsList = m_List != null
// ? Utility.CastListCovariant<object, PyramidLevel>(m_List) // ? Utility.CastListCovariant<object, PyramidLevel>(m_List)
// : new List<PyramidLevel>(tourney.Pyramid.Levels); // : new List<PyramidLevel>(tourney.Pyramid.Levels);

View file

@ -68,7 +68,7 @@ namespace Server.Engines.ConPVP
public class Ladder public class Ladder
{ {
private static int[] m_ShortLevels = private static readonly int[] m_ShortLevels =
{ {
1, 1,
2, 2,
@ -81,12 +81,12 @@ namespace Server.Engines.ConPVP
9, 9, 9, 9, 9 9, 9, 9, 9, 9
}; };
private static int[] m_BaseXP = private static readonly int[] m_BaseXP =
{ {
0, 100, 200, 400, 600, 900, 1200, 1600, 2000, 2500 0, 100, 200, 400, 600, 900, 1200, 1600, 2000, 2500
}; };
private static int[] m_LossFactors = private static readonly int[] m_LossFactors =
{ {
10, 10,
11, 11, 11, 11,
@ -95,7 +95,7 @@ namespace Server.Engines.ConPVP
67, 67 67, 67
}; };
private static int[,] m_OffsetScalar = private static readonly int[,] m_OffsetScalar =
{ {
/* { win, los } */ /* { win, los } */
/* -6 */ { 175, 25 }, /* -6 */ { 175, 25 },
@ -115,7 +115,7 @@ namespace Server.Engines.ConPVP
public List<LadderEntry> Entries { get; } = new List<LadderEntry>(); public List<LadderEntry> Entries { get; } = new List<LadderEntry>();
private Dictionary<Mobile, LadderEntry> m_Table; private readonly Dictionary<Mobile, LadderEntry> m_Table;
public Ladder() => m_Table = new Dictionary<Mobile, LadderEntry>(); public Ladder() => m_Table = new Dictionary<Mobile, LadderEntry>();
@ -295,7 +295,7 @@ namespace Server.Engines.ConPVP
public class LadderEntry : IComparable<LadderEntry> public class LadderEntry : IComparable<LadderEntry>
{ {
private int m_Experience; private int m_Experience;
private Ladder m_Ladder; private readonly Ladder m_Ladder;
public LadderEntry(Mobile mob, Ladder ladder) public LadderEntry(Mobile mob, Ladder ladder)
{ {

View file

@ -64,7 +64,7 @@ namespace Server.Engines.ConPVP
public class Preferences public class Preferences
{ {
private Dictionary<Mobile, PreferencesEntry> m_Table; private readonly Dictionary<Mobile, PreferencesEntry> m_Table;
public Preferences() public Preferences()
{ {
@ -173,7 +173,7 @@ namespace Server.Engines.ConPVP
public class PreferencesGump : Gump public class PreferencesGump : Gump
{ {
private int m_ColumnX = 12; private int m_ColumnX = 12;
private PreferencesEntry m_Entry; private readonly PreferencesEntry m_Entry;
public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50) public PreferencesGump(Mobile from, Preferences prefs) : base(50, 50)
{ {

View file

@ -7,21 +7,21 @@ namespace Server.Engines.ConPVP
{ {
private static RulesetLayout m_Root; private static RulesetLayout m_Root;
public RulesetLayout(string title, string[] options) : this(title, title, new RulesetLayout[0], options) public RulesetLayout(string title, string[] options) : this(title, title, Array.Empty<RulesetLayout>(), options)
{ {
} }
public RulesetLayout(string title, string description, string[] options) : this(title, description, public RulesetLayout(string title, string description, string[] options) : this(title, description,
new RulesetLayout[0], options) Array.Empty<RulesetLayout>(), options)
{ {
} }
public RulesetLayout(string title, RulesetLayout[] children) : this(title, title, children, new string[0]) public RulesetLayout(string title, RulesetLayout[] children) : this(title, title, children, Array.Empty<string>())
{ {
} }
public RulesetLayout(string title, string description, RulesetLayout[] children) : this(title, description, children, public RulesetLayout(string title, string description, RulesetLayout[] children) : this(title, description, children,
new string[0]) Array.Empty<string>())
{ {
} }
@ -356,8 +356,6 @@ namespace Server.Engines.ConPVP
if (!Core.AOS) if (!Core.AOS)
{ {
#region Mage 5x
Ruleset m5x = new Ruleset(m_Root); Ruleset m5x = new Ruleset(m_Root);
m5x.Title = "Mage 5x"; m5x.Title = "Mage 5x";
@ -404,10 +402,6 @@ namespace Server.Engines.ConPVP
m5x.SetOption("Items", "Trapped Containers", true); m5x.SetOption("Items", "Trapped Containers", true);
#endregion
#region Mage 7x
Ruleset m7x = new Ruleset(m_Root); Ruleset m7x = new Ruleset(m_Root);
m7x.Title = "Mage 7x"; m7x.Title = "Mage 7x";
@ -459,10 +453,6 @@ namespace Server.Engines.ConPVP
m7x.SetOption("Items", "Trapped Containers", true); m7x.SetOption("Items", "Trapped Containers", true);
m7x.SetOption("Items", "Bandages", true); m7x.SetOption("Items", "Bandages", true);
#endregion
#region Standard 7x
Ruleset s7x = new Ruleset(m_Root); Ruleset s7x = new Ruleset(m_Root);
s7x.Title = "Standard 7x"; s7x.Title = "Standard 7x";
@ -514,19 +504,14 @@ namespace Server.Engines.ConPVP
s7x.SetOption("Items", "Bandages", true); s7x.SetOption("Items", "Bandages", true);
s7x.SetOption("Items", "Trapped Containers", true); s7x.SetOption("Items", "Trapped Containers", true);
#endregion
m_Root.Defaults = new[] { m5x, m7x, s7x }; m_Root.Defaults = new[] { m5x, m7x, s7x };
} }
else else
{ {
#region Standard All Skills
Ruleset all = new Ruleset(m_Root); Ruleset all = new Ruleset(m_Root);
all.Title = "Standard All Skills"; all.Title = "Standard All Skills";
all.SetOptionRange("Spells", true); all.SetOptionRange("Spells", true);
all.SetOption("Spells", "Wall of Stone", false); all.SetOption("Spells", "Wall of Stone", false);
@ -606,15 +591,12 @@ namespace Server.Engines.ConPVP
all.SetOption("Items", "Trapped Containers", true); all.SetOption("Items", "Trapped Containers", true);
m_Root.Defaults = new[] { all }; m_Root.Defaults = new[] { all };
#endregion
} }
// Set up flavors // Set up flavors
Ruleset pots = new Ruleset(m_Root) { Title = "Potions" }; Ruleset pots = new Ruleset(m_Root) { Title = "Potions" };
pots.SetOptionRange("Potions", true); pots.SetOptionRange("Potions", true);
pots.SetOption("Potions", "Explosion", false); pots.SetOption("Potions", "Explosion", false);

View file

@ -873,7 +873,6 @@ namespace Server.Engines.ConPVP
Undefeated.Clear(); Undefeated.Clear();
break; break;
} }
} }
if (Undefeated.Count > 1) if (Undefeated.Count > 1)

View file

@ -7,7 +7,7 @@ namespace Server.Engines.ConPVP
{ {
public class TournamentController : Item public class TournamentController : Item
{ {
private static List<TournamentController> m_Instances = new List<TournamentController>(); private static readonly List<TournamentController> m_Instances = new List<TournamentController>();
[Constructible] [Constructible]
public TournamentController() : base(0x1B7A) public TournamentController() : base(0x1B7A)
@ -104,7 +104,7 @@ namespace Server.Engines.ConPVP
private class EditEntry : ContextMenuEntry private class EditEntry : ContextMenuEntry
{ {
private Tournament m_Tournament; private readonly Tournament m_Tournament;
public EditEntry(Tournament tourney) : base(5101) => m_Tournament = tourney; public EditEntry(Tournament tourney) : base(5101) => m_Tournament = tourney;
@ -116,7 +116,7 @@ namespace Server.Engines.ConPVP
private class StartEntry : ContextMenuEntry private class StartEntry : ContextMenuEntry
{ {
private Tournament m_Tournament; private readonly Tournament m_Tournament;
public StartEntry(Tournament tourney) : base(5113) => m_Tournament = tourney; public StartEntry(Tournament tourney) : base(5113) => m_Tournament = tourney;

View file

@ -148,7 +148,7 @@ namespace Server.Engines.ConPVP
{ {
var idx = groupType switch var idx = groupType switch
{ {
GroupingType.HighVsLow => (i * (copy.Count - 1) / (partsPerMatch - 1)), GroupingType.HighVsLow => i * (copy.Count - 1) / (partsPerMatch - 1),
GroupingType.Nearest => 0, GroupingType.Nearest => 0,
GroupingType.Random => Utility.Random(copy.Count), GroupingType.Random => Utility.Random(copy.Count),
_ => 0 _ => 0

View file

@ -28,8 +28,8 @@ namespace Server.Engines.Craft
int nameNumber = craftGroup.NameNumber; int nameNumber = craftGroup.NameNumber;
string nameString = craftGroup.NameString; string nameString = craftGroup.NameString;
if (nameNumber != 0 && nameNumber == groupName.Number || if ((nameNumber != 0 && nameNumber == groupName.Number) ||
nameString != null && nameString == groupName.String) (nameString != null && nameString == groupName.String))
return i; return i;
} }

View file

@ -11,11 +11,11 @@ namespace Server.Engines.Craft
private const int LabelHue = 0x480; private const int LabelHue = 0x480;
private const int LabelColor = 0x7FFF; private const int LabelColor = 0x7FFF;
private const int FontColor = 0xFFFFFF; private const int FontColor = 0xFFFFFF;
private CraftSystem m_CraftSystem; private readonly CraftSystem m_CraftSystem;
private Mobile m_From; private readonly Mobile m_From;
private CraftPage m_Page; private readonly CraftPage m_Page;
private BaseTool m_Tool; private readonly BaseTool m_Tool;
public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page = CraftPage.None) : base(40, 40) public CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page = CraftPage.None) : base(40, 40)
{ {

View file

@ -16,16 +16,16 @@ namespace Server.Engines.Craft
private const int GreyLabelColor = 0x3DEF; private const int GreyLabelColor = 0x3DEF;
private static Type typeofBlankScroll = typeof(BlankScroll); private static readonly Type typeofBlankScroll = typeof(BlankScroll);
private static Type typeofSpellScroll = typeof(SpellScroll); private static readonly Type typeofSpellScroll = typeof(SpellScroll);
private CraftItem m_CraftItem; private readonly CraftItem m_CraftItem;
private CraftSystem m_CraftSystem; private readonly CraftSystem m_CraftSystem;
private Mobile m_From; private readonly Mobile m_From;
private int m_OtherCount; private int m_OtherCount;
private bool m_ShowExceptionalChance; private bool m_ShowExceptionalChance;
private BaseTool m_Tool; private readonly BaseTool m_Tool;
public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool) : base(40, 40) public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool) : base(40, 40)
{ {

View file

@ -24,7 +24,7 @@ namespace Server.Engines.Craft
public class CraftItem public class CraftItem
{ {
private static Dictionary<Type, int> _itemIds = new Dictionary<Type, int>(); private static readonly Dictionary<Type, int> _itemIds = new Dictionary<Type, int>();
private int m_ResAmount; private int m_ResAmount;
private int m_ResHue; private int m_ResHue;
@ -170,7 +170,6 @@ namespace Server.Engines.Craft
Resources.Add(craftRes); Resources.Add(craftRes);
} }
public void AddSkill(SkillName skillToMake, double minSkill, double maxSkill) public void AddSkill(SkillName skillToMake, double minSkill, double maxSkill)
{ {
CraftSkill craftSkill = new CraftSkill(skillToMake, minSkill, maxSkill); CraftSkill craftSkill = new CraftSkill(skillToMake, minSkill, maxSkill);
@ -302,7 +301,7 @@ namespace Server.Engines.Craft
return false; return false;
} }
public bool Find(int itemID, int[] itemIDs) public static bool Find(int itemID, int[] itemIDs)
{ {
bool contains = false; bool contains = false;
@ -312,19 +311,8 @@ namespace Server.Engines.Craft
return contains; return contains;
} }
public bool IsQuantityType(Type[][] types) public bool IsQuantityType(Type[][] types) =>
{ types.Any(check => check.Any(t => typeof(IHasQuantity).IsAssignableFrom(t)));
for (int i = 0; i < types.Length; ++i)
{
Type[] check = types[i];
for (int j = 0; j < check.Length; ++j)
if (typeof(IHasQuantity).IsAssignableFrom(check[j]))
return true;
}
return false;
}
public int ConsumeQuantity(Container cont, Type[][] types, int[] amounts) public int ConsumeQuantity(Container cont, Type[][] types, int[] amounts)
{ {
@ -461,6 +449,7 @@ namespace Server.Engines.Craft
CraftSubResCol resCol = UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes; CraftSubResCol resCol = UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes;
CraftRes res;
for (int i = 0; i < types.Length; ++i) for (int i = 0; i < types.Length; ++i)
{ {
CraftRes craftRes = Resources.GetAt(i); CraftRes craftRes = Resources.GetAt(i);
@ -501,7 +490,7 @@ namespace Server.Engines.Craft
if (maxAmount == 0) if (maxAmount == 0)
{ {
CraftRes res = Resources.GetAt(i); res = Resources.GetAt(i);
if (res.MessageNumber > 0) if (res.MessageNumber > 0)
message = res.MessageNumber; message = res.MessageNumber;
@ -557,7 +546,6 @@ namespace Server.Engines.Craft
resHue = m_ResHue; resHue = m_ResHue;
} }
// Consume Half ( for use all resource craft type ) // Consume Half ( for use all resource craft type )
else if (consumeType == ConsumeType.Half) else if (consumeType == ConsumeType.Half)
{ {
@ -580,7 +568,6 @@ namespace Server.Engines.Craft
resHue = m_ResHue; resHue = m_ResHue;
} }
else // ConstumeType.None ( it's basically used to know if the crafter has enough resource before starting the process ) else // ConstumeType.None ( it's basically used to know if the crafter has enough resource before starting the process )
{ {
index = -1; index = -1;
@ -612,8 +599,7 @@ namespace Server.Engines.Craft
return true; return true;
} }
{ res = Resources.GetAt(index);
CraftRes res = Resources.GetAt(index);
if (res.MessageNumber > 0) if (res.MessageNumber > 0)
message = res.MessageNumber; message = res.MessageNumber;
@ -624,7 +610,6 @@ namespace Server.Engines.Craft
return false; return false;
} }
}
private void OnResourceConsumed(Item item, int amount) private void OnResourceConsumed(Item item, int amount)
{ {
@ -833,7 +818,7 @@ namespace Server.Engines.Craft
{ {
return expansion switch return expansion switch
{ {
Expansion.SE => (object)1063307, // The "Samurai Empire" expansion is required to attempt this item. Expansion.SE => 1063307, // The "Samurai Empire" expansion is required to attempt this item.
Expansion.ML => 1072650, // The "Mondain's Legacy" expansion is required to attempt this item. Expansion.ML => 1072650, // The "Mondain's Legacy" expansion is required to attempt this item.
_ => $"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item." _ => $"The \"{ExpansionInfo.GetInfo(expansion).Name}\" expansion is required to attempt this item."
}; };
@ -1052,13 +1037,13 @@ namespace Server.Engines.Craft
private class InternalTimer : Timer private class InternalTimer : Timer
{ {
private CraftItem m_CraftItem; private readonly CraftItem m_CraftItem;
private CraftSystem m_CraftSystem; private readonly CraftSystem m_CraftSystem;
private Mobile m_From; private readonly Mobile m_From;
private int m_iCount; private int m_iCount;
private int m_iCountMax; private readonly int m_iCountMax;
private BaseTool m_Tool; private readonly BaseTool m_Tool;
private Type m_TypeRes; private readonly Type m_TypeRes;
public InternalTimer(Mobile from, CraftSystem craftSystem, CraftItem craftItem, Type typeRes, BaseTool tool, public InternalTimer(Mobile from, CraftSystem craftSystem, CraftItem craftItem, Type typeRes, BaseTool tool,
int iCountMax) : base(TimeSpan.Zero, TimeSpan.FromSeconds(craftSystem.Delay), iCountMax) int iCountMax) : base(TimeSpan.Zero, TimeSpan.FromSeconds(craftSystem.Delay), iCountMax)
@ -1148,9 +1133,7 @@ namespace Server.Engines.Craft
} }
} }
#region Tables private static readonly int[] m_HeatSources =
private static int[] m_HeatSources =
{ {
0x461, 0x48E, // Sandstone oven/fireplace 0x461, 0x48E, // Sandstone oven/fireplace
0x92B, 0x96C, // Stone oven/fireplace 0x92B, 0x96C, // Stone oven/fireplace
@ -1166,20 +1149,20 @@ namespace Server.Engines.Craft
0x2DD8, 0x2DD8 // Elven Forge 0x2DD8, 0x2DD8 // Elven Forge
}; };
private static int[] m_Ovens = private static readonly int[] m_Ovens =
{ {
0x461, 0x46F, // Sandstone oven 0x461, 0x46F, // Sandstone oven
0x92B, 0x93F, // Stone oven 0x92B, 0x93F, // Stone oven
0x2DDB, 0x2DDC // Elven stove 0x2DDB, 0x2DDC // Elven stove
}; };
private static int[] m_Mills = private static readonly int[] m_Mills =
{ {
0x1920, 0x1921, 0x1922, 0x1923, 0x1924, 0x1295, 0x1926, 0x1928, 0x1920, 0x1921, 0x1922, 0x1923, 0x1924, 0x1295, 0x1926, 0x1928,
0x192C, 0x192D, 0x192E, 0x129F, 0x1930, 0x1931, 0x1932, 0x1934 0x192C, 0x192D, 0x192E, 0x129F, 0x1930, 0x1931, 0x1932, 0x1934
}; };
private static Type[][] m_TypesTable = private static readonly Type[][] m_TypesTable =
{ {
new[] { typeof(Log), typeof(Board) }, new[] { typeof(Log), typeof(Board) },
new[] { typeof(HeartwoodLog), typeof(HeartwoodBoard) }, new[] { typeof(HeartwoodLog), typeof(HeartwoodBoard) },
@ -1199,13 +1182,13 @@ namespace Server.Engines.Craft
new[] { typeof(WoodenBowlOfPeas), typeof(PewterBowlOfPeas) } new[] { typeof(WoodenBowlOfPeas), typeof(PewterBowlOfPeas) }
}; };
private static Type[] m_ColoredItemTable = private static readonly Type[] m_ColoredItemTable =
{ {
typeof(BaseWeapon), typeof(BaseArmor), typeof(BaseClothing), typeof(BaseWeapon), typeof(BaseArmor), typeof(BaseClothing),
typeof(BaseJewel), typeof(DragonBardingDeed) typeof(BaseJewel), typeof(DragonBardingDeed)
}; };
private static Type[] m_ColoredResourceTable = private static readonly Type[] m_ColoredResourceTable =
{ {
typeof(BaseIngot), typeof(BaseOre), typeof(BaseIngot), typeof(BaseOre),
typeof(BaseLeather), typeof(BaseHides), typeof(BaseLeather), typeof(BaseHides),
@ -1213,7 +1196,7 @@ namespace Server.Engines.Craft
typeof(BaseGranite), typeof(BaseScales) typeof(BaseGranite), typeof(BaseScales)
}; };
private static Type[] m_MarkableTable = private static readonly Type[] m_MarkableTable =
{ {
typeof(BaseArmor), typeof(BaseArmor),
typeof(BaseWeapon), typeof(BaseWeapon),
@ -1227,11 +1210,9 @@ namespace Server.Engines.Craft
typeof(BaseQuiver) typeof(BaseQuiver)
}; };
private static Type[] m_NeverColorTable = private static readonly Type[] m_NeverColorTable =
{ {
typeof(OrcHelm) typeof(OrcHelm)
}; };
#endregion
} }
} }

View file

@ -13,9 +13,9 @@ namespace Server.Engines.Craft
public abstract class CraftSystem public abstract class CraftSystem
{ {
private Dictionary<Mobile, CraftContext> m_ContextTable = new Dictionary<Mobile, CraftContext>(); private readonly Dictionary<Mobile, CraftContext> m_ContextTable = new Dictionary<Mobile, CraftContext>();
private List<int> m_RareRecipes; private readonly List<int> m_RareRecipes;
private List<int> m_Recipes; private readonly List<int> m_Recipes;
public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay) public CraftSystem(int minCraftEffect, int maxCraftEffect, double delay)
{ {
@ -114,7 +114,6 @@ namespace Server.Engines.Craft
return m_RareRecipes[Utility.Random(m_RareRecipes.Count)]; return m_RareRecipes[Utility.Random(m_RareRecipes.Count)];
} }
public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill, public int AddCraft(Type typeItem, TextDefinition group, TextDefinition name, double minSkill, double maxSkill,
Type typeRes, TextDefinition nameRes, int amount) => Type typeRes, TextDefinition nameRes, int amount) =>
AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, ""); AddCraft(typeItem, group, name, MainSkill, minSkill, maxSkill, typeRes, nameRes, amount, "");
@ -138,7 +137,6 @@ namespace Server.Engines.Craft
return CraftItems.Add(craftItem); return CraftItems.Add(craftItem);
} }
private void DoGroup(TextDefinition groupName, CraftItem craftItem) private void DoGroup(TextDefinition groupName, CraftItem craftItem)
{ {
int index = CraftGroups.SearchFor(groupName); int index = CraftGroups.SearchFor(groupName);
@ -155,7 +153,6 @@ namespace Server.Engines.Craft
} }
} }
public void SetItemHue(int index, int hue) public void SetItemHue(int index, int hue)
{ {
CraftItem craftItem = CraftItems.GetAt(index); CraftItem craftItem = CraftItems.GetAt(index);
@ -268,7 +265,6 @@ namespace Server.Engines.Craft
craftItem.ForceNonExceptional = true; craftItem.ForceNonExceptional = true;
} }
public void SetSubRes(Type type, string name) public void SetSubRes(Type type, string name)
{ {
CraftSubRes.ResType = type; CraftSubRes.ResType = type;
@ -301,7 +297,6 @@ namespace Server.Engines.Craft
CraftSubRes.Add(craftSubRes); CraftSubRes.Add(craftSubRes);
} }
public void SetSubRes2(Type type, string name) public void SetSubRes2(Type type, string name)
{ {
CraftSubRes2.ResType = type; CraftSubRes2.ResType = type;

View file

@ -231,7 +231,7 @@ namespace Server.Engines.Craft
int random = Utility.Random(100); int random = Utility.Random(100);
if (10 > random) if (random < 10)
res = EnhanceResult.Failure; res = EnhanceResult.Failure;
else if (chance > random) else if (chance > random)
res = EnhanceResult.Broken; res = EnhanceResult.Broken;
@ -281,10 +281,10 @@ namespace Server.Engines.Craft
private class InternalTarget : Target private class InternalTarget : Target
{ {
private CraftSystem m_CraftSystem; private readonly CraftSystem m_CraftSystem;
private CraftResource m_Resource; private readonly CraftResource m_Resource;
private Type m_ResourceType; private readonly Type m_ResourceType;
private BaseTool m_Tool; private readonly BaseTool m_Tool;
public InternalTarget(CraftSystem craftSystem, BaseTool tool, Type resourceType, CraftResource resource) : base( public InternalTarget(CraftSystem craftSystem, BaseTool tool, Type resourceType, CraftResource resource) : base(
2, false, TargetFlags.None) 2, false, TargetFlags.None)

Some files were not shown because too many files have changed in this diff Show more