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

File diff suppressed because it is too large Load diff

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
{ {
@ -113,13 +112,13 @@ namespace Server.Accounting
RefreshAccessTime(); RefreshAccessTime();
} }
public IPAddress Address{ get; set; } public IPAddress Address { get; set; }
public DateTime LastAccessTime{ get; set; } public DateTime LastAccessTime { get; set; }
public bool HasExpired => DateTime.UtcNow >= LastAccessTime + TimeSpan.FromHours(1.0); public bool HasExpired => DateTime.UtcNow >= LastAccessTime + TimeSpan.FromHours(1.0);
public int Counts{ get; set; } public int Counts { get; set; }
public void RefreshAccessTime() public void RefreshAccessTime()
{ {

View file

@ -33,7 +33,7 @@ namespace Server.Accounting
/// <summary> /// <summary>
/// A string representing who added this comment. /// A string representing who added this comment.
/// </summary> /// </summary>
public string AddedBy{ get; } public string AddedBy { get; }
/// <summary> /// <summary>
/// Gets or sets the body of this comment. Setting this value will reset LastModified. /// Gets or sets the body of this comment. Setting this value will reset LastModified.
@ -51,7 +51,7 @@ namespace Server.Accounting
/// <summary> /// <summary>
/// The date and time when this account was last modified -or- the comment creation time, if never modified. /// The date and time when this account was last modified -or- the comment creation time, if never modified.
/// </summary> /// </summary>
public DateTime LastModified{ get; private set; } public DateTime LastModified { get; private set; }
/// <summary> /// <summary>
/// Serializes this AccountComment instance to an XmlTextWriter. /// Serializes this AccountComment instance to an XmlTextWriter.

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),
@ -47,7 +47,7 @@ namespace Server.Misc
// .. // ..
new CityInfo( "Haven", "Buckler's Hideaway", 3667, 2625, 0 ) new CityInfo( "Haven", "Buckler's Hideaway", 3667, 2625, 0 )
if ( Core.AOS ) if (Core.AOS)
{ {
//CityInfo haven = new CityInfo( "Haven", "Uzeraan's Mansion", 3618, 2591, 0 ); //CityInfo haven = new CityInfo( "Haven", "Uzeraan's Mansion", 3618, 2591, 0 );
CityInfo haven = new CityInfo( "Haven", "Uzeraan's Mansion", 3503, 2574, 14 ); CityInfo haven = new CityInfo( "Haven", "Uzeraan's Mansion", 3503, 2574, 14 );
@ -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;
@ -64,7 +64,7 @@ namespace Server.Misc
'<', '>', ':', '"', '/', '\\', '|', '?', '*' '<', '>', ':', '"', '/', '\\', '|', '?', '*'
}; };
public static AccessLevel LockdownLevel{ get; set; } public static AccessLevel LockdownLevel { get; set; }
public static Dictionary<IPAddress, int> IPTable public static Dictionary<IPAddress, int> 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

@ -28,12 +28,12 @@ namespace Server.Accounting
/// <summary> /// <summary>
/// Gets or sets the name of this tag. /// Gets or sets the name of this tag.
/// </summary> /// </summary>
public string Name{ get; set; } public string Name { get; set; }
/// <summary> /// <summary>
/// Gets or sets the value of this tag. /// Gets or sets the value of this tag.
/// </summary> /// </summary>
public string Value{ get; set; } public string Value { get; set; }
/// <summary> /// <summary>
/// Serializes this AccountTag instance to an XmlTextWriter. /// Serializes this AccountTag instance to an XmlTextWriter.

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

@ -30,7 +30,7 @@ namespace Server
object toAdd; object toAdd;
IPAddress addr; IPAddress addr;
if ( IPAddress.TryParse( line, out addr ) ) if (IPAddress.TryParse( line, out addr ))
toAdd = addr; toAdd = addr;
else else
toAdd = line; toAdd = line;
@ -41,7 +41,7 @@ namespace Server
} }
} }
public static List<IFirewallEntry> List{ get; } public static List<IFirewallEntry> List { get; }
public static IFirewallEntry ToFirewallEntry(object entry) public static IFirewallEntry ToFirewallEntry(object entry)
{ {
@ -60,7 +60,7 @@ namespace Server
if (IPAddress.TryParse(entry, out IPAddress addr)) if (IPAddress.TryParse(entry, out IPAddress addr))
return new IPFirewallEntry(addr); return new IPFirewallEntry(addr);
//Try CIDR parse // Try CIDR parse
string[] str = entry.Split('/'); string[] str = entry.Split('/');
if (str.Length == 2) if (str.Length == 2)
@ -147,15 +147,15 @@ namespace Server
for ( int i = 0; !contains && i < m_Blocked.Count; ++i ) for ( int i = 0; !contains && i < m_Blocked.Count; ++i )
{ {
if ( m_Blocked[i] is IPAddress ) if (m_Blocked[i] is IPAddress)
contains = ip.Equals( m_Blocked[i] ); contains = ip.Equals( m_Blocked[i] );
else if ( m_Blocked[i] is String ) else if (m_Blocked[i] is String)
{ {
string s = (string)m_Blocked[i]; string s = (string)m_Blocked[i];
contains = Utility.IPMatchCIDR( s, ip ); contains = Utility.IPMatchCIDR( s, ip );
if ( !contains ) if (!contains)
contains = Utility.IPMatch( s, ip ); contains = Utility.IPMatch( s, ip );
} }
} }
@ -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;
@ -249,7 +247,7 @@ namespace Server
public bool IsBlocked(IPAddress address) public bool IsBlocked(IPAddress address)
{ {
if (!m_Valid) if (!m_Valid)
return false; //Why process if it's invalid? it'll return false anyway after processing it. return false; // Why process if it's invalid? it'll return false anyway after processing it.
bool matched = Utility.IPMatch(m_Entry, address, out bool valid); bool matched = Utility.IPMatch(m_Entry, address, out bool valid);
m_Valid = valid; m_Valid = valid;
@ -268,7 +266,5 @@ namespace Server
public override int GetHashCode() => m_Entry.GetHashCode(); public override int GetHashCode() => m_Entry.GetHashCode();
} }
#endregion
} }
} }

View file

@ -13,7 +13,7 @@ namespace Server.Misc
public static IPAddress[] Exemptions = public static IPAddress[] Exemptions =
{ {
//IPAddress.Parse( "127.0.0.1" ), // IPAddress.Parse( "127.0.0.1" ),
}; };
public static bool IsExempt(IPAddress ip) public static bool IsExempt(IPAddress ip)

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);
@ -348,23 +347,23 @@ namespace Server.Commands
int z = start.Z; int z = start.Z;
for (int x = start.X; x <= end.X; ++x) for (int x = start.X; x <= end.X; ++x)
for (int y = start.Y; y <= end.Y; ++y) for (int y = start.Y; y <= end.Y; ++y)
{ {
if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y) if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y)
continue; continue;
if (mapAvg) if (mapAvg)
z = map.GetAverageZ(x, y); z = map.GetAverageZ(x, y);
IEntity built = Build(from, ctor, values, props, realProps, ref sendError); IEntity built = Build(from, ctor, values, props, realProps, ref sendError);
sb.AppendFormat("0x{0:X}; ", built.Serial.Value); sb.AppendFormat("0x{0:X}; ", built.Serial.Value);
if (built is Item item) if (built is Item item)
item.MoveToWorld(new Point3D(x, y, z), map); item.MoveToWorld(new Point3D(x, y, z), map);
else if (built is Mobile m) else if (built is Mobile m)
m.MoveToWorld(new Point3D(x, y, z), map); m.MoveToWorld(new Point3D(x, y, z), map);
} }
} }
CommandLogging.WriteLine(from, sb.ToString()); CommandLogging.WriteLine(from, sb.ToString());
@ -433,15 +432,15 @@ namespace Server.Commands
switch (ts.m_ZType) switch (ts.m_ZType)
{ {
case TileZType.Fixed: case TileZType.Fixed:
{ {
start.Z = end.Z = ts.m_FixedZ; start.Z = end.Z = ts.m_FixedZ;
break; break;
} }
case TileZType.MapAverage: case TileZType.MapAverage:
{ {
mapAvg = true; mapAvg = true;
break; break;
} }
} }
Invoke(from, start, end, ts.m_Args, null, ts.m_Outline, mapAvg); Invoke(from, start, end, ts.m_Args, null, ts.m_Outline, mapAvg);
@ -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

@ -6,20 +6,20 @@ namespace Server
{ {
public UsageAttribute(string usage) => Usage = usage; public UsageAttribute(string usage) => Usage = usage;
public string Usage{ get; } public string Usage { get; }
} }
public class DescriptionAttribute : Attribute public class DescriptionAttribute : Attribute
{ {
public DescriptionAttribute(string description) => Description = description; public DescriptionAttribute(string description) => Description = description;
public string Description{ get; } public string Description { get; }
} }
public class AliasesAttribute : Attribute public class AliasesAttribute : Attribute
{ {
public AliasesAttribute(params string[] aliases) => Aliases = aliases; public AliasesAttribute(params string[] aliases) => Aliases = aliases;
public string[] Aliases{ get; } public string[] Aliases { get; }
} }
} }

View file

@ -15,11 +15,11 @@ namespace Server.Commands
ListOptimized = true; ListOptimized = true;
} }
public BaseCommandImplementor Scope{ get; set; } public BaseCommandImplementor Scope { get; set; }
public string Condition{ get; set; } = ""; public string Condition { get; set; } = "";
public List<BatchCommand> BatchCommands{ get; } = new List<BatchCommand>(); public List<BatchCommand> BatchCommands { get; } = new List<BatchCommand>();
public override void ExecuteList(CommandEventArgs e, List<object> list) public override void ExecuteList(CommandEventArgs e, List<object> list)
{ {
@ -180,9 +180,9 @@ namespace Server.Commands
Object = obj; Object = obj;
} }
public string Command{ get; set; } public string Command { get; set; }
public string Object{ get; set; } public string Object { get; set; }
public void GetDetails(out string command, out string argString, out string[] args) public void GetDetails(out string command, out string argString, out string[] args)
{ {
@ -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)
{ {
@ -326,28 +326,28 @@ namespace Server.Commands
switch (type) switch (type)
{ {
case 0: // main case 0: // main
{
switch (index)
{ {
case 0: // run switch (index)
{ {
m_Batch.Run(m_From); case 0: // run
break; {
m_Batch.Run(m_From);
break;
}
case 1: // set scope
{
m_From.SendGump(new BatchScopeGump(m_From, m_Batch));
return;
}
case 2: // add command
{
m_Batch.BatchCommands.Add(new BatchCommand("", ""));
break;
}
} }
case 1: // set scope
{
m_From.SendGump(new BatchScopeGump(m_From, m_Batch));
return;
}
case 2: // add command
{
m_Batch.BatchCommands.Add(new BatchCommand("", ""));
break;
}
}
break; break;
} }
} }
m_From.SendGump(new BatchGump(m_From, m_Batch)); m_From.SendGump(new BatchGump(m_From, m_Batch));
@ -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)
{ {
@ -399,17 +399,17 @@ namespace Server.Commands
switch (type) switch (type)
{ {
case 0: case 0:
{
if (index < BaseCommandImplementor.Implementors.Count)
{ {
BaseCommandImplementor impl = BaseCommandImplementor.Implementors[index]; if (index < BaseCommandImplementor.Implementors.Count)
{
BaseCommandImplementor impl = BaseCommandImplementor.Implementors[index];
if (m_From.AccessLevel >= impl.AccessLevel) if (m_From.AccessLevel >= impl.AccessLevel)
m_Batch.Scope = impl; m_Batch.Scope = impl;
}
break;
} }
break;
}
} }
m_From.SendGump(new BatchGump(m_From, m_Batch)); m_From.SendGump(new BatchGump(m_From, m_Batch));

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;
} }
@ -1083,11 +1080,11 @@ namespace Server.Commands
Extra = line; Extra = line;
} }
public Point3D Location{ get; } public Point3D Location { get; }
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;
@ -1070,9 +1069,9 @@ namespace Server.Commands
Extra = line; Extra = line;
} }
public Point3D Location{ get; } public Point3D Location { get; }
public string Extra{ get; } public string Extra { get; }
public void Pop(out string v, ref string line) public void Pop(out string v, ref string line)
{ {

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(
@ -270,7 +270,7 @@ namespace Server.Commands
else else
linkName = link; linkName = link;
//Console.WriteLine( typeName+":"+fileName+":"+linkName ); // Console.WriteLine( typeName+":"+fileName+":"+linkName );
} }
public static string SanitizeType(string name) public static string SanitizeType(string name)
@ -312,7 +312,7 @@ namespace Server.Commands
public static bool DontLink( string name ) public static bool DontLink( string name )
{ {
foreach( string dontLink in m_DontLink ) foreach( string dontLink in m_DontLink )
if ( dontLink == name ) return true; if (dontLink == name ) return true;
return false; return false;
} }
*/ */
@ -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)
{ {
@ -1221,20 +1207,20 @@ namespace Server.Commands
switch (material) switch (material)
{ {
case BulkMaterialType.None: case BulkMaterialType.None:
{
if (type.IsSubclassOf(typeof(BaseArmor)) || type.IsSubclassOf(typeof(BaseShoes)))
{ {
style = "pl"; if (type.IsSubclassOf(typeof(BaseArmor)) || type.IsSubclassOf(typeof(BaseShoes)))
name = "Plain"; {
} style = "pl";
else name = "Plain";
{ }
style = "cl"; else
name = "Cloth"; {
} style = "cl";
name = "Cloth";
}
break; break;
} }
case BulkMaterialType.Spined: case BulkMaterialType.Spined:
style = "sp"; style = "sp";
name = "Spined"; name = "Spined";
@ -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();
@ -1728,7 +1700,7 @@ namespace Server.Commands
html.Write(" <tr><td class=\"lentry\">0x{0:X4}</td><td class=\"rentry\">", entry.Index); html.Write(" <tr><td class=\"lentry\">0x{0:X4}</td><td class=\"rentry\">", entry.Index);
entry.Strings.Sort(); //( new EnglishPrioStringSorter() ); entry.Strings.Sort(); // ( new EnglishPrioStringSorter() );
for (int j = 0; j < entry.Strings.Count; ++j) for (int j = 0; j < entry.Strings.Count; ++j)
{ {
@ -1776,9 +1748,9 @@ namespace Server.Commands
Strings = new List<string>(); Strings = new List<string>();
} }
public int Index{ get; } public int Index { get; }
public List<string> Strings{ get; } public List<string> Strings { get; }
} }
private class SpeechEntrySorter : IComparer<SpeechEntry> private class SpeechEntrySorter : IComparer<SpeechEntry>
@ -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)
@ -1848,15 +1816,15 @@ namespace Server.Commands
Description = description; Description = description;
} }
public AccessLevel AccessLevel{ get; } public AccessLevel AccessLevel { get; }
public string Name{ get; } public string Name { get; }
public string[] Aliases{ get; } public string[] Aliases { get; }
public string Usage{ get; } public string Usage { get; }
public string Description{ get; } public string Description { get; }
} }
public class CommandEntrySorter : IComparer<DocCommandEntry> public class CommandEntrySorter : IComparer<DocCommandEntry>
@ -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;
@ -2381,7 +2335,7 @@ namespace Server.Commands
if (decInfo == null) if (decInfo == null)
typeHtml.Write(decType.Name); typeHtml.Write(decType.Name);
else else
//typeHtml.Write( "<a href=\"{0}\">{1}</a>", decInfo.m_FileName, decInfo.m_TypeName ); // typeHtml.Write( "<a href=\"{0}\">{1}</a>", decInfo.m_FileName, decInfo.m_TypeName );
typeHtml.Write(decInfo.LinkName(null)); typeHtml.Write(decInfo.LinkName(null));
typeHtml.Write(") - "); typeHtml.Write(") - ");
@ -2452,7 +2406,7 @@ namespace Server.Commands
if (i != 0) if (i != 0)
typeHtml.Write(", "); typeHtml.Write(", ");
//typeHtml.Write( "<a href=\"{0}\">{1}</a>", derivedInfo.m_FileName, derivedInfo.m_TypeName ); // typeHtml.Write( "<a href=\"{0}\">{1}</a>", derivedInfo.m_FileName, derivedInfo.m_TypeName );
typeHtml.Write($"<!-- DBG-3 -->{derivedInfo.LinkName(null)}"); typeHtml.Write($"<!-- DBG-3 -->{derivedInfo.LinkName(null)}");
} }
@ -2474,7 +2428,7 @@ namespace Server.Commands
if (i != 0) if (i != 0)
typeHtml.Write(", "); typeHtml.Write(", ");
//typeHtml.Write( "<a href=\"{0}\">{1}</a>", nestedInfo.m_FileName, nestedInfo.m_TypeName ); // typeHtml.Write( "<a href=\"{0}\">{1}</a>", nestedInfo.m_FileName, nestedInfo.m_TypeName );
typeHtml.Write($"<!-- DBG-4 -->{nestedInfo.LinkName(null)}"); typeHtml.Write($"<!-- DBG-4 -->{nestedInfo.LinkName(null)}");
} }
@ -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,
@ -2625,11 +2575,11 @@ namespace Server.Commands
Name = name; Name = name;
} }
public Body Body{ get; } public Body Body { get; }
public ModelBodyType BodyType{ get; } public ModelBodyType BodyType { get; }
public string Name{ get; } public string Name { get; }
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
@ -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
{ {
@ -48,14 +48,14 @@ namespace Server.Commands
} }
catch catch
{ {
//Console.WriteLine( "Denied" ); // Console.WriteLine( "Denied" );
} }
} }
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)
@ -103,7 +103,7 @@ namespace Server.Commands
for (int i = 0; i < m_Amount; i++) for (int i = 0; i < m_Amount; i++)
if (c.Invoke(args) is Item newItem) if (c.Invoke(args) is Item newItem)
{ {
CopyProperties(newItem, copy); //copy.Dupe( item, copy.Amount ); CopyProperties(newItem, copy); // copy.Dupe( item, copy.Amount );
copy.OnAfterDuped(newItem); copy.OnAfterDuped(newItem);
newItem.Parent = null; newItem.Parent = null;

View file

@ -76,4 +76,4 @@ WEIGHT 25500
OWNER -1 OWNER -1
SPAWN -1 SPAWN -1
VALUE 1 VALUE 1
}*/ }*/

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
{ {
@ -275,9 +275,9 @@ namespace Server.Commands
Object = ActivatorUtil.CreateInstance(type); Object = ActivatorUtil.CreateInstance(type);
} }
public Type Type{ get; } public Type Type { get; }
public object Object{ get; } public object Object { get; }
} }
public class CategoryEntry public class CategoryEntry
@ -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>();
} }
@ -342,15 +342,15 @@ namespace Server.Commands
Matched = new List<CategoryTypeEntry>(); Matched = new List<CategoryTypeEntry>();
} }
public string Title{ get; } public string Title { get; }
public Type[] Matches{ get; } public Type[] Matches { get; }
public CategoryEntry Parent{ get; } public CategoryEntry Parent { get; }
public CategoryEntry[] SubCategories{ get; } public CategoryEntry[] SubCategories { get; }
public List<CategoryTypeEntry> Matched{ get; } public List<CategoryTypeEntry> Matched { get; }
public bool IsMatch(Type type) public bool IsMatch(Type type)
{ {
@ -380,9 +380,9 @@ namespace Server.Commands
Text = input.Substring(index); Text = input.Substring(index);
} }
public int Indentation{ get; } public int Indentation { get; }
public string Text{ get; } public string Text { get; }
public static CategoryLine[] Load(string path) public static CategoryLine[] Load(string path)
{ {

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,22 +12,22 @@ 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; }
public string[] Commands{ get; set; } public string[] Commands { get; set; }
public string Usage{ get; set; } public string Usage { get; set; }
public string Description{ get; set; } public string Description { get; set; }
public AccessLevel AccessLevel{ get; set; } public AccessLevel AccessLevel { get; set; }
public ObjectTypes ObjectTypes{ get; set; } public ObjectTypes ObjectTypes { get; set; }
public CommandSupport Supports{ get; set; } public CommandSupport Supports { get; set; }
public static bool IsAccessible(Mobile from, object obj) public static bool IsAccessible(Mobile from, object obj)
{ {
@ -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

@ -14,7 +14,7 @@ namespace Server.Commands.Generic
{ {
public class TargetCommands public class TargetCommands
{ {
public static List<BaseCommand> AllCommands{ get; } = new List<BaseCommand>(); public static List<BaseCommand> AllCommands { get; } = new List<BaseCommand>();
public static void Initialize() public static void Initialize()
{ {
@ -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)
{ {
@ -511,7 +511,7 @@ namespace Server.Commands.Generic
SpellHelper.GetSurfaceTop(ref p); SpellHelper.GetSurfaceTop(ref p);
//CommandLogging.WriteLine( from, "{0} {1} teleporting to {2}", from.AccessLevel, CommandLogging.Format( from ), new Point3D( p ) ); // CommandLogging.WriteLine( from, "{0} {1} teleporting to {2}", from.AccessLevel, CommandLogging.Format( from ), new Point3D( p ) );
Point3D fromLoc = from.Location; Point3D fromLoc = from.Location;
Point3D toLoc = new Point3D(p); Point3D toLoc = new Point3D(p);
@ -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)
@ -107,39 +105,35 @@ namespace Server.Commands.Generic
switch (result) switch (result)
{ {
case DesignInsertResult.Valid: case DesignInsertResult.Valid:
{ {
if (m_Foundations.Count == 0) if (m_Foundations.Count == 0)
from.SendMessage( from.SendMessage(
"The item has been inserted into the house design. Press ESC when you are finished."); "The item has been inserted into the house design. Press ESC when you are finished.");
else else
from.SendMessage("The item has been inserted into the house design."); from.SendMessage("The item has been inserted into the house design.");
if (!m_Foundations.Contains(house)) if (!m_Foundations.Contains(house))
m_Foundations.Add(house); m_Foundations.Add(house);
break; break;
} }
case DesignInsertResult.InvalidItem: case DesignInsertResult.InvalidItem:
{ {
from.SendMessage("That cannot be inserted. Try again."); from.SendMessage("That cannot be inserted. Try again.");
break; break;
} }
case DesignInsertResult.NotInHouse: case DesignInsertResult.NotInHouse:
case DesignInsertResult.OutsideHouseBounds: case DesignInsertResult.OutsideHouseBounds:
{ {
from.SendMessage("That item is not inside a customizable house. Try again."); from.SendMessage("That item is not inside a customizable house. Try again.");
break; break;
} }
} }
from.Target = new DesignInsertTarget(m_Foundations, m_StaticsOnly); from.Target = new DesignInsertTarget(m_Foundations, m_StaticsOnly);
} }
} }
#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;
@ -165,25 +159,25 @@ namespace Server.Commands.Generic
switch (result) switch (result)
{ {
case DesignInsertResult.Valid: case DesignInsertResult.Valid:
{ {
AddResponse("The item has been inserted into the house design."); AddResponse("The item has been inserted into the house design.");
if (!foundations.Contains(house)) if (!foundations.Contains(house))
foundations.Add(house); foundations.Add(house);
break; break;
} }
case DesignInsertResult.InvalidItem: case DesignInsertResult.InvalidItem:
{ {
LogFailure("That cannot be inserted."); LogFailure("That cannot be inserted.");
break; break;
} }
case DesignInsertResult.NotInHouse: case DesignInsertResult.NotInHouse:
case DesignInsertResult.OutsideHouseBounds: case DesignInsertResult.OutsideHouseBounds:
{ {
LogFailure("That item is not inside a customizable house."); LogFailure("That item is not inside a customizable house.");
break; break;
} }
} }
} }
@ -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)
{ {
@ -197,57 +196,57 @@ namespace Server.Commands.Generic
switch (info.ButtonID) switch (info.ButtonID)
{ {
case 1: case 1:
{
if (m_Page > 0)
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page - 1, m_Select));
break;
}
case 2:
{
if ((m_Page + 1) * EntriesPerPage < m_List.Count)
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page + 1, m_Select));
break;
}
default:
{
int v = info.ButtonID - 3;
if (v >= 0 && v < m_List.Count)
{ {
object obj = m_List[v]; if (m_Page > 0)
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page - 1, m_Select));
if (!BaseCommand.IsAccessible(m_From, obj)) break;
}
case 2:
{
if ((m_Page + 1) * EntriesPerPage < m_List.Count)
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page + 1, m_Select));
break;
}
default:
{
int v = info.ButtonID - 3;
if (v >= 0 && v < m_List.Count)
{ {
m_From.SendLocalizedMessage(500447); // That is not accessible. object obj = m_List[v];
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select));
break; if (!BaseCommand.IsAccessible(m_From, obj))
{
m_From.SendLocalizedMessage(500447); // That is not accessible.
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select));
break;
}
if (obj is Item item && !item.Deleted)
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, item));
else if (obj is Mobile mobile && !mobile.Deleted)
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, mobile));
else
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select));
} }
if (obj is Item item && !item.Deleted) break;
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, item));
else if (obj is Mobile mobile && !mobile.Deleted)
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, mobile));
else
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select));
} }
break;
}
} }
} }
} }
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)
{ {
@ -318,71 +317,71 @@ namespace Server.Commands.Generic
{ {
case 0: case 0:
case 1: case 1:
{ {
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item)); m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
break; break;
} }
case 2: // Properties case 2: // Properties
{
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
m_From.SendGump(new PropertiesGump(m_From, m_Item));
break;
}
case 3: // Delete
{
CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel,
CommandLogging.Format(m_From), CommandLogging.Format(m_Item));
m_Item.Delete();
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
break;
}
case 4: // Go there
{
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
InvokeCommand($"Go {m_Item.Serial.Value}");
break;
}
case 5: // Move to target
{
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
m_From.Target = new MoveTarget(m_Item);
break;
}
case 6: // Bring to pack
{
Mobile owner = m_Item.RootParent as Mobile;
if (owner?.Map != null && owner.Map != Map.Internal &&
!BaseCommand.IsAccessible(m_From, owner) /* !m_From.CanSee( owner )*/)
{
m_From.SendMessage("You can not get what you can not see.");
}
else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden &&
owner.AccessLevel >= m_From.AccessLevel)
{
m_From.SendMessage("You can not get what you can not see.");
}
else
{ {
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item)); m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
m_From.AddToBackpack(m_Item); m_From.SendGump(new PropertiesGump(m_From, m_Item));
break;
} }
case 3: // Delete
{
CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel,
CommandLogging.Format(m_From), CommandLogging.Format(m_Item));
m_Item.Delete();
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
break;
}
case 4: // Go there
{
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
InvokeCommand($"Go {m_Item.Serial.Value}");
break;
}
case 5: // Move to target
{
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
m_From.Target = new MoveTarget(m_Item);
break;
}
case 6: // Bring to pack
{
Mobile owner = m_Item.RootParent as Mobile;
break; if (owner?.Map != null && owner.Map != Map.Internal &&
} !BaseCommand.IsAccessible(m_From, owner) /* !m_From.CanSee( owner )*/)
{
m_From.SendMessage("You can not get what you can not see.");
}
else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden &&
owner.AccessLevel >= m_From.AccessLevel)
{
m_From.SendMessage("You can not get what you can not see.");
}
else
{
m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, m_List, m_Page, m_Item));
m_From.AddToBackpack(m_Item);
}
break;
}
} }
} }
} }
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)
@ -482,86 +481,86 @@ namespace Server.Commands.Generic
{ {
case 0: case 0:
case 1: case 1:
{
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
break;
}
case 2: // Properties
{
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
m_From.SendGump(new PropertiesGump(m_From, m_Mobile));
break;
}
case 3: // Delete
{
if (!m_Mobile.Player)
{ {
CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel,
CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile));
m_Mobile.Delete();
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
break;
} }
case 2: // Properties
break;
}
case 4: // Go there
{
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
InvokeCommand($"Go {m_Mobile.Serial.Value}");
break;
}
case 5: // Bring them here
{
if (m_From.Map == null || m_From.Map == Map.Internal)
{
m_From.SendMessage("You cannot bring that person here.");
}
else
{ {
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
m_Mobile.MoveToWorld(m_From.Location, m_From.Map); m_From.SendGump(new PropertiesGump(m_From, m_Mobile));
break;
} }
case 3: // Delete
break;
}
case 6: // Move to target
{
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
m_From.Target = new MoveTarget(m_Mobile);
break;
}
case 7: // Kill
{
if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
m_Mobile.Kill();
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
break;
}
case 8: // Res
{
if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
{ {
m_Mobile.PlaySound(0x214); if (!m_Mobile.Player)
m_Mobile.FixedEffect(0x376A, 10, 16); {
CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel,
CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile));
m_Mobile.Delete();
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
}
m_Mobile.Resurrect(); break;
} }
case 4: // Go there
{
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
InvokeCommand($"Go {m_Mobile.Serial.Value}");
break;
}
case 5: // Bring them here
{
if (m_From.Map == null || m_From.Map == Map.Internal)
{
m_From.SendMessage("You cannot bring that person here.");
}
else
{
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
m_Mobile.MoveToWorld(m_From.Location, m_From.Map);
}
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); break;
}
case 6: // Move to target
{
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
m_From.Target = new MoveTarget(m_Mobile);
break;
}
case 7: // Kill
{
if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
m_Mobile.Kill();
break; m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
}
break;
}
case 8: // Res
{
if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
{
m_Mobile.PlaySound(0x214);
m_Mobile.FixedEffect(0x376A, 10, 16);
m_Mobile.Resurrect();
}
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
break;
}
case 9: // Client case 9: // Client
{ {
m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile)); m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
if (m_Mobile.NetState != null) if (m_Mobile.NetState != null)
m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState)); m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState));
break; break;
} }
} }
} }
} }

View file

@ -17,18 +17,18 @@ namespace Server.Commands.Generic
Constructor = constructor; Constructor = constructor;
} }
public static Dictionary<string, ExtensionInfo> Table{ get; } = public static Dictionary<string, ExtensionInfo> Table { get; } =
new Dictionary<string, ExtensionInfo>(StringComparer.InvariantCultureIgnoreCase); new Dictionary<string, ExtensionInfo>(StringComparer.InvariantCultureIgnoreCase);
public int Order{ get; } public int Order { get; }
public string Name{ get; } public string Name { get; }
public int Size{ get; } public int Size { get; }
public bool IsFixedSize => Size >= 0; public bool IsFixedSize => Size >= 0;
public ExtensionConstructor Constructor{ get; } public ExtensionConstructor Constructor { get; }
public static void Register(ExtensionInfo ext) public static void Register(ExtensionInfo ext)
{ {
@ -103,7 +103,7 @@ namespace Server.Commands.Generic
public abstract class BaseExtension public abstract class BaseExtension
{ {
public abstract ExtensionInfo Info{ get; } public abstract ExtensionInfo Info { get; }
public string Name => Info.Name; public string Name => Info.Name;

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
{ {
@ -47,11 +47,11 @@ namespace Server.Commands.Generic
Value = value; Value = value;
} }
public Type Type{ get; } public Type Type { get; }
public object Value{ get; private set; } public object Value { get; private set; }
public FieldInfo Field{ get; private set; } public FieldInfo Field { get; private set; }
public bool HasField => Field != null; public bool HasField => Field != null;
@ -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,15 +135,9 @@ 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,15 +213,9 @@ 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();
return (IComparer<T>)ActivatorUtil.CreateInstance(comparerType); return (IComparer<T>)ActivatorUtil.CreateInstance(comparerType);

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
{ {
@ -17,7 +17,7 @@ namespace Server.Commands.Generic
IsAscending = isAscending; IsAscending = isAscending;
} }
public Property Property{ get; set; } public Property Property { get; set; }
public bool IsAscending public bool IsAscending
{ {
@ -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,15 +139,9 @@ 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
public override ExtensionInfo Info => ExtInfo; public override ExtensionInfo Info => ExtInfo;
public int Limit{ get; private set; } public int Limit { get; private set; }
public static void Initialize() public static void Initialize()
{ {

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

@ -8,7 +8,7 @@ namespace Server.Commands.Generic
public override ExtensionInfo Info => ExtInfo; public override ExtensionInfo Info => ExtInfo;
public ObjectConditional Conditional{ get; private set; } public ObjectConditional Conditional { get; private set; }
public static void Initialize() public static void Initialize()
{ {

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
{ {
@ -19,7 +18,7 @@ namespace Server.Commands.Generic
Instance = this; Instance = this;
} }
public static AreaCommandImplementor Instance{ get; private set; } public static AreaCommandImplementor Instance { get; private set; }
public override void Process(Mobile from, BaseCommand command, string[] args) public override void Process(Mobile from, BaseCommand command, string[] args)
{ {
@ -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

@ -32,19 +32,19 @@ namespace Server.Commands.Generic
public BaseCommandImplementor() => Commands = new Dictionary<string, BaseCommand>(StringComparer.OrdinalIgnoreCase); public BaseCommandImplementor() => Commands = new Dictionary<string, BaseCommand>(StringComparer.OrdinalIgnoreCase);
public bool SupportsConditionals{ get; set; } public bool SupportsConditionals { get; set; }
public string[] Accessors{ get; set; } public string[] Accessors { get; set; }
public string Usage{ get; set; } public string Usage { get; set; }
public string Description{ get; set; } public string Description { get; set; }
public AccessLevel AccessLevel{ get; set; } public AccessLevel AccessLevel { get; set; }
public CommandSupport SupportRequirement{ get; set; } public CommandSupport SupportRequirement { get; set; }
public Dictionary<string, BaseCommand> Commands{ get; } public Dictionary<string, BaseCommand> Commands { get; }
public static List<BaseCommandImplementor> Implementors public static List<BaseCommandImplementor> Implementors
{ {
@ -110,43 +110,43 @@ namespace Server.Commands.Generic
{ {
case ObjectTypes.All: case ObjectTypes.All:
case ObjectTypes.Both: case ObjectTypes.Both:
{ {
if (condIsItem) if (condIsItem)
items = true; items = true;
if (condIsMobile) if (condIsMobile)
mobiles = true; mobiles = true;
break; break;
} }
case ObjectTypes.Items: case ObjectTypes.Items:
{
if (condIsItem)
{ {
items = true; if (condIsItem)
} {
else if (condIsMobile) items = true;
{ }
from.SendMessage("You may not use a mobile type condition for this command."); else if (condIsMobile)
return false; {
} from.SendMessage("You may not use a mobile type condition for this command.");
return false;
}
break; break;
} }
case ObjectTypes.Mobiles: case ObjectTypes.Mobiles:
{
if (condIsMobile)
{ {
mobiles = true; if (condIsMobile)
} {
else if (condIsItem) mobiles = true;
{ }
from.SendMessage("You may not use an item type condition for this command."); else if (condIsItem)
return false; {
} from.SendMessage("You may not use an item type condition for this command.");
return false;
}
break; break;
} }
} }
return true; return true;
@ -199,8 +199,8 @@ namespace Server.Commands.Generic
public void RunCommand(Mobile from, object obj, BaseCommand command, string[] args) public void RunCommand(Mobile from, object obj, BaseCommand command, string[] args)
{ {
// try // try
// { // {
CommandEventArgs e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args); CommandEventArgs e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args);
if (!command.ValidateArgs(this, e)) if (!command.ValidateArgs(this, e))
@ -226,17 +226,17 @@ namespace Server.Commands.Generic
else if (obj != null) else if (obj != null)
{ {
if (command.ListOptimized) if (command.ListOptimized)
command.ExecuteList(e, new List<object>{ obj }); command.ExecuteList(e, new List<object> { obj });
else else
command.Execute(e, obj); command.Execute(e, obj);
} }
command.Flush(from, flushToLog); command.Flush(from, flushToLog);
// } // }
// catch ( Exception ex ) // catch ( Exception ex )
// { // {
// from.SendMessage( ex.Message ); // from.SendMessage( ex.Message );
// } // }
} }
public virtual void Process(Mobile from, BaseCommand command, string[] args) public virtual void Process(Mobile from, BaseCommand command, string[] args)

View file

@ -40,7 +40,7 @@ namespace Server.Commands.Generic
from.SendMessage("That is not a container."); from.SendMessage("That is not a container.");
return; return;
} }
try try
{ {
Extensions ext = Extensions.Parse(from, ref args); Extensions ext = Extensions.Parse(from, ref args);

View file

@ -33,35 +33,35 @@ namespace Server.Commands.Generic
switch (command.ObjectTypes) switch (command.ObjectTypes)
{ {
case ObjectTypes.Both: case ObjectTypes.Both:
{
if (!(targeted is Item || targeted is Mobile))
{ {
from.SendMessage("This command does not work on that."); if (!(targeted is Item || targeted is Mobile))
return; {
} from.SendMessage("This command does not work on that.");
return;
}
break; break;
} }
case ObjectTypes.Items: case ObjectTypes.Items:
{
if (!(targeted is Item))
{ {
from.SendMessage("This command only works on items."); if (!(targeted is Item))
return; {
} from.SendMessage("This command only works on items.");
return;
}
break; break;
} }
case ObjectTypes.Mobiles: case ObjectTypes.Mobiles:
{
if (!(targeted is Mobile))
{ {
from.SendMessage("This command only works on mobiles."); if (!(targeted is Mobile))
return; {
} from.SendMessage("This command only works on mobiles.");
return;
}
break; break;
} }
} }
RunCommand(from, targeted, command, args); RunCommand(from, targeted, command, args);

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)
{ {
@ -20,7 +20,7 @@ namespace Server.Commands.Generic
m_Conditions = conditions; m_Conditions = conditions;
} }
public Type Type{ get; } public Type Type { get; }
public bool IsItem => Type == null || Type == typeofItem || Type.IsSubclassOf(typeofItem); public bool IsItem => Type == null || Type == typeofItem || Type.IsSubclassOf(typeofItem);

View file

@ -15,7 +15,7 @@ namespace Server.Commands.Generic
Instance = this; Instance = this;
} }
public static RangeCommandImplementor Instance{ get; private set; } public static RangeCommandImplementor Instance { get; private set; }
public override void Execute(CommandEventArgs e) public override void Execute(CommandEventArgs e)
{ {

View file

@ -46,25 +46,25 @@ namespace Server.Commands.Generic
switch (command.ObjectTypes) switch (command.ObjectTypes)
{ {
case ObjectTypes.Items: case ObjectTypes.Items:
{
if (!(obj is Item))
{ {
e.Mobile.SendMessage("This command only works on items."); if (!(obj is Item))
return; {
} e.Mobile.SendMessage("This command only works on items.");
return;
}
break; break;
} }
case ObjectTypes.Mobiles: case ObjectTypes.Mobiles:
{
if (!(obj is Mobile))
{ {
e.Mobile.SendMessage("This command only works on mobiles."); if (!(obj is Mobile))
return; {
} e.Mobile.SendMessage("This command only works on mobiles.");
return;
}
break; break;
} }
} }
string[] oldArgs = e.Arguments; string[] oldArgs = e.Arguments;

View file

@ -52,35 +52,35 @@ namespace Server.Commands.Generic
switch (command.ObjectTypes) switch (command.ObjectTypes)
{ {
case ObjectTypes.Both: case ObjectTypes.Both:
{
if (!(targeted is Item) && !(targeted is Mobile))
{ {
from.SendMessage("This command does not work on that."); if (!(targeted is Item) && !(targeted is Mobile))
return; {
} from.SendMessage("This command does not work on that.");
return;
}
break; break;
} }
case ObjectTypes.Items: case ObjectTypes.Items:
{
if (!(targeted is Item))
{ {
from.SendMessage("This command only works on items."); if (!(targeted is Item))
return; {
} from.SendMessage("This command only works on items.");
return;
}
break; break;
} }
case ObjectTypes.Mobiles: case ObjectTypes.Mobiles:
{
if (!(targeted is Mobile))
{ {
from.SendMessage("This command only works on mobiles."); if (!(targeted is Mobile))
return; {
} from.SendMessage("This command only works on mobiles.");
return;
}
break; break;
} }
} }
RunCommand(from, targeted, command, args); RunCommand(from, targeted, command, args);

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

@ -11,9 +11,9 @@ namespace Server.Commands
{ {
public class HelpInfo public class HelpInfo
{ {
public static Dictionary<string, CommandInfo> HelpInfos{ get; } = new Dictionary<string, CommandInfo>(); public static Dictionary<string, CommandInfo> HelpInfos { get; } = new Dictionary<string, CommandInfo>();
public static List<CommandInfo> SortedHelpInfo{ get; private set; } = new List<CommandInfo>(); public static List<CommandInfo> SortedHelpInfo { get; private set; } = new List<CommandInfo>();
[CallPriority(100)] [CallPriority(100)]
public static void Initialize() public static void Initialize()
@ -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)
@ -290,51 +289,50 @@ namespace Server.Commands
switch (info.ButtonID) switch (info.ButtonID)
{ {
case 0: case 0:
{
m.CloseGump<CommandInfoGump>();
break;
}
case 1:
{
if (m_Page > 0)
m.SendGump(new CommandListGump(m_Page - 1, m, m_List));
break;
}
case 2:
{
if ((m_Page + 1) * EntriesPerPage < SortedHelpInfo.Count)
m.SendGump(new CommandListGump(m_Page + 1, m, m_List));
break;
}
default:
{
int v = info.ButtonID - 3;
if (v >= 0 && v < m_List.Count)
{ {
CommandInfo c = m_List[v]; m.CloseGump<CommandInfoGump>();
break;
if (m.AccessLevel >= c.AccessLevel)
{
m.SendGump(new CommandInfoGump(c));
m.SendGump(new CommandListGump(m_Page, m, m_List));
}
else
{
m.SendMessage("You no longer have access to that command.");
m.SendGump(new CommandListGump(m_Page, m, null));
}
} }
case 1:
{
if (m_Page > 0)
m.SendGump(new CommandListGump(m_Page - 1, m, m_List));
break; break;
} }
case 2:
{
if ((m_Page + 1) * EntriesPerPage < SortedHelpInfo.Count)
m.SendGump(new CommandListGump(m_Page + 1, m, m_List));
break;
}
default:
{
int v = info.ButtonID - 3;
if (v >= 0 && v < m_List.Count)
{
CommandInfo c = m_List[v];
if (m.AccessLevel >= c.AccessLevel)
{
m.SendGump(new CommandInfoGump(c));
m.SendGump(new CommandListGump(m_Page, m, m_List));
}
else
{
m.SendMessage("You no longer have access to that command.");
m.SendGump(new CommandListGump(m_Page, m, null));
}
}
break;
}
} }
} }
} }
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)
@ -344,13 +342,13 @@ namespace Server.Commands
AddBackground(0, 0, width, height, 5054); AddBackground(0, 0, width, height, 5054);
//AddImageTiled( 10, 10, width - 20, 20, 2624 ); // AddImageTiled( 10, 10, width - 20, 20, 2624 );
//AddAlphaRegion( 10, 10, width - 20, 20 ); // AddAlphaRegion( 10, 10, width - 20, 20 );
//AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false ); // AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false );
AddHtml(10, 10, width - 20, 20, Color(Center(info.Name), 0xFF0000)); AddHtml(10, 10, width - 20, 20, Color(Center(info.Name), 0xFF0000));
//AddImageTiled( 10, 40, width - 20, height - 80, 2624 ); // AddImageTiled( 10, 40, width - 20, height - 80, 2624 );
//AddAlphaRegion( 10, 40, width - 20, height - 80 ); // AddAlphaRegion( 10, 40, width - 20, height - 80 );
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -384,8 +382,8 @@ namespace Server.Commands
AddHtml(10, 40, width - 20, height - 80, sb.ToString(), false, true); AddHtml(10, 40, width - 20, height - 80, sb.ToString(), false, true);
//AddImageTiled( 10, height - 30, width - 20, 20, 2624 ); // AddImageTiled( 10, height - 30, width - 20, 20, 2624 );
//AddAlphaRegion( 10, height - 30, width - 20, 20 ); // AddAlphaRegion( 10, height - 30, width - 20, 20 );
} }
public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>"; public string Color(string text, int color) => $"<BASEFONT COLOR=#{color:X6}>{text}</BASEFONT>";

View file

@ -1,14 +1,14 @@
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
{ {
public class LocationCommand : BaseCommand public class LocationCommand : BaseCommand
{ {
private static readonly List<int> m_DefaultGraphics = new List<int>{ 0x17AF, 0x17B0, 0x17B1, 0x17B2 }; private static readonly List<int> m_DefaultGraphics = new List<int> { 0x17AF, 0x17B0, 0x17B1, 0x17B2 };
public LocationCommand() public LocationCommand()
{ {

View file

@ -7,10 +7,10 @@ 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; }
public static void Initialize() public static void Initialize()
{ {

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()
{ {
@ -168,10 +168,10 @@ namespace Server.Commands
if ((flags & ExpandFlag.Blessed) != 0) if ((flags & ExpandFlag.Blessed) != 0)
++countTable[4]; ++countTable[4];
/*if ( ( flags & ExpandFlag.TempFlag ) != 0 ) /*if (( flags & ExpandFlag.TempFlag ) != 0)
++countTable[5]; ++countTable[5];
if ( ( flags & ExpandFlag.SaveFlag ) != 0 ) if (( flags & ExpandFlag.SaveFlag ) != 0)
++countTable[6];*/ ++countTable[6];*/
if ((flags & ExpandFlag.Weight) != 0) if ((flags & ExpandFlag.Weight) != 0)
@ -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),
@ -602,8 +602,8 @@ namespace Server
{ {
} }
public AccessLevel PlayerAccess{ get; set; } public AccessLevel PlayerAccess { get; set; }
public AccessLevel NeededAccess{ get; set; } public AccessLevel NeededAccess { get; set; }
} }
public sealed class ReadAccessException : ClearanceException public sealed class ReadAccessException : ClearanceException
@ -630,11 +630,11 @@ namespace Server
public Property(PropertyInfo[] chain) => m_Chain = chain; public Property(PropertyInfo[] chain) => m_Chain = chain;
public string Binding{ get; } public string Binding { get; }
public bool IsBound => m_Chain != null; public bool IsBound => m_Chain != null;
public PropertyAccess Access{ get; private set; } public PropertyAccess Access { get; private set; }
public PropertyInfo[] Chain public PropertyInfo[] Chain
{ {

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;
@ -45,7 +45,7 @@ namespace Server
CommandSystem.Register("UnfreezeWorld", AccessLevel.Administrator, UnfreezeWorld_OnCommand); CommandSystem.Register("UnfreezeWorld", AccessLevel.Administrator, UnfreezeWorld_OnCommand);
} }
public delegate void FreezeCallback( Mobile from, bool okay, StateInfo si ); public delegate void FreezeCallback(Mobile from, bool okay, StateInfo si);
[Usage("Freeze")] [Usage("Freeze")]
[Description("Makes a targeted area of dynamic items static.")] [Description("Makes a targeted area of dynamic items static.")]
@ -361,79 +361,79 @@ namespace Server
BinaryWriter mulWriter = new BinaryWriter(mulStream); BinaryWriter mulWriter = new BinaryWriter(mulStream);
for (int x = xStartBlock; x <= xEndBlock; ++x) for (int x = xStartBlock; x <= xEndBlock; ++x)
for (int y = yStartBlock; y <= yEndBlock; ++y) for (int y = yStartBlock; y <= yEndBlock; ++y)
{
StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, x, y, matrix.BlockWidth,
matrix.BlockHeight, out int oldTileCount);
if (oldTileCount < 0)
continue;
int newTileCount = 0;
StaticTile[] newTiles = new StaticTile[oldTileCount];
int baseX = (x << 3) - xTileStart, baseY = (y << 3) - yTileStart;
for (int i = 0; i < oldTileCount; ++i)
{ {
StaticTile oldTile = oldTiles[i]; StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, x, y, matrix.BlockWidth,
matrix.BlockHeight, out int oldTileCount);
int px = baseX + oldTile.X; if (oldTileCount < 0)
int py = baseY + oldTile.Y; continue;
if (px < 0 || px >= xTileWidth || py < 0 || py >= yTileHeight) int newTileCount = 0;
StaticTile[] newTiles = new StaticTile[oldTileCount];
int baseX = (x << 3) - xTileStart, baseY = (y << 3) - yTileStart;
for (int i = 0; i < oldTileCount; ++i)
{ {
newTiles[newTileCount++] = oldTile; StaticTile oldTile = oldTiles[i];
int px = baseX + oldTile.X;
int py = baseY + oldTile.Y;
if (px < 0 || px >= xTileWidth || py < 0 || py >= yTileHeight)
{
newTiles[newTileCount++] = oldTile;
}
else
{
++totalUnfrozen;
Item item = new Static(oldTile.ID);
item.Hue = oldTile.Hue;
item.MoveToWorld(new Point3D(px + xTileStart, py + yTileStart, oldTile.Z), map);
}
} }
else
int mulPos = -1;
int length = -1;
int extra = 0;
if (newTileCount > 0)
{ {
++totalUnfrozen; mulWriter.Seek(0, SeekOrigin.End);
Item item = new Static(oldTile.ID); mulPos = (int)mulWriter.BaseStream.Position;
length = newTileCount * 7;
extra = 1;
item.Hue = oldTile.Hue; for (int i = 0; i < newTileCount; ++i)
{
StaticTile toWrite = newTiles[i];
item.MoveToWorld(new Point3D(px + xTileStart, py + yTileStart, oldTile.Z), map); mulWriter.Write((ushort)toWrite.ID);
mulWriter.Write((byte)toWrite.X);
mulWriter.Write((byte)toWrite.Y);
mulWriter.Write((sbyte)toWrite.Z);
mulWriter.Write((short)toWrite.Hue);
}
mulWriter.Flush();
} }
int idxPos = (x * matrix.BlockHeight + y) * 12;
idxWriter.Seek(idxPos, SeekOrigin.Begin);
idxWriter.Write(mulPos);
idxWriter.Write(length);
idxWriter.Write(extra);
idxWriter.Flush();
matrix.SetStaticBlock(x, y, null);
} }
int mulPos = -1;
int length = -1;
int extra = 0;
if (newTileCount > 0)
{
mulWriter.Seek(0, SeekOrigin.End);
mulPos = (int)mulWriter.BaseStream.Position;
length = newTileCount * 7;
extra = 1;
for (int i = 0; i < newTileCount; ++i)
{
StaticTile toWrite = newTiles[i];
mulWriter.Write((ushort)toWrite.ID);
mulWriter.Write((byte)toWrite.X);
mulWriter.Write((byte)toWrite.Y);
mulWriter.Write((sbyte)toWrite.Z);
mulWriter.Write((short)toWrite.Hue);
}
mulWriter.Flush();
}
int idxPos = (x * matrix.BlockHeight + y) * 12;
idxWriter.Seek(idxPos, SeekOrigin.Begin);
idxWriter.Write(mulPos);
idxWriter.Write(length);
idxWriter.Write(extra);
idxWriter.Flush();
matrix.SetStaticBlock(x, y, null);
}
} }
public static void DoUnfreeze(Map map, ref bool badDataFile, ref int totalUnfrozen) public static void DoUnfreeze(Map map, ref bool badDataFile, ref int totalUnfrozen)
@ -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,9 +72,9 @@ 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);
foreach (IEntity obj in eable) foreach (IEntity obj in eable)

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;
@ -15,7 +15,7 @@ namespace Server.Engines.BulkOrders
if (!(targeted is Item item && item.IsChildOf(from.Backpack))) if (!(targeted is Item item && item.IsChildOf(from.Backpack)))
{ {
from.SendLocalizedMessage( 1045158 ); // You must have the item in your backpack to target it. from.SendLocalizedMessage(1045158); // You must have the item in your backpack to target it.
return; return;
} }

View file

@ -12,9 +12,9 @@ namespace Server.Engines.BulkOrders
{ {
double random = Utility.RandomDouble(); double random = Utility.RandomDouble();
for ( int i = 0; i < chances.Length; ++i ) for (int i = 0; i < chances.Length; ++i)
{ {
if ( random < chances[i] ) if (random < chances[i])
return i == 0 ? BulkMaterialType.None : start + (i - 1); return i == 0 ? BulkMaterialType.None : start + (i - 1);
random -= chances[i]; random -= chances[i];
@ -41,30 +41,30 @@ namespace Server.Engines.BulkOrders
{ {
} }
public abstract bool Complete{ get; } public abstract bool Complete { get; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public sealed override int Hue{ get; set; } public sealed override int Hue { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int AmountMax public int AmountMax
{ {
get => m_AmountMax; get => m_AmountMax;
set{ m_AmountMax = value; InvalidateProperties(); } set { m_AmountMax = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty(AccessLevel.GameMaster)]
public bool RequireExceptional public bool RequireExceptional
{ {
get => m_RequireExceptional; get => m_RequireExceptional;
set{ m_RequireExceptional = value; InvalidateProperties(); } set { m_RequireExceptional = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty(AccessLevel.GameMaster)]
public BulkMaterialType Material public BulkMaterialType Material
{ {
get => m_Material; get => m_Material;
set{ m_Material = value; InvalidateProperties(); } set { m_Material = value; InvalidateProperties(); }
} }
public abstract RewardGroup GetRewardGroup(); public abstract RewardGroup GetRewardGroup();
@ -118,35 +118,35 @@ namespace Server.Engines.BulkOrders
from.Target = new BODTarget(this); from.Target = new BODTarget(this);
} }
public override void Serialize(IGenericWriter writer ) public override void Serialize(IGenericWriter writer)
{ {
base.Serialize( writer ); base.Serialize(writer);
writer.WriteEncodedInt( 0 ); // version writer.WriteEncodedInt(0); // version
writer.Write( m_AmountMax ); writer.Write(m_AmountMax);
writer.Write( m_RequireExceptional ); writer.Write(m_RequireExceptional);
writer.Write( (int) m_Material ); writer.Write((int)m_Material);
} }
public override void Deserialize( IGenericReader reader ) public override void Deserialize(IGenericReader reader)
{ {
base.Deserialize( reader ); base.Deserialize(reader);
int version = reader.ReadEncodedInt(); int version = reader.ReadEncodedInt();
switch ( version ) switch (version)
{ {
case 0: case 0:
{ {
m_AmountMax = reader.ReadInt(); m_AmountMax = reader.ReadInt();
m_RequireExceptional = reader.ReadBool(); m_RequireExceptional = reader.ReadBool();
m_Material = (BulkMaterialType)reader.ReadInt(); m_Material = (BulkMaterialType)reader.ReadInt();
break; break;
} }
} }
if ( Parent == null && Map == Map.Internal && Location == Point3D.Zero ) if (Parent == null && Map == Map.Internal && Location == Point3D.Zero)
Delete(); Delete();
} }
} }

View file

@ -13,26 +13,26 @@ namespace Server.Engines.BulkOrders
switch (version) switch (version)
{ {
case 1: case 1:
{ {
Type = reader.ReadEncodedInt(); Type = reader.ReadEncodedInt();
Quality = reader.ReadEncodedInt(); Quality = reader.ReadEncodedInt();
Material = reader.ReadEncodedInt(); Material = reader.ReadEncodedInt();
Quantity = reader.ReadEncodedInt(); Quantity = reader.ReadEncodedInt();
break; break;
} }
} }
} }
public bool IsDefault => Type == 0 && Quality == 0 && Material == 0 && Quantity == 0; public bool IsDefault => Type == 0 && Quality == 0 && Material == 0 && Quantity == 0;
public int Type{ get; set; } public int Type { get; set; }
public int Quality{ get; set; } public int Quality { get; set; }
public int Material{ get; set; } public int Material { get; set; }
public int Quantity{ get; set; } public int Quantity { get; set; }
public void Clear() public void Clear()
{ {

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);
@ -150,70 +148,70 @@ namespace Server.Engines.BulkOrders
switch (index) switch (index)
{ {
case 0: // Apply case 0: // Apply
{
m_From.SendGump(new BOBGump(m_From, m_Book));
break;
}
case 1: // Set Book Filter
{
m_From.UseOwnFilter = false;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
case 2: // Set Your Filter
{
m_From.UseOwnFilter = true;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
case 3: // Clear Filter
{
f.Clear();
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
default:
{
index -= 4;
int type = index % 4;
index /= 4;
if (type >= 0 && type < m_Filters.Length)
{ {
int[,] filters = m_Filters[type]; m_From.SendGump(new BOBGump(m_From, m_Book));
if (index >= 0 && index < filters.GetLength(0)) break;
{
if (filters[index, 0] == 0)
break;
switch (type)
{
case 0:
f.Type = filters[index, 1];
break;
case 1:
f.Quality = filters[index, 1];
break;
case 2:
f.Material = filters[index, 1];
break;
case 3:
f.Quantity = filters[index, 1];
break;
}
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
}
} }
case 1: // Set Book Filter
{
m_From.UseOwnFilter = false;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break; break;
} }
case 2: // Set Your Filter
{
m_From.UseOwnFilter = true;
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
case 3: // Clear Filter
{
f.Clear();
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break;
}
default:
{
index -= 4;
int type = index % 4;
index /= 4;
if (type >= 0 && type < m_Filters.Length)
{
int[,] filters = m_Filters[type];
if (index >= 0 && index < filters.GetLength(0))
{
if (filters[index, 0] == 0)
break;
switch (type)
{
case 0:
f.Type = filters[index, 1];
break;
case 1:
f.Quality = filters[index, 1];
break;
case 2:
f.Material = filters[index, 1];
break;
case 3:
f.Quantity = filters[index, 1];
break;
}
m_From.SendGump(new BOBFilterGump(m_From, m_Book));
}
}
break;
}
} }
} }
} }

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,46 +391,45 @@ 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)
{ {
case BODType.Smith: case BODType.Smith:
{
switch (mat)
{ {
case BulkMaterialType.None: return 1062226; switch (mat)
case BulkMaterialType.DullCopper: return 1018332;
case BulkMaterialType.ShadowIron: return 1018333;
case BulkMaterialType.Copper: return 1018334;
case BulkMaterialType.Bronze: return 1018335;
case BulkMaterialType.Gold: return 1018336;
case BulkMaterialType.Agapite: return 1018337;
case BulkMaterialType.Verite: return 1018338;
case BulkMaterialType.Valorite: return 1018339;
}
break;
}
case BODType.Tailor:
{
switch (mat)
{
case BulkMaterialType.None:
{ {
if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes))) case BulkMaterialType.None: return 1062226;
return 1062235; case BulkMaterialType.DullCopper: return 1018332;
case BulkMaterialType.ShadowIron: return 1018333;
return 1044286; case BulkMaterialType.Copper: return 1018334;
case BulkMaterialType.Bronze: return 1018335;
case BulkMaterialType.Gold: return 1018336;
case BulkMaterialType.Agapite: return 1018337;
case BulkMaterialType.Verite: return 1018338;
case BulkMaterialType.Valorite: return 1018339;
} }
case BulkMaterialType.Spined: return 1062236;
case BulkMaterialType.Horned: return 1062237;
case BulkMaterialType.Barbed: return 1062238;
}
break; break;
} }
case BODType.Tailor:
{
switch (mat)
{
case BulkMaterialType.None:
{
if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)))
return 1062235;
return 1044286;
}
case BulkMaterialType.Spined: return 1062236;
case BulkMaterialType.Horned: return 1062237;
case BulkMaterialType.Barbed: return 1062238;
}
break;
}
} }
return "Invalid"; return "Invalid";
@ -443,148 +442,148 @@ namespace Server.Engines.BulkOrders
switch (index) switch (index)
{ {
case 0: // EXIT case 0: // EXIT
{ {
break; break;
} }
case 1: // Set Filter case 1: // Set Filter
{ {
m_From.SendGump(new BOBFilterGump(m_From, m_Book)); m_From.SendGump(new BOBFilterGump(m_From, m_Book));
break; break;
} }
case 2: // Previous page case 2: // Previous page
{ {
if (m_Page > 0) if (m_Page > 0)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List)); m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List));
return; return;
} }
case 3: // Next page case 3: // Next page
{ {
if (GetIndexForPage(m_Page + 1) < m_List.Count) if (GetIndexForPage(m_Page + 1) < m_List.Count)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List)); m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List));
break; break;
} }
case 4: // Price all case 4: // Price all
{
if (m_Book.IsChildOf(m_From.Backpack))
{ {
m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List); if (m_Book.IsChildOf(m_From.Backpack))
m_From.SendMessage("Type in a price for all deeds in the book:"); {
} m_From.Prompt = new SetPricePrompt(m_Book, null, m_Page, m_List);
m_From.SendMessage("Type in a price for all deeds in the book:");
}
break; break;
} }
default: default:
{
index -= 5;
int type = index % 2;
index /= 2;
if (index < 0 || index >= m_List.Count)
break;
IBOBEntry bobEntry = m_List[index];
if (!m_Book.Entries.Contains(bobEntry))
{ {
m_From.SendLocalizedMessage(1062382); // The deed selected is not available. index -= 5;
break;
}
if (type == 0) // Drop int type = index % 2;
{ index /= 2;
if (m_Book.IsChildOf(m_From.Backpack))
if (index < 0 || index >= m_List.Count)
break;
IBOBEntry bobEntry = m_List[index];
if (!m_Book.Entries.Contains(bobEntry))
{ {
Item item = bobEntry.Reconstruct(); m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
break;
Container pack = m_From.Backpack;
if (pack?.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight) != true)
{
m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
if (m_Book.IsChildOf(m_From.Backpack))
{
int sizeOfDroppedBod = bobEntry is BOBLargeEntry entry ? entry.Entries.Length : 1;
m_From.AddToBackpack(item);
m_From.SendLocalizedMessage(
1045152); // The bulk order deed has been placed in your backpack.
m_Book.Entries.Remove(bobEntry);
m_Book.InvalidateProperties();
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
}
}
} }
}
else // Set Price | Buy if (type == 0) // Drop
{
if (m_Book.IsChildOf(m_From.Backpack))
{ {
m_From.Prompt = new SetPricePrompt(m_Book, bobEntry, m_Page, m_List); if (m_Book.IsChildOf(m_From.Backpack))
m_From.SendLocalizedMessage(1062383); // Type in a price for the deed:
}
else if (m_Book.RootParent is PlayerVendor pv)
{
VendorItem vi = pv.GetVendorItem(m_Book);
if (vi?.IsForSale != false)
return;
int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
int price = bobEntry.Price;
if (price == 0)
{ {
m_From.SendLocalizedMessage(1062382); // The deed selected is not available. Item item = bobEntry.Reconstruct();
}
else Container pack = m_From.Backpack;
{ if (pack?.CheckHold(m_From, item, true, true, 0,
if (m_Book.Entries.Count > 0) item.PileWeight + item.TotalWeight) != true)
{ {
m_Page = GetPageForIndex(index, sizeOfDroppedBod); m_From.SendLocalizedMessage(503204); // You do not have room in your backpack for this
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price)); m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
} }
else else
{ {
m_From.SendLocalizedMessage(1062381); // The book is emptz if (m_Book.IsChildOf(m_From.Backpack))
{
int sizeOfDroppedBod = bobEntry is BOBLargeEntry entry ? entry.Entries.Length : 1;
m_From.AddToBackpack(item);
m_From.SendLocalizedMessage(
1045152); // The bulk order deed has been placed in your backpack.
m_Book.Entries.Remove(bobEntry);
m_Book.InvalidateProperties();
if (m_Book.Entries.Count / 5 < m_Book.ItemCount)
{
m_Book.ItemCount--;
m_Book.InvalidateItems();
}
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
}
} }
} }
} }
} else // Set Price | Buy
{
if (m_Book.IsChildOf(m_From.Backpack))
{
m_From.Prompt = new SetPricePrompt(m_Book, bobEntry, m_Page, m_List);
m_From.SendLocalizedMessage(1062383); // Type in a price for the deed:
}
else if (m_Book.RootParent is PlayerVendor pv)
{
VendorItem vi = pv.GetVendorItem(m_Book);
break; if (vi?.IsForSale != false)
} return;
int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
int price = bobEntry.Price;
if (price == 0)
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
}
else
{
if (m_Book.Entries.Count > 0)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is emptz
}
}
}
}
break;
}
} }
} }
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

@ -1,6 +1,6 @@
namespace Server.Engines.BulkOrders namespace Server.Engines.BulkOrders
{ {
public class BOBLargeEntry: IBOBEntry public class BOBLargeEntry : IBOBEntry
{ {
public BOBLargeEntry(LargeBOD bod) public BOBLargeEntry(LargeBOD bod)
{ {
@ -27,36 +27,36 @@ namespace Server.Engines.BulkOrders
switch (version) switch (version)
{ {
case 0: case 0:
{ {
RequireExceptional = reader.ReadBool(); RequireExceptional = reader.ReadBool();
DeedType = (BODType)reader.ReadEncodedInt(); DeedType = (BODType)reader.ReadEncodedInt();
Material = (BulkMaterialType)reader.ReadEncodedInt(); Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt(); AmountMax = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt(); Price = reader.ReadEncodedInt();
Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()]; Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()];
for (int i = 0; i < Entries.Length; ++i) for (int i = 0; i < Entries.Length; ++i)
Entries[i] = new BOBLargeSubEntry(reader); Entries[i] = new BOBLargeSubEntry(reader);
break; break;
} }
} }
} }
public bool RequireExceptional{ get; } public bool RequireExceptional { get; }
public BODType DeedType{ get; } public BODType DeedType { get; }
public BulkMaterialType Material{ get; } public BulkMaterialType Material { get; }
public int AmountMax{ get; } public int AmountMax { get; }
public int Price{ get; set; } public int Price { get; set; }
public BOBLargeSubEntry[] Entries{ get; } public BOBLargeSubEntry[] Entries { get; }
public Item Reconstruct() public Item Reconstruct()
{ {
@ -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

@ -19,28 +19,28 @@ namespace Server.Engines.BulkOrders
switch (version) switch (version)
{ {
case 0: case 0:
{ {
string type = reader.ReadString(); string type = reader.ReadString();
if (type != null) if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type); ItemType = AssemblyHandler.FindFirstTypeForName(type);
AmountCur = reader.ReadEncodedInt(); AmountCur = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt(); Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt(); Graphic = reader.ReadEncodedInt();
break; break;
} }
} }
} }
public Type ItemType{ get; } public Type ItemType { get; }
public int AmountCur{ get; } public int AmountCur { get; }
public int Number{ get; } public int Number { get; }
public int Graphic{ get; } public int Graphic { get; }
public void Serialize(IGenericWriter writer) public void Serialize(IGenericWriter writer)
{ {

View file

@ -28,45 +28,45 @@ namespace Server.Engines.BulkOrders
switch (version) switch (version)
{ {
case 0: case 0:
{ {
string type = reader.ReadString(); string type = reader.ReadString();
if (type != null) if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type); ItemType = AssemblyHandler.FindFirstTypeForName(type);
RequireExceptional = reader.ReadBool(); RequireExceptional = reader.ReadBool();
DeedType = (BODType)reader.ReadEncodedInt(); DeedType = (BODType)reader.ReadEncodedInt();
Material = (BulkMaterialType)reader.ReadEncodedInt(); Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt(); AmountCur = reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt(); AmountMax = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt(); Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt(); Graphic = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt(); Price = reader.ReadEncodedInt();
break; break;
} }
} }
} }
public Type ItemType{ get; } public Type ItemType { get; }
public bool RequireExceptional{ get; } public bool RequireExceptional { get; }
public BODType DeedType{ get; } public BODType DeedType { get; }
public BulkMaterialType Material{ get; } public BulkMaterialType Material { get; }
public int AmountCur{ get; } public int AmountCur { get; }
public int AmountMax{ get; } public int AmountMax { get; }
public int Number{ get; } public int Number { get; }
public int Graphic{ get; } public int Graphic { get; }
public int Price{ get; set; } public int Price { get; set; }
public Item Reconstruct() public Item Reconstruct()
{ {

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

@ -12,14 +12,14 @@ namespace Server.Engines.BulkOrders
{ {
private string m_BookName; private string m_BookName;
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty(AccessLevel.GameMaster)]
public string BookName public string BookName
{ {
get => m_BookName; get => m_BookName;
set{ m_BookName = value; InvalidateProperties(); } set { m_BookName = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty(AccessLevel.GameMaster)]
public SecureLevel Level { get; set; } public SecureLevel Level { get; set; }
public List<IBOBEntry> Entries { get; private set; } public List<IBOBEntry> Entries { get; private set; }
@ -29,7 +29,7 @@ namespace Server.Engines.BulkOrders
public int ItemCount { get; set; } public int ItemCount { get; set; }
[Constructible] [Constructible]
public BulkOrderBook() : base( 0x2259 ) public BulkOrderBook() : base(0x2259)
{ {
Weight = 1.0; Weight = 1.0;
LootType = LootType.Blessed; LootType = LootType.Blessed;
@ -40,89 +40,89 @@ namespace Server.Engines.BulkOrders
Level = SecureLevel.CoOwners; Level = SecureLevel.CoOwners;
} }
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick(Mobile from)
{ {
if ( !from.InRange( GetWorldLocation(), 2 ) ) if (!from.InRange(GetWorldLocation(), 2))
from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that. from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
else if ( Entries.Count == 0 ) else if (Entries.Count == 0)
from.SendLocalizedMessage( 1062381 ); // The book is empty. from.SendLocalizedMessage(1062381); // The book is empty.
else if ( from is PlayerMobile mobile ) else if (from is PlayerMobile mobile)
mobile.SendGump( new BOBGump( mobile, this ) ); mobile.SendGump(new BOBGump(mobile, this));
} }
public override void OnDoubleClickSecureTrade( Mobile from ) public override void OnDoubleClickSecureTrade(Mobile from)
{ {
if ( !from.InRange( GetWorldLocation(), 2 ) ) if (!from.InRange(GetWorldLocation(), 2))
{ {
from.SendLocalizedMessage( 500446 ); // That is too far away. from.SendLocalizedMessage(500446); // That is too far away.
} }
else if ( Entries.Count == 0 ) else if (Entries.Count == 0)
{ {
from.SendLocalizedMessage( 1062381 ); // The book is empty. from.SendLocalizedMessage(1062381); // The book is empty.
} }
else else
{ {
from.SendGump( new BOBGump( (PlayerMobile)from, this ) ); from.SendGump(new BOBGump((PlayerMobile)from, this));
SecureTrade trade = GetSecureTradeCont()?.Trade; SecureTrade trade = GetSecureTradeCont()?.Trade;
if (trade?.From.Mobile == from ) if (trade?.From.Mobile == from)
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) ); trade.To.Mobile.SendGump(new BOBGump((PlayerMobile)trade.To.Mobile, this));
else if (trade?.To.Mobile == from ) else if (trade?.To.Mobile == from)
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) ); trade.From.Mobile.SendGump(new BOBGump((PlayerMobile)trade.From.Mobile, this));
} }
} }
public override bool OnDragDrop( Mobile from, Item dropped ) public override bool OnDragDrop(Mobile from, Item dropped)
{ {
if ( dropped is BaseBOD ) if (dropped is BaseBOD)
{ {
if ( !IsChildOf( from.Backpack ) ) if (!IsChildOf(from.Backpack))
{ {
from.SendLocalizedMessage( 1062385 ); // You must have the book in your backpack to add deeds to it. from.SendLocalizedMessage(1062385); // You must have the book in your backpack to add deeds to it.
return false; return false;
} }
if ( !from.Backpack.CheckHold( from, dropped, true, true ) ) if (!from.Backpack.CheckHold(from, dropped, true, true))
return false; return false;
if ( Entries.Count < 500 ) if (Entries.Count < 500)
{ {
if ( dropped is LargeBOD bod ) if (dropped is LargeBOD bod)
Entries.Add( new BOBLargeEntry( bod ) ); Entries.Add(new BOBLargeEntry(bod));
else else
Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) ); Entries.Add(new BOBSmallEntry((SmallBOD)dropped));
InvalidateProperties(); InvalidateProperties();
if ( Entries.Count / 5 > ItemCount ) if (Entries.Count / 5 > ItemCount)
{ {
ItemCount++; ItemCount++;
InvalidateItems(); InvalidateItems();
} }
from.SendSound(0x42, GetWorldLocation()); from.SendSound(0x42, GetWorldLocation());
from.SendLocalizedMessage( 1062386 ); // Deed added to book. from.SendLocalizedMessage(1062386); // Deed added to book.
if ( from is PlayerMobile pm ) if (from is PlayerMobile pm)
pm.SendGump( new BOBGump( pm, this ) ); pm.SendGump(new BOBGump(pm, this));
dropped.Delete(); dropped.Delete();
return true; return true;
} }
from.SendLocalizedMessage( 1062387 ); // The book is full of deeds. from.SendLocalizedMessage(1062387); // The book is full of deeds.
return false; return false;
} }
from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed. from.SendLocalizedMessage(1062388); // That is not a bulk order deed.
return false; return false;
} }
public override int GetTotal( TotalType type ) public override int GetTotal(TotalType type)
{ {
int total = base.GetTotal( type ); int total = base.GetTotal(type);
if ( type == TotalType.Items ) if (type == TotalType.Items)
total = ItemCount; total = ItemCount;
return total; return total;
@ -130,111 +130,111 @@ namespace Server.Engines.BulkOrders
public void InvalidateItems() public void InvalidateItems()
{ {
if ( RootParent is Mobile m ) if (RootParent is Mobile m)
{ {
m.UpdateTotals(); m.UpdateTotals();
InvalidateContainers( Parent ); InvalidateContainers(Parent);
} }
} }
public void InvalidateContainers(IEntity parent) public void InvalidateContainers(IEntity parent)
{ {
if ( parent is Container c ) if (parent is Container c)
{ {
c.InvalidateProperties(); c.InvalidateProperties();
InvalidateContainers( c.Parent ); InvalidateContainers(c.Parent);
} }
} }
public BulkOrderBook( Serial serial ) : base( serial ) public BulkOrderBook(Serial serial) : base(serial)
{ {
} }
public override void Serialize(IGenericWriter writer ) public override void Serialize(IGenericWriter writer)
{ {
base.Serialize( writer ); base.Serialize(writer);
writer.Write( 2 ); // version writer.Write(2); // version
writer.Write( ItemCount ); writer.Write(ItemCount);
writer.Write( (int) Level ); writer.Write((int)Level);
writer.Write( m_BookName ); writer.Write(m_BookName);
Filter.Serialize( writer ); Filter.Serialize(writer);
writer.WriteEncodedInt( Entries.Count ); writer.WriteEncodedInt(Entries.Count);
for ( int i = 0; i < Entries.Count; ++i ) for (int i = 0; i < Entries.Count; ++i)
{ {
object obj = Entries[i]; object obj = Entries[i];
if ( obj is BOBLargeEntry entry ) if (obj is BOBLargeEntry entry)
{ {
writer.WriteEncodedInt( 0 ); writer.WriteEncodedInt(0);
entry.Serialize( writer ); entry.Serialize(writer);
} }
else else
{ {
writer.WriteEncodedInt( 1 ); writer.WriteEncodedInt(1);
((BOBSmallEntry)obj).Serialize( writer ); ((BOBSmallEntry)obj).Serialize(writer);
} }
} }
} }
public override void Deserialize( IGenericReader reader ) public override void Deserialize(IGenericReader reader)
{ {
base.Deserialize( reader ); base.Deserialize(reader);
int version = reader.ReadInt(); int version = reader.ReadInt();
switch ( version ) switch (version)
{ {
case 2: case 2:
{
ItemCount = reader.ReadInt();
goto case 1;
}
case 1:
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
m_BookName = reader.ReadString();
Filter = new BOBFilter( reader );
int count = reader.ReadEncodedInt();
Entries = new List<IBOBEntry>( count );
for ( int i = 0; i < count; ++i )
{ {
int v = reader.ReadEncodedInt(); ItemCount = reader.ReadInt();
goto case 1;
switch ( v )
{
case 0: Entries.Add( new BOBLargeEntry( reader ) ); break;
case 1: Entries.Add( new BOBSmallEntry( reader ) ); break;
}
} }
case 1:
{
Level = (SecureLevel)reader.ReadInt();
goto case 0;
}
case 0:
{
m_BookName = reader.ReadString();
break; Filter = new BOBFilter(reader);
}
int count = reader.ReadEncodedInt();
Entries = new List<IBOBEntry>(count);
for (int i = 0; i < count; ++i)
{
int v = reader.ReadEncodedInt();
switch (v)
{
case 0: Entries.Add(new BOBLargeEntry(reader)); break;
case 1: Entries.Add(new BOBSmallEntry(reader)); break;
}
}
break;
}
} }
} }
public override void GetProperties( ObjectPropertyList list ) public override void GetProperties(ObjectPropertyList list)
{ {
base.GetProperties( list ); base.GetProperties(list);
list.Add( 1062344, Entries.Count.ToString() ); // Deeds in book: ~1_val~ list.Add(1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~
if ( !string.IsNullOrEmpty(m_BookName) ) if (!string.IsNullOrEmpty(m_BookName))
list.Add( 1062481, m_BookName ); // Book Name: ~1_val~ list.Add(1062481, m_BookName); // Book Name: ~1_val~
} }
public override void OnSingleClick(Mobile from) public override void OnSingleClick(Mobile from)
@ -247,22 +247,22 @@ namespace Server.Engines.BulkOrders
LabelTo(from, 1062481, m_BookName); LabelTo(from, 1062481, m_BookName);
} }
public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list ) public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
{ {
base.GetContextMenuEntries( from, list ); base.GetContextMenuEntries(from, list);
if ( from.CheckAlive() && IsChildOf( from.Backpack ) ) if (from.CheckAlive() && IsChildOf(from.Backpack))
list.Add( new NameBookEntry( from, this ) ); list.Add(new NameBookEntry(from, this));
SetSecureLevelEntry.AddTo( from, this, list ); SetSecureLevelEntry.AddTo(from, this, list);
} }
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)
{ {
m_From = from; m_From = from;
m_Book = book; m_Book = book;
@ -270,34 +270,34 @@ namespace Server.Engines.BulkOrders
public override void OnClick() public override void OnClick()
{ {
if ( m_From.CheckAlive() && m_Book.IsChildOf( m_From.Backpack ) ) if (m_From.CheckAlive() && m_Book.IsChildOf(m_From.Backpack))
{ {
m_From.Prompt = new NameBookPrompt( m_Book ); m_From.Prompt = new NameBookPrompt(m_Book);
m_From.SendLocalizedMessage( 1062479 ); // Type in the new name of the book: m_From.SendLocalizedMessage(1062479); // Type in the new name of the book:
} }
} }
} }
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;
public override void OnResponse( Mobile from, string text ) public override void OnResponse(Mobile from, string text)
{ {
if ( text.Length > 40 ) if (text.Length > 40)
text = text.Substring( 0, 40 ); text = text.Substring(0, 40);
if ( from.CheckAlive() && m_Book.IsChildOf( from.Backpack ) ) if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack))
{ {
m_Book.BookName = Utility.FixHtml( text.Trim() ); m_Book.BookName = Utility.FixHtml(text.Trim());
from.SendLocalizedMessage( 1062480 ); // The bulk order book's name has been changed. from.SendLocalizedMessage(1062480); // The bulk order book's name has been changed.
} }
} }
public override void OnCancel( Mobile from ) public override void OnCancel(Mobile from)
{ {
} }
} }

View file

@ -2,11 +2,11 @@ namespace Server.Engines.BulkOrders
{ {
public interface IBOBEntry public interface IBOBEntry
{ {
bool RequireExceptional{ get; } bool RequireExceptional { get; }
BODType DeedType{ get; } BODType DeedType { get; }
BulkMaterialType Material{ get; } BulkMaterialType Material { get; }
int AmountMax{ get; } int AmountMax { get; }
int Price{ get; set; } int Price { get; set; }
Item Reconstruct(); Item Reconstruct();
} }
} }

View file

@ -9,16 +9,16 @@ namespace Server.Engines.BulkOrders
public LargeBulkEntry[] Entries public LargeBulkEntry[] Entries
{ {
get => m_Entries; get => m_Entries;
set{ m_Entries = value; InvalidateProperties(); } set { m_Entries = value; InvalidateProperties(); }
} }
[CommandProperty( AccessLevel.GameMaster )] [CommandProperty(AccessLevel.GameMaster)]
public override bool Complete public override bool Complete
{ {
get get
{ {
for ( int i = 0; i < m_Entries.Length; ++i ) for (int i = 0; i < m_Entries.Length; ++i)
if ( m_Entries[i].Amount < AmountMax ) if (m_Entries[i].Amount < AmountMax)
return false; return false;
return true; return true;
@ -27,48 +27,47 @@ 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()
{ {
} }
public override void GetProperties( ObjectPropertyList list ) public override void GetProperties(ObjectPropertyList list)
{ {
base.GetProperties( list ); base.GetProperties(list);
list.Add( 1060655 ); // large bulk order list.Add(1060655); // large bulk order
if ( RequireExceptional ) if (RequireExceptional)
list.Add( 1045141 ); // All items must be exceptional. list.Add(1045141); // All items must be exceptional.
if ( Material != BulkMaterialType.None ) if (Material != BulkMaterialType.None)
list.Add( LargeBODGump.GetMaterialNumberFor( Material ) ); // All items must be made with x material. list.Add(LargeBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material.
list.Add( 1060656, AmountMax.ToString() ); // amount to make: ~1_val~ list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~
for ( int i = 0; i < m_Entries.Length; ++i ) for (int i = 0; i < m_Entries.Length; ++i)
list.Add( 1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount ); // ~1_val~: ~2_val~ list.Add(1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount); // ~1_val~: ~2_val~
} }
public override void OnDoubleClickNotAccessible( Mobile from ) public override void OnDoubleClickNotAccessible(Mobile from)
{ {
OnDoubleClick( from ); OnDoubleClick(from);
} }
public override void OnDoubleClickSecureTrade( Mobile from ) public override void OnDoubleClickSecureTrade(Mobile from)
{ {
OnDoubleClick( from ); OnDoubleClick(from);
} }
public override void OnDoubleClick( Mobile from ) public override void OnDoubleClick(Mobile from)
{ {
if ( IsChildOf( from.Backpack ) || InSecureTrade || RootParent is PlayerVendor ) if (IsChildOf(from.Backpack) || InSecureTrade || RootParent is PlayerVendor)
from.SendGump( new LargeBODGump( from, this ) ); from.SendGump(new LargeBODGump(from, this));
else else
from.SendLocalizedMessage( 1045156 ); // You must have the deed in your backpack to use it. from.SendLocalizedMessage(1045156); // You must have the deed in your backpack to use it.
} }
public override void EndCombine(Mobile from, Item item) public override void EndCombine(Mobile from, Item item)
@ -136,35 +135,35 @@ namespace Server.Engines.BulkOrders
{ {
} }
public override void Serialize(IGenericWriter writer ) public override void Serialize(IGenericWriter writer)
{ {
base.Serialize( writer ); base.Serialize(writer);
writer.WriteEncodedInt( 0 ); // version writer.WriteEncodedInt(0); // version
writer.Write( m_Entries.Length ); writer.Write(m_Entries.Length);
for ( int i = 0; i < m_Entries.Length; ++i ) for (int i = 0; i < m_Entries.Length; ++i)
m_Entries[i].Serialize( writer ); m_Entries[i].Serialize(writer);
} }
public override void Deserialize( IGenericReader reader ) public override void Deserialize(IGenericReader reader)
{ {
base.Deserialize( reader ); base.Deserialize(reader);
int version = reader.ReadEncodedInt(); int version = reader.ReadEncodedInt();
switch ( version ) switch (version)
{ {
case 0: case 0:
{ {
m_Entries = new LargeBulkEntry[reader.ReadInt()]; m_Entries = new LargeBulkEntry[reader.ReadInt()];
for ( int i = 0; i < m_Entries.Length; ++i ) for (int i = 0; i < m_Entries.Length; ++i)
m_Entries[i] = new LargeBulkEntry( this, reader ); m_Entries[i] = new LargeBulkEntry(this, reader);
break; break;
} }
} }
} }
} }

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

@ -12,88 +12,86 @@ namespace Server.Engines.BulkOrders
public int Amount public int Amount
{ {
get => m_Amount; get => m_Amount;
set{ m_Amount = value; Owner?.InvalidateProperties(); } set { m_Amount = value; Owner?.InvalidateProperties(); }
} }
public SmallBulkEntry Details { get; } public SmallBulkEntry Details { get; }
public static SmallBulkEntry[] LargeRing => GetEntries( "Blacksmith", "largering" ); public static SmallBulkEntry[] LargeRing => GetEntries("Blacksmith", "largering");
public static SmallBulkEntry[] LargePlate => GetEntries( "Blacksmith", "largeplate" ); public static SmallBulkEntry[] LargePlate => GetEntries("Blacksmith", "largeplate");
public static SmallBulkEntry[] LargeChain => GetEntries( "Blacksmith", "largechain" ); public static SmallBulkEntry[] LargeChain => GetEntries("Blacksmith", "largechain");
public static SmallBulkEntry[] LargeAxes => GetEntries( "Blacksmith", "largeaxes" ); public static SmallBulkEntry[] LargeAxes => GetEntries("Blacksmith", "largeaxes");
public static SmallBulkEntry[] LargeFencing => GetEntries( "Blacksmith", "largefencing" ); public static SmallBulkEntry[] LargeFencing => GetEntries("Blacksmith", "largefencing");
public static SmallBulkEntry[] LargeMaces => GetEntries( "Blacksmith", "largemaces" ); public static SmallBulkEntry[] LargeMaces => GetEntries("Blacksmith", "largemaces");
public static SmallBulkEntry[] LargePolearms => GetEntries( "Blacksmith", "largepolearms" ); public static SmallBulkEntry[] LargePolearms => GetEntries("Blacksmith", "largepolearms");
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" ); public static SmallBulkEntry[] FemaleLeatherSet => GetEntries("Tailoring", "femaleleatherset");
public static SmallBulkEntry[] FemaleLeatherSet => GetEntries( "Tailoring", "femaleleatherset" ); public static SmallBulkEntry[] FisherGirl => GetEntries("Tailoring", "fishergirl");
public static SmallBulkEntry[] FisherGirl => GetEntries( "Tailoring", "fishergirl" ); public static SmallBulkEntry[] Gypsy => GetEntries("Tailoring", "gypsy");
public static SmallBulkEntry[] Gypsy => GetEntries( "Tailoring", "gypsy" ); public static SmallBulkEntry[] HatSet => GetEntries("Tailoring", "hatset");
public static SmallBulkEntry[] HatSet => GetEntries( "Tailoring", "hatset" ); public static SmallBulkEntry[] Jester => GetEntries("Tailoring", "jester");
public static SmallBulkEntry[] Jester => GetEntries( "Tailoring", "jester" ); public static SmallBulkEntry[] Lady => GetEntries("Tailoring", "lady");
public static SmallBulkEntry[] Lady => GetEntries( "Tailoring", "lady" ); public static SmallBulkEntry[] MaleLeatherSet => GetEntries("Tailoring", "maleleatherset");
public static SmallBulkEntry[] MaleLeatherSet => GetEntries( "Tailoring", "maleleatherset" ); public static SmallBulkEntry[] Pirate => GetEntries("Tailoring", "pirate");
public static SmallBulkEntry[] Pirate => GetEntries( "Tailoring", "pirate" ); public static SmallBulkEntry[] ShoeSet => GetEntries("Tailoring", "shoeset");
public static SmallBulkEntry[] ShoeSet => GetEntries( "Tailoring", "shoeset" ); public static SmallBulkEntry[] StuddedSet => GetEntries("Tailoring", "studdedset");
public static SmallBulkEntry[] StuddedSet => GetEntries( "Tailoring", "studdedset" ); public static SmallBulkEntry[] TownCrier => GetEntries("Tailoring", "towncrier");
public static SmallBulkEntry[] TownCrier => GetEntries( "Tailoring", "towncrier" ); public static SmallBulkEntry[] Wizard => GetEntries("Tailoring", "wizard");
public static SmallBulkEntry[] Wizard => GetEntries( "Tailoring", "wizard" ); private static Dictionary<string, Dictionary<string, SmallBulkEntry[]>> m_Cache;
public static SmallBulkEntry[] GetEntries(string type, string name)
private static Dictionary<string,Dictionary<string,SmallBulkEntry[]>> m_Cache;
public static SmallBulkEntry[] GetEntries( string type, string name )
{ {
m_Cache ??= new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>(); m_Cache ??= new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>();
if (!m_Cache.TryGetValue( type, out Dictionary<string, SmallBulkEntry[]> table )) if (!m_Cache.TryGetValue(type, out Dictionary<string, SmallBulkEntry[]> table))
m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>(); m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>();
if (!table.TryGetValue( name, out SmallBulkEntry[] entries )) if (!table.TryGetValue(name, out SmallBulkEntry[] entries))
table[name] = entries = SmallBulkEntry.LoadEntries(type, name); table[name] = entries = SmallBulkEntry.LoadEntries(type, name);
return entries; return entries;
} }
public static LargeBulkEntry[] ConvertEntries( LargeBOD owner, SmallBulkEntry[] small ) public static LargeBulkEntry[] ConvertEntries(LargeBOD owner, SmallBulkEntry[] small)
{ {
LargeBulkEntry[] large = new LargeBulkEntry[small.Length]; LargeBulkEntry[] large = new LargeBulkEntry[small.Length];
for ( int i = 0; i < small.Length; ++i ) for (int i = 0; i < small.Length; ++i)
large[i] = new LargeBulkEntry( owner, small[i] ); large[i] = new LargeBulkEntry(owner, small[i]);
return large; return large;
} }
public LargeBulkEntry( LargeBOD owner, SmallBulkEntry details ) public LargeBulkEntry(LargeBOD owner, SmallBulkEntry details)
{ {
Owner = owner; Owner = owner;
Details = details; Details = details;
} }
public LargeBulkEntry( LargeBOD owner, IGenericReader reader ) public LargeBulkEntry(LargeBOD owner, IGenericReader reader)
{ {
Owner = owner; Owner = owner;
m_Amount = reader.ReadInt(); m_Amount = reader.ReadInt();
@ -102,18 +100,18 @@ namespace Server.Engines.BulkOrders
string type = reader.ReadString(); string type = reader.ReadString();
if ( type != null ) if (type != null)
realType = AssemblyHandler.FindFirstTypeForName( type ); realType = AssemblyHandler.FindFirstTypeForName(type);
Details = new SmallBulkEntry( realType, reader.ReadInt(), reader.ReadInt() ); Details = new SmallBulkEntry(realType, reader.ReadInt(), reader.ReadInt());
} }
public void Serialize(IGenericWriter writer ) public void Serialize(IGenericWriter writer)
{ {
writer.Write( m_Amount ); writer.Write(m_Amount);
writer.Write( Details.Type?.FullName ); writer.Write(Details.Type?.FullName);
writer.Write( Details.Number ); writer.Write(Details.Number);
writer.Write( Details.Graphic ); writer.Write(Details.Graphic);
} }
} }
} }

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

@ -13,9 +13,9 @@ namespace Server.Engines.BulkOrders
Types = types; Types = types;
} }
public int Points{ get; } public int Points { get; }
public Type[] Types{ get; } public Type[] Types { get; }
public bool Contains(Type type) public bool Contains(Type type)
{ {
@ -36,11 +36,11 @@ namespace Server.Engines.BulkOrders
Type = type; Type = type;
} }
public int Weight{ get; } public int Weight { get; }
public ConstructCallback Constructor{ get; } public ConstructCallback Constructor { get; }
public int Type{ get; } public int Type { get; }
public Item Construct() public Item Construct()
{ {
@ -63,9 +63,9 @@ namespace Server.Engines.BulkOrders
Items = items; Items = items;
} }
public int Points{ get; } public int Points { get; }
public RewardItem[] Items{ get; } public RewardItem[] Items { get; }
public RewardItem AcquireItem() public RewardItem AcquireItem()
{ {
@ -97,7 +97,7 @@ namespace Server.Engines.BulkOrders
public abstract class RewardCalculator public abstract class RewardCalculator
{ {
public RewardGroup[] Groups{ get; set; } public RewardGroup[] Groups { get; set; }
public abstract int ComputePoints(int quantity, bool exceptional, BulkMaterialType material, int itemCount, public abstract int ComputePoints(int quantity, bool exceptional, BulkMaterialType material, int itemCount,
Type type); Type type);
@ -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)),
@ -264,7 +264,7 @@ namespace Server.Engines.BulkOrders
// Weapons // Weapons
new RewardType(200, typeof(Bardiche), typeof(Halberd)), new RewardType(200, typeof(Bardiche), typeof(Halberd)),
new RewardType(300, typeof(Dagger), typeof(ShortSpear), typeof(Spear), typeof(WarFork), new RewardType(300, typeof(Dagger), typeof(ShortSpear), typeof(Spear), typeof(WarFork),
typeof(Kryss)), //OSI put the dagger in there. Odd, ain't it. typeof(Kryss)), // OSI put the dagger in there. Odd, ain't it.
new RewardType(350, typeof(Axe), typeof(BattleAxe), typeof(DoubleAxe), typeof(ExecutionersAxe), new RewardType(350, typeof(Axe), typeof(BattleAxe), typeof(DoubleAxe), typeof(ExecutionersAxe),
typeof(LargeBattleAxe), typeof(TwoHandedAxe)), typeof(LargeBattleAxe), typeof(TwoHandedAxe)),
new RewardType(350, typeof(Broadsword), typeof(Cutlass), typeof(Katana), typeof(Longsword), new RewardType(350, typeof(Broadsword), typeof(Cutlass), typeof(Katana), typeof(Longsword),
@ -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)
{ {
@ -612,7 +608,7 @@ namespace Server.Engines.BulkOrders
4 => 1, 4 => 1,
_ => 0 _ => 0
} * 2 + (exceptional ? 1 : 0); } * 2 + (exceptional ? 1 : 0);
int quanIndex = quantity switch int quanIndex = quantity switch
{ {
20 => 2, 20 => 2,
@ -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

@ -38,7 +38,7 @@ namespace Server.Engines.BulkOrders
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Type Type{ get; set; } public Type Type { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int Number public int Number
@ -52,7 +52,7 @@ namespace Server.Engines.BulkOrders
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int Graphic{ get; set; } public int Graphic { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public override bool Complete => m_AmountCur == AmountMax; public override bool Complete => m_AmountCur == AmountMax;
@ -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.
} }
@ -194,18 +194,18 @@ namespace Server.Engines.BulkOrders
switch (version) switch (version)
{ {
case 0: case 0:
{ {
m_AmountCur = reader.ReadInt(); m_AmountCur = reader.ReadInt();
string type = reader.ReadString(); string type = reader.ReadString();
if (type != null) if (type != null)
Type = AssemblyHandler.FindFirstTypeForName(type); Type = AssemblyHandler.FindFirstTypeForName(type);
m_Number = reader.ReadInt(); m_Number = reader.ReadInt();
Graphic = reader.ReadInt(); Graphic = reader.ReadInt();
break; break;
} }
} }
} }
} }

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

@ -12,66 +12,66 @@ namespace Server.Engines.BulkOrders
public int Graphic { get; } public int Graphic { get; }
public SmallBulkEntry( Type type, int number, int graphic ) public SmallBulkEntry(Type type, int number, int graphic)
{ {
Type = type; Type = type;
Number = number; Number = number;
Graphic = graphic; Graphic = graphic;
} }
public static SmallBulkEntry[] BlacksmithWeapons => GetEntries( "Blacksmith", "weapons" ); public static SmallBulkEntry[] BlacksmithWeapons => GetEntries("Blacksmith", "weapons");
public static SmallBulkEntry[] BlacksmithArmor => GetEntries( "Blacksmith", "armor" ); public static SmallBulkEntry[] BlacksmithArmor => GetEntries("Blacksmith", "armor");
public static SmallBulkEntry[] TailorCloth => GetEntries( "Tailoring", "cloth" ); public static SmallBulkEntry[] TailorCloth => GetEntries("Tailoring", "cloth");
public static SmallBulkEntry[] TailorLeather => GetEntries( "Tailoring", "leather" ); public static SmallBulkEntry[] TailorLeather => GetEntries("Tailoring", "leather");
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)
{ {
if ( m_Cache == null ) if (m_Cache == null)
m_Cache = new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>(); m_Cache = new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>();
if (!m_Cache.TryGetValue( type, out Dictionary<string, SmallBulkEntry[]> table )) if (!m_Cache.TryGetValue(type, out Dictionary<string, SmallBulkEntry[]> table))
m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>(); m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>();
if (!table.TryGetValue( name, out SmallBulkEntry[] entries )) if (!table.TryGetValue(name, out SmallBulkEntry[] entries))
table[name] = entries = LoadEntries(type, name); table[name] = entries = LoadEntries(type, name);
return entries; return entries;
} }
public static SmallBulkEntry[] LoadEntries( string type, string name ) => LoadEntries($"Data/Bulk Orders/{type}/{name}.cfg"); public static SmallBulkEntry[] LoadEntries(string type, string name) => LoadEntries($"Data/Bulk Orders/{type}/{name}.cfg");
public static SmallBulkEntry[] LoadEntries( string path ) public static SmallBulkEntry[] LoadEntries(string path)
{ {
path = Path.Combine( Core.BaseDirectory, path ); path = Path.Combine(Core.BaseDirectory, path);
List<SmallBulkEntry> list = new List<SmallBulkEntry>(); List<SmallBulkEntry> list = new List<SmallBulkEntry>();
if ( File.Exists( path ) ) if (File.Exists(path))
{ {
using StreamReader ip = new StreamReader( path ); using StreamReader ip = new StreamReader(path);
string line; string line;
while ( (line = ip.ReadLine()) != null ) while ((line = ip.ReadLine()) != null)
{ {
if ( line.Length == 0 || line.StartsWith( "#" ) ) if (line.Length == 0 || line.StartsWith("#"))
continue; continue;
try try
{ {
string[] split = line.Split( '\t' ); string[] split = line.Split('\t');
if ( split.Length >= 2 ) if (split.Length >= 2)
{ {
Type type = AssemblyHandler.FindFirstTypeForName( split[0] ); Type type = AssemblyHandler.FindFirstTypeForName(split[0]);
int graphic = Utility.ToInt32( split[split.Length - 1] ); int graphic = Utility.ToInt32(split[split.Length - 1]);
if ( type != null && graphic > 0 ) if (type != null && graphic > 0)
list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) ); list.Add(new SmallBulkEntry(type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic));
} }
} }
catch catch

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

@ -37,14 +37,14 @@ namespace Server.Engines.CannedEvil
switch (version) switch (version)
{ {
case 0: case 0:
{ {
m_Spawn = reader.ReadItem() as ChampionSpawn; m_Spawn = reader.ReadItem() as ChampionSpawn;
if (m_Spawn == null) if (m_Spawn == null)
Delete(); Delete();
break; break;
} }
} }
} }
} }

View file

@ -11,12 +11,12 @@ namespace Server.Engines.CannedEvil
m_Spawn = spawn; m_Spawn = spawn;
for (int x = -2; x <= 2; ++x) for (int x = -2; x <= 2; ++x)
for (int y = -2; y <= 2; ++y) for (int y = -2; y <= 2; ++y)
AddComponent(0x750, x, y, -5); AddComponent(0x750, x, y, -5);
for (int x = -1; x <= 1; ++x) for (int x = -1; x <= 1; ++x)
for (int y = -1; y <= 1; ++y) for (int y = -1; y <= 1; ++y)
AddComponent(0x750, x, y, 0); AddComponent(0x750, x, y, 0);
for (int i = -1; i <= 1; ++i) for (int i = -1; i <= 1; ++i)
{ {
@ -71,14 +71,14 @@ namespace Server.Engines.CannedEvil
switch (version) switch (version)
{ {
case 0: case 0:
{ {
m_Spawn = reader.ReadItem() as ChampionSpawn; m_Spawn = reader.ReadItem() as ChampionSpawn;
if (m_Spawn == null) if (m_Spawn == null)
Delete(); Delete();
break; break;
} }
} }
} }
} }

View file

@ -60,11 +60,11 @@ namespace Server.Items
{ {
case 1: case 1:
case 0: case 0:
{ {
m_Type = (ChampionSkullType)reader.ReadInt(); m_Type = (ChampionSkullType)reader.ReadInt();
break; break;
} }
} }
if (version == 0) if (version == 0)

View file

@ -23,7 +23,7 @@ namespace Server.Engines.CannedEvil
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public ChampionSkullPlatform Platform{ get; private set; } public ChampionSkullPlatform Platform { get; private set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public ChampionSkullType Type public ChampionSkullType Type
@ -147,16 +147,16 @@ namespace Server.Engines.CannedEvil
switch (version) switch (version)
{ {
case 0: case 0:
{ {
m_Type = (ChampionSkullType)reader.ReadInt(); m_Type = (ChampionSkullType)reader.ReadInt();
Platform = reader.ReadItem() as ChampionSkullPlatform; Platform = reader.ReadItem() as ChampionSkullPlatform;
m_Skull = reader.ReadItem(); m_Skull = reader.ReadItem();
if (Platform == null) if (Platform == null)
Delete(); Delete();
break; break;
} }
} }
if (Hue == 0x497) if (Hue == 0x497)
@ -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

@ -109,16 +109,16 @@ namespace Server.Engines.CannedEvil
switch (version) switch (version)
{ {
case 0: case 0:
{ {
m_Power = reader.ReadItem() as ChampionSkullBrazier; m_Power = reader.ReadItem() as ChampionSkullBrazier;
m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier; m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier;
m_Venom = reader.ReadItem() as ChampionSkullBrazier; m_Venom = reader.ReadItem() as ChampionSkullBrazier;
m_Pain = reader.ReadItem() as ChampionSkullBrazier; m_Pain = reader.ReadItem() as ChampionSkullBrazier;
m_Greed = reader.ReadItem() as ChampionSkullBrazier; m_Greed = reader.ReadItem() as ChampionSkullBrazier;
m_Death = reader.ReadItem() as ChampionSkullBrazier; m_Death = reader.ReadItem() as ChampionSkullBrazier;
break; break;
} }
} }
} }
} }

View file

@ -26,7 +26,7 @@ namespace Server.Engines.CannedEvil
private List<Item> m_RedSkulls; private List<Item> m_RedSkulls;
private ChampionSpawnRegion m_Region; private ChampionSpawnRegion m_Region;
//private int m_SpawnRange; // private int m_SpawnRange;
private Rectangle2D m_SpawnArea; private Rectangle2D m_SpawnArea;
private int m_SPawnSzMod; private int m_SPawnSzMod;
@ -68,13 +68,13 @@ namespace Server.Engines.CannedEvil
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public bool ConfinedRoaming{ get; set; } public bool ConfinedRoaming { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public bool HasBeenAdvanced{ get; set; } public bool HasBeenAdvanced { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public bool RandomizeType{ get; set; } public bool RandomizeType { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int Kills public int Kills
@ -100,16 +100,16 @@ namespace Server.Engines.CannedEvil
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public TimeSpan RestartDelay{ get; set; } public TimeSpan RestartDelay { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public DateTime RestartTime{ get; private set; } public DateTime RestartTime { get; private set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public TimeSpan ExpireDelay{ get; set; } public TimeSpan ExpireDelay { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public DateTime ExpireTime{ get; set; } public DateTime ExpireTime { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public ChampionSpawnType Type public ChampionSpawnType Type
@ -138,7 +138,7 @@ namespace Server.Engines.CannedEvil
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Mobile Champion{ get; set; } public Mobile Champion { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public int Level public int Level
@ -173,7 +173,7 @@ namespace Server.Engines.CannedEvil
public void SetInitialSpawnArea() public void SetInitialSpawnArea()
{ {
//Previous default used to be 24; // Previous default used to be 24;
SpawnArea = new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); SpawnArea = new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24));
} }
@ -188,7 +188,7 @@ namespace Server.Engines.CannedEvil
} }
/* /*
if ( m_Region == null ) if (m_Region == null)
{ {
m_Region = new ChampionSpawnRegion( this ); m_Region = new ChampionSpawnRegion( this );
} }
@ -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,11 +317,9 @@ 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
return; return;
if (scroll is ScrollofTranscendence) if (scroll is ScrollofTranscendence)
@ -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)
@ -484,7 +476,7 @@ namespace Server.Engines.CannedEvil
else else
m.SendLocalizedMessage(1054030); // You have gained in Valor! m.SendLocalizedMessage(1054030); // You have gained in Valor!
//No delay on Valor gains // No delay on Valor gains
} }
PlayerMobile.ChampionTitleInfo info = pm.ChampionTitles; PlayerMobile.ChampionTitleInfo info = pm.ChampionTitles;
@ -790,7 +782,7 @@ namespace Server.Engines.CannedEvil
list.Add(1060659, "Level\t{0}", Level); // ~1_val~: ~2_val~ list.Add(1060659, "Level\t{0}", Level); // ~1_val~: ~2_val~
list.Add(1060660, "Kills\t{0} of {1} ({2:F1}%)", m_Kills, MaxKills, list.Add(1060660, "Kills\t{0} of {1} ({2:F1}%)", m_Kills, MaxKills,
100.0 * ((double)m_Kills / MaxKills)); // ~1_val~: ~2_val~ 100.0 * ((double)m_Kills / MaxKills)); // ~1_val~: ~2_val~
//list.Add( 1060661, "Spawn Range\t{0}", m_SpawnRange ); // ~1_val~: ~2_val~ // list.Add( 1060661, "Spawn Range\t{0}", m_SpawnRange ); // ~1_val~: ~2_val~
} }
else else
{ {
@ -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)
{ {
@ -1013,7 +1005,7 @@ namespace Server.Engines.CannedEvil
writer.Write(RandomizeType); writer.Write(RandomizeType);
// writer.Write( m_SpawnRange ); // writer.Write( m_SpawnRange );
writer.Write(m_Kills); writer.Write(m_Kills);
writer.Write(m_Active); writer.Write(m_Active);
@ -1045,97 +1037,97 @@ namespace Server.Engines.CannedEvil
switch (version) switch (version)
{ {
case 6: case 6:
{ {
m_SPawnSzMod = reader.ReadInt(); m_SPawnSzMod = reader.ReadInt();
goto case 5; goto case 5;
} }
case 5: case 5:
{
int entries = reader.ReadInt();
for (int i = 0; i < entries; ++i)
{ {
Mobile m = reader.ReadMobile(); int entries = reader.ReadInt();
int damage = reader.ReadInt(); for (int i = 0; i < entries; ++i)
{
Mobile m = reader.ReadMobile();
int damage = reader.ReadInt();
if (m == null) if (m == null)
continue; continue;
m_DamageEntries.Add(m, damage); m_DamageEntries.Add(m, damage);
}
goto case 4;
} }
goto case 4;
}
case 4: case 4:
{ {
ConfinedRoaming = reader.ReadBool(); ConfinedRoaming = reader.ReadBool();
m_Idol = reader.ReadItem<IdolOfTheChampion>(); m_Idol = reader.ReadItem<IdolOfTheChampion>();
HasBeenAdvanced = reader.ReadBool(); HasBeenAdvanced = reader.ReadBool();
goto case 3; goto case 3;
} }
case 3: case 3:
{ {
m_SpawnArea = reader.ReadRect2D(); m_SpawnArea = reader.ReadRect2D();
goto case 2; goto case 2;
} }
case 2: case 2:
{ {
RandomizeType = reader.ReadBool(); RandomizeType = reader.ReadBool();
goto case 1; goto case 1;
} }
case 1: case 1:
{
if (version < 3)
{ {
int oldRange = reader.ReadInt(); if (version < 3)
{
int oldRange = reader.ReadInt();
m_SpawnArea = new Rectangle2D(new Point2D(X - oldRange, Y - oldRange), m_SpawnArea = new Rectangle2D(new Point2D(X - oldRange, Y - oldRange),
new Point2D(X + oldRange, Y + oldRange)); new Point2D(X + oldRange, Y + oldRange));
}
m_Kills = reader.ReadInt();
goto case 0;
} }
m_Kills = reader.ReadInt();
goto case 0;
}
case 0: case 0:
{
if (version < 1)
m_SpawnArea =
new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); //Default was 24
bool active = reader.ReadBool();
m_Type = (ChampionSpawnType)reader.ReadInt();
m_Creatures = reader.ReadStrongMobileList();
m_RedSkulls = reader.ReadStrongItemList();
m_WhiteSkulls = reader.ReadStrongItemList();
m_Platform = reader.ReadItem<ChampionPlatform>();
m_Altar = reader.ReadItem<ChampionAltar>();
ExpireDelay = reader.ReadTimeSpan();
ExpireTime = reader.ReadDeltaTime();
Champion = reader.ReadMobile();
RestartDelay = reader.ReadTimeSpan();
if (reader.ReadBool())
{ {
RestartTime = reader.ReadDeltaTime(); if (version < 1)
BeginRestart(RestartTime - DateTime.UtcNow); m_SpawnArea =
new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); // Default was 24
bool active = reader.ReadBool();
m_Type = (ChampionSpawnType)reader.ReadInt();
m_Creatures = reader.ReadStrongMobileList();
m_RedSkulls = reader.ReadStrongItemList();
m_WhiteSkulls = reader.ReadStrongItemList();
m_Platform = reader.ReadItem<ChampionPlatform>();
m_Altar = reader.ReadItem<ChampionAltar>();
ExpireDelay = reader.ReadTimeSpan();
ExpireTime = reader.ReadDeltaTime();
Champion = reader.ReadMobile();
RestartDelay = reader.ReadTimeSpan();
if (reader.ReadBool())
{
RestartTime = reader.ReadDeltaTime();
BeginRestart(RestartTime - DateTime.UtcNow);
}
if (version < 4)
{
m_Idol = new IdolOfTheChampion(this);
m_Idol.MoveToWorld(new Point3D(X, Y, Z - 15), Map);
}
if (m_Platform == null || m_Altar == null || m_Idol == null)
Delete();
else if (active)
Start();
break;
} }
if (version < 4)
{
m_Idol = new IdolOfTheChampion(this);
m_Idol.MoveToWorld(new Point3D(X, Y, Z - 15), Map);
}
if (m_Platform == null || m_Altar == null || m_Idol == null)
Delete();
else if (active)
Start();
break;
}
} }
Timer.DelayCall(TimeSpan.Zero, UpdateRegion); Timer.DelayCall(TimeSpan.Zero, UpdateRegion);
@ -1150,7 +1142,7 @@ namespace Server.Engines.CannedEvil
public override bool YoungProtected => false; public override bool YoungProtected => false;
public ChampionSpawn ChampionSpawn{ get; } public ChampionSpawn ChampionSpawn { get; }
public override bool AllowHousing(Mobile from, Point3D p) => false; public override bool AllowHousing(Mobile from, Point3D p) => false;
@ -1159,7 +1151,7 @@ namespace Server.Engines.CannedEvil
base.AlterLightLevel(m, ref global, ref personal); base.AlterLightLevel(m, ref global, ref personal);
global = Math.Max(global, global = Math.Max(global,
1 + ChampionSpawn 1 + ChampionSpawn
.Level); //This is a guesstimate. TODO: Verify & get exact values // OSI testing: at 2 red skulls, light = 0x3 ; 1 red = 0x3.; 3 = 8; 9 = 0xD 8 = 0xD 12 = 0x12 10 = 0xD .Level); // This is a guesstimate. TODO: Verify & get exact values // OSI testing: at 2 red skulls, light = 0x3 ; 1 red = 0x3.; 3 = 8; 9 = 0xD 8 = 0xD 12 = 0x12 10 = 0xD
} }
} }
@ -1175,7 +1167,7 @@ namespace Server.Engines.CannedEvil
{ {
} }
public ChampionSpawn Spawn{ get; private set; } public ChampionSpawn Spawn { get; private set; }
public override string DefaultName => "Idol of the Champion"; public override string DefaultName => "Idol of the Champion";
@ -1204,14 +1196,14 @@ namespace Server.Engines.CannedEvil
switch (version) switch (version)
{ {
case 0: case 0:
{ {
Spawn = reader.ReadItem() as ChampionSpawn; Spawn = reader.ReadItem() as ChampionSpawn;
if (Spawn == null) if (Spawn == null)
Delete(); Delete();
break; break;
} }
} }
} }
} }

View file

@ -26,15 +26,15 @@ namespace Server.Engines.CannedEvil
SpawnTypes = spawnTypes; SpawnTypes = spawnTypes;
} }
public string Name{ get; } public string Name { get; }
public Type Champion{ get; } public Type Champion { get; }
public Type[][] SpawnTypes{ get; } public Type[][] SpawnTypes { get; }
public string[] LevelNames{ get; } public string[] LevelNames { get; }
public static ChampionSpawnInfo[] Table{ get; } = public static ChampionSpawnInfo[] Table { get; } =
{ {
new ChampionSpawnInfo("Abyss", typeof(Semidar), new[] { "Foe", "Assassin", "Conqueror" }, new[] // Abyss new ChampionSpawnInfo("Abyss", typeof(Semidar), new[] { "Foe", "Assassin", "Conqueror" }, new[] // Abyss
{ {

View file

@ -39,14 +39,14 @@ namespace Server.Items
switch (version) switch (version)
{ {
case 0: case 0:
{ {
m_Harrower = reader.ReadMobile(); m_Harrower = reader.ReadMobile();
if (m_Harrower == null) if (m_Harrower == null)
Delete(); Delete();
break; break;
} }
} }
if (Light != LightType.Circle300) if (Light != LightType.Circle300)

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

@ -65,25 +65,25 @@ namespace Server.Items
switch (version) switch (version)
{ {
case 0: case 0:
{
m_Decays = reader.ReadBool();
if (m_Decays)
{ {
m_DecayTime = reader.ReadDeltaTime(); m_Decays = reader.ReadBool();
m_Timer = new InternalTimer(this, m_DecayTime); if (m_Decays)
m_Timer.Start(); {
m_DecayTime = reader.ReadDeltaTime();
m_Timer = new InternalTimer(this, m_DecayTime);
m_Timer.Start();
}
break;
} }
break;
}
} }
} }
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)
@ -66,9 +69,9 @@ namespace Server.Engines.Chat
} }
} }
public bool AlwaysAvailable{ get; set; } public bool AlwaysAvailable { get; set; }
public static List<Channel> Channels{ get; } = new List<Channel>(); public static List<Channel> Channels { get; } = new List<Channel>();
public bool Contains(ChatUser user) => m_Users.Contains(user); public bool Contains(ChatUser user) => m_Users.Contains(user);
@ -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

@ -8,7 +8,7 @@ namespace Server.Engines.Chat
{ {
public class ChatSystem public class ChatSystem
{ {
public static bool Enabled{ get; set; } = true; public static bool Enabled { get; set; } = true;
public static void Initialize() public static void Initialize()
{ {
@ -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
@ -147,4 +148,4 @@ namespace Server.Engines.Chat
} }
} }
} }
} }

View file

@ -11,10 +11,10 @@ namespace Server.Engines.Chat
Callback = callback; Callback = callback;
} }
public bool RequireModerator{ get; } public bool RequireModerator { get; }
public bool RequireConference{ get; } public bool RequireConference { get; }
public OnChatAction Callback{ get; } public OnChatAction Callback { get; }
} }
} }

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)
{ {
@ -19,11 +19,11 @@ namespace Server.Engines.Chat
Ignoring = new List<ChatUser>(); Ignoring = new List<ChatUser>();
} }
public Mobile Mobile{ get; } public Mobile Mobile { get; }
public List<ChatUser> Ignored{ get; } public List<ChatUser> Ignored { get; }
public List<ChatUser> Ignoring{ get; } public List<ChatUser> Ignoring { get; }
public string Username public string Username
{ {
@ -41,13 +41,13 @@ namespace Server.Engines.Chat
} }
} }
public Channel CurrentChannel{ get; set; } public Channel CurrentChannel { get; set; }
public bool IsOnline => Mobile.NetState != null; public bool IsOnline => Mobile.NetState != null;
public bool Anonymous{ get; set; } public bool Anonymous { get; set; }
public bool IgnorePrivateMessage{ get; set; } public bool IgnorePrivateMessage { get; set; }
public bool IsModerator => CurrentChannel?.IsModerator(this) == true; public bool IsModerator => CurrentChannel?.IsModerator(this) == true;
@ -135,7 +135,7 @@ namespace Server.Engines.Chat
break; break;
} }
//ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username ); // ChatSystem.SendCommandTo( user.m_Mobile, ChatCommand.AddUserToChannel, user.GetColorCharacter() + user.Username );
return user; return user;
} }

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)
@ -34,15 +35,15 @@ namespace Server.Engines.ConPVP
AddPage(0); AddPage(0);
//AddBackground( 0, 0, 400, 220, 9150 ); // AddBackground( 0, 0, 400, 220, 9150 );
AddBackground(1, 1, 398, 218, 3600); AddBackground(1, 1, 398, 218, 3600);
//AddBackground( 16, 15, 369, 189, 9100 ); // AddBackground( 16, 15, 369, 189, 9100 );
AddImageTiled(16, 15, 369, 189, 3604); AddImageTiled(16, 15, 369, 189, 3604);
AddAlphaRegion(16, 15, 369, 189); AddAlphaRegion(16, 15, 369, 189);
AddImage(215, -43, 0xEE40); AddImage(215, -43, 0xEE40);
//AddImage( 330, 141, 0x8BA ); // AddImage( 330, 141, 0x8BA );
AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32)); AddHtml(22 - 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32));
AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32)); AddHtml(22 + 1, 22, 294, 20, Color(Center("Duel Challenge"), BlackColor32));
@ -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

@ -24,14 +24,14 @@ namespace Server.Engines.ConPVP
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Arena Arena{ get; private set; } public Arena Arena { get; private set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public bool IsPrivate{ get; set; } public bool IsPrivate { get; set; }
public override string DefaultName => "arena controller"; public override string DefaultName => "arena controller";
public static List<ArenaController> Instances{ get; set; } = new List<ArenaController>(); public static List<ArenaController> Instances { get; set; } = new List<ArenaController>();
public override void OnDelete() public override void OnDelete()
{ {
@ -67,16 +67,16 @@ namespace Server.Engines.ConPVP
switch (version) switch (version)
{ {
case 1: case 1:
{ {
IsPrivate = reader.ReadBool(); IsPrivate = reader.ReadBool();
goto case 0; goto case 0;
} }
case 0: case 0:
{ {
Arena = new Arena(reader); Arena = new Arena(reader);
break; break;
} }
} }
Instances.Add(this); Instances.Add(this);
@ -96,7 +96,7 @@ namespace Server.Engines.ConPVP
Points[i] = reader.ReadPoint3D(); Points[i] = reader.ReadPoint3D();
} }
public Point3D[] Points{ get; } public Point3D[] Points { get; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Point3D EdgeWest public Point3D EdgeWest
@ -194,74 +194,74 @@ namespace Server.Engines.ConPVP
switch (version) switch (version)
{ {
case 7: case 7:
{ {
m_IsGuarded = reader.ReadBool(); m_IsGuarded = reader.ReadBool();
goto case 6; goto case 6;
} }
case 6: case 6:
{ {
Ladder = reader.ReadItem() as LadderController; Ladder = reader.ReadItem() as LadderController;
goto case 5; goto case 5;
} }
case 5: case 5:
{ {
m_Tournament = reader.ReadItem() as TournamentController; m_Tournament = reader.ReadItem() as TournamentController;
Announcer = reader.ReadMobile(); Announcer = reader.ReadMobile();
goto case 4; goto case 4;
} }
case 4: case 4:
{ {
m_Name = reader.ReadString(); m_Name = reader.ReadString();
goto case 3; goto case 3;
} }
case 3: case 3:
{ {
m_Zone = reader.ReadRect2D(); m_Zone = reader.ReadRect2D();
goto case 2; goto case 2;
} }
case 2: case 2:
{ {
GateIn = reader.ReadPoint3D(); GateIn = reader.ReadPoint3D();
m_GateOut = reader.ReadPoint3D(); m_GateOut = reader.ReadPoint3D();
Teleporter = reader.ReadItem(); Teleporter = reader.ReadItem();
goto case 1; goto case 1;
} }
case 1: case 1:
{ {
Players = reader.ReadStrongMobileList(); Players = reader.ReadStrongMobileList();
goto case 0; goto case 0;
} }
case 0: case 0:
{
m_Facet = reader.ReadMap();
m_Bounds = reader.ReadRect2D();
Outside = reader.ReadPoint3D();
Wall = reader.ReadPoint3D();
if (version == 0)
{ {
reader.ReadBool(); m_Facet = reader.ReadMap();
Players = new List<Mobile>(); m_Bounds = reader.ReadRect2D();
Outside = reader.ReadPoint3D();
Wall = reader.ReadPoint3D();
if (version == 0)
{
reader.ReadBool();
Players = new List<Mobile>();
}
m_Active = reader.ReadBool();
Points = new ArenaStartPoints(reader);
if (m_Active)
{
Arenas.Add(this);
Arenas.Sort();
}
break;
} }
m_Active = reader.ReadBool();
Points = new ArenaStartPoints(reader);
if (m_Active)
{
Arenas.Add(this);
Arenas.Sort();
}
break;
}
} }
if (m_Zone.Start != Point2D.Zero && m_Zone.End != Point2D.Zero && m_Facet != null) if (m_Zone.Start != Point2D.Zero && m_Zone.End != Point2D.Zero && m_Facet != null)
@ -275,7 +275,7 @@ namespace Server.Engines.ConPVP
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public LadderController Ladder{ get; set; } public LadderController Ladder { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public bool IsGuarded public bool IsGuarded
@ -305,7 +305,7 @@ namespace Server.Engines.ConPVP
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Mobile Announcer{ get; set; } public Mobile Announcer { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public string Name public string Name
@ -385,10 +385,10 @@ namespace Server.Engines.ConPVP
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Point3D Outside{ get; set; } public Point3D Outside { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Point3D GateIn{ get; set; } public Point3D GateIn { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Point3D GateOut public Point3D GateOut
@ -403,17 +403,17 @@ namespace Server.Engines.ConPVP
} }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public Point3D Wall{ get; set; } public Point3D Wall { get; set; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public bool IsOccupied => Players.Count > 0; public bool IsOccupied => Players.Count > 0;
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public ArenaStartPoints Points{ get; private set; } public ArenaStartPoints Points { get; private set; }
public Item Teleporter{ get; set; } public Item Teleporter { get; set; }
public List<Mobile> Players{ get; } public List<Mobile> Players { get; }
[CommandProperty(AccessLevel.GameMaster)] [CommandProperty(AccessLevel.GameMaster)]
public bool Active public bool Active
@ -448,7 +448,7 @@ namespace Server.Engines.ConPVP
} }
} }
public static List<Arena> Arenas{ get; } = new List<Arena>(); public static List<Arena> Arenas { get; } = new List<Arena>();
public int CompareTo(Arena c) public int CompareTo(Arena c)
{ {
@ -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
} }
} }

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