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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Analyze|Any CPU = Analyze|Any CPU
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
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.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.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.Build.0 = Debug|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;
private static List<InvalidAccountAccessLog> m_List = new List<InvalidAccountAccessLog>();
private static readonly List<InvalidAccountAccessLog> m_List = new List<InvalidAccountAccessLog>();
public static void Initialize()
{
@ -75,8 +75,7 @@ namespace Server.Accounting
"{0}\t{1}\t{2}",
DateTime.UtcNow,
ns,
accessLog.Counts
);
accessLog.Counts);
}
catch
{
@ -113,13 +112,13 @@ namespace Server.Accounting
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 int Counts{ get; set; }
public int Counts { get; set; }
public void RefreshAccessTime()
{

View file

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

View file

@ -18,14 +18,14 @@ namespace Server.Misc
public class AccountHandler
{
private static int MaxAccountsPerIP = 1;
private static bool AutoAccountCreation = true;
private static bool RestrictDeletion = !TestCenter.Enabled;
private static TimeSpan DeleteDelay = TimeSpan.FromDays(7.0);
private static readonly int MaxAccountsPerIP = 1;
private static readonly bool AutoAccountCreation = true;
private static readonly bool RestrictDeletion = !TestCenter.Enabled;
private static readonly TimeSpan DeleteDelay = TimeSpan.FromDays(7.0);
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("Yew", "The Empath Abbey", 1075072, 633, 858, 0),
@ -47,7 +47,7 @@ namespace Server.Misc
// ..
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", 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;
@ -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
{
@ -174,10 +174,10 @@ namespace Server.Misc
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.");
from.SendLocalizedMessage(501234, "",
0x35); /* The next available Counselor/Game Master will respond as soon as possible.
* Please check your Journal for messages every few minutes.
*/
/* The next available Counselor/Game Master will respond as soon as possible.
* Please check your Journal for messages every few minutes.
*/
from.SendLocalizedMessage(501234, "", 0x35);
PageQueue.Enqueue(new PageEntry(from,
$"[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));
}
else if (m.AccessLevel == AccessLevel.Player &&
Region.Find(m.LogoutLocation, m.LogoutMap).IsPartOf<Jail>()
) //Don't need to check current location, if netstate is null, they're logged out
Region.Find(m.LogoutLocation, m.LogoutMap).IsPartOf<Jail>()) // Don't need to check current location, if netstate is null, they're logged out
{
state.Send(new DeleteResult(DeleteResultType.BadRequest));
state.Send(new CharacterListUpdate(acct));

View file

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

View file

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

View file

@ -30,7 +30,7 @@ namespace Server
object toAdd;
IPAddress addr;
if ( IPAddress.TryParse( line, out addr ) )
if (IPAddress.TryParse( line, out addr ))
toAdd = addr;
else
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)
{
@ -60,7 +60,7 @@ namespace Server
if (IPAddress.TryParse(entry, out IPAddress addr))
return new IPFirewallEntry(addr);
//Try CIDR parse
// Try CIDR parse
string[] str = entry.Split('/');
if (str.Length == 2)
@ -147,15 +147,15 @@ namespace Server
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] );
else if ( m_Blocked[i] is String )
else if (m_Blocked[i] is String)
{
string s = (string)m_Blocked[i];
contains = Utility.IPMatchCIDR( s, ip );
if ( !contains )
if (!contains)
contains = Utility.IPMatch( s, ip );
}
}
@ -164,8 +164,6 @@ namespace Server
* */
}
#region Firewall Entries
public interface IFirewallEntry
{
bool IsBlocked(IPAddress address);
@ -173,7 +171,7 @@ namespace Server
public class IPFirewallEntry : IFirewallEntry
{
private IPAddress m_Address;
private readonly IPAddress m_Address;
public IPFirewallEntry(IPAddress address) => m_Address = address;
@ -203,8 +201,8 @@ namespace Server
public class CIDRFirewallEntry : IFirewallEntry
{
private int m_CIDRLength;
private IPAddress m_CIDRPrefix;
private readonly int m_CIDRLength;
private readonly IPAddress m_CIDRPrefix;
public CIDRFirewallEntry(IPAddress cidrPrefix, int cidrLength)
{
@ -240,7 +238,7 @@ namespace Server
public class WildcardIPFirewallEntry : IFirewallEntry
{
private string m_Entry;
private readonly string m_Entry;
private bool m_Valid;
@ -249,7 +247,7 @@ namespace Server
public bool IsBlocked(IPAddress address)
{
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);
m_Valid = valid;
@ -268,7 +266,5 @@ namespace Server
public override int GetHashCode() => m_Entry.GetHashCode();
}
#endregion
}
}

View file

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

View file

@ -9,20 +9,20 @@ namespace Server.Commands
{
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 object[] m_ParseArgs = new object[1];
private static readonly Type[] m_ParseTypes = { typeof(string) };
private static readonly object[] m_ParseArgs = new object[1];
private static Type[] m_SignedNumerics =
private static readonly Type[] m_SignedNumerics =
{
typeof(long),
typeof(int),
@ -30,7 +30,7 @@ namespace Server.Commands
typeof(sbyte)
};
private static Type[] m_UnsignedNumerics =
private static readonly Type[] m_UnsignedNumerics =
{
typeof(ulong),
typeof(uint),
@ -198,7 +198,6 @@ namespace Server.Commands
if (!paramList[j].HasDefaultValue)
totalParams += 1;
if (args.Length >= totalParams && args.Length <= paramList.Length)
{
object[] paramValues = ParseValues(paramList, args);
@ -348,23 +347,23 @@ namespace Server.Commands
int z = start.Z;
for (int x = start.X; x <= end.X; ++x)
for (int y = start.Y; y <= end.Y; ++y)
{
if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y)
continue;
for (int y = start.Y; y <= end.Y; ++y)
{
if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y)
continue;
if (mapAvg)
z = map.GetAverageZ(x, y);
if (mapAvg)
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)
item.MoveToWorld(new Point3D(x, y, z), map);
else if (built is Mobile m)
m.MoveToWorld(new Point3D(x, y, z), map);
}
if (built is Item item)
item.MoveToWorld(new Point3D(x, y, z), map);
else if (built is Mobile m)
m.MoveToWorld(new Point3D(x, y, z), map);
}
}
CommandLogging.WriteLine(from, sb.ToString());
@ -433,15 +432,15 @@ namespace Server.Commands
switch (ts.m_ZType)
{
case TileZType.Fixed:
{
start.Z = end.Z = ts.m_FixedZ;
break;
}
{
start.Z = end.Z = ts.m_FixedZ;
break;
}
case TileZType.MapAverage:
{
mapAvg = true;
break;
}
{
mapAvg = true;
break;
}
}
Invoke(from, start, end, ts.m_Args, null, ts.m_Outline, mapAvg);
@ -667,10 +666,10 @@ namespace Server.Commands
private class TileState
{
public string[] m_Args;
public int m_FixedZ;
public bool m_Outline;
public TileZType m_ZType;
public readonly string[] m_Args;
public readonly int m_FixedZ;
public readonly bool m_Outline;
public readonly TileZType m_ZType;
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 string Usage{ get; }
public string Usage { get; }
}
public class DescriptionAttribute : Attribute
{
public DescriptionAttribute(string description) => Description = description;
public string Description{ get; }
public string Description { get; }
}
public class AliasesAttribute : Attribute
{
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;
}
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)
{
@ -180,9 +180,9 @@ namespace Server.Commands
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)
{
@ -199,15 +199,15 @@ namespace Server.Commands
{
argString = "";
command = Command.ToLower();
args = new string[0];
args = Array.Empty<string>();
}
}
}
public class BatchGump : BaseGridGump
{
private Batch m_Batch;
private Mobile m_From;
private readonly Batch m_Batch;
private readonly Mobile m_From;
public BatchGump(Mobile from, Batch batch) : base(30, 30)
{
@ -326,28 +326,28 @@ namespace Server.Commands
switch (type)
{
case 0: // main
{
switch (index)
{
case 0: // run
switch (index)
{
m_Batch.Run(m_From);
break;
case 0: // run
{
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));
@ -356,8 +356,8 @@ namespace Server.Commands
public class BatchScopeGump : BaseGridGump
{
private Batch m_Batch;
private Mobile m_From;
private readonly Batch m_Batch;
private readonly Mobile m_From;
public BatchScopeGump(Mobile from, Batch batch) : base(30, 30)
{
@ -399,17 +399,17 @@ namespace Server.Commands
switch (type)
{
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)
m_Batch.Scope = impl;
if (m_From.AccessLevel >= impl.AccessLevel)
m_Batch.Scope = impl;
}
break;
}
break;
}
}
m_From.SendGump(new BatchGump(m_From, m_Batch));

View file

@ -14,10 +14,10 @@ namespace Server
private class PickTarget : Target
{
private BoundingBoxCallback m_Callback;
private bool m_First;
private Map m_Map;
private Point3D m_Store;
private readonly BoundingBoxCallback m_Callback;
private readonly bool m_First;
private readonly Map m_Map;
private readonly Point3D m_Store;
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)
.Where(prop => prop.CanRead && prop.CanWrite).ToArray();

View file

@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using Server.Engines.Quests.Haven;
using Server.Engines.Quests.Necro;
using Server.Items;
@ -12,7 +10,7 @@ using Server.Utilities;
namespace Server.Commands
{
public class Decorate
public static class Decorate
{
private static Mobile m_Mobile;
private static int m_Count;
@ -60,22 +58,22 @@ namespace Server.Commands
public class DecorationList
{
private static Type typeofStatic = typeof(Static);
private static Type typeofLocalizedStatic = typeof(LocalizedStatic);
private static Type typeofBaseDoor = typeof(BaseDoor);
private static Type typeofAnkhWest = typeof(AnkhWest);
private static Type typeofAnkhNorth = typeof(AnkhNorth);
private static Type typeofBeverage = typeof(BaseBeverage);
private static Type typeofLocalizedSign = typeof(LocalizedSign);
private static Type typeofMarkContainer = typeof(MarkContainer);
private static Type typeofWarningItem = typeof(WarningItem);
private static Type typeofHintItem = typeof(HintItem);
private static Type typeofCannon = typeof(Cannon);
private static Type typeofSerpentPillar = typeof(SerpentPillar);
private static readonly Type typeofStatic = typeof(Static);
private static readonly Type typeofLocalizedStatic = typeof(LocalizedStatic);
private static readonly Type typeofBaseDoor = typeof(BaseDoor);
private static readonly Type typeofAnkhWest = typeof(AnkhWest);
private static readonly Type typeofAnkhNorth = typeof(AnkhNorth);
private static readonly Type typeofBeverage = typeof(BaseBeverage);
private static readonly Type typeofLocalizedSign = typeof(LocalizedSign);
private static readonly Type typeofMarkContainer = typeof(MarkContainer);
private static readonly Type typeofWarningItem = typeof(WarningItem);
private static readonly Type typeofHintItem = typeof(HintItem);
private static readonly Type typeofCannon = typeof(Cannon);
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 int m_ItemID;
private string[] m_Params;
@ -934,14 +932,13 @@ namespace Server.Commands
for (int j = 0; j < maps.Length; ++j)
{
try
{
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;
}
@ -1083,11 +1080,11 @@ namespace Server.Commands
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(' ');

View file

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

View file

@ -243,7 +243,7 @@ namespace Server.Commands
nameBuilder.Append(sanitizedName);
fnamBuilder.Append("T");
if (DontLink(typeArguments[i])) //if ( DontLink( typeArguments[i].Name ) )
if (DontLink(typeArguments[i]))
linkBuilder.Append($"<font color=\"blue\">{aliasedName}</font>");
else
linkBuilder.Append(
@ -270,7 +270,7 @@ namespace Server.Commands
else
linkName = link;
//Console.WriteLine( typeName+":"+fileName+":"+linkName );
// Console.WriteLine( typeName+":"+fileName+":"+linkName );
}
public static string SanitizeType(string name)
@ -312,7 +312,7 @@ namespace Server.Commands
public static bool DontLink( string name )
{
foreach( string dontLink in m_DontLink )
if ( dontLink == name ) return true;
if (dontLink == name ) return true;
return false;
}
*/
@ -416,9 +416,13 @@ namespace Server.Commands
private class TypeInfo
{
public List<TypeInfo> m_Derived, m_Nested;
private string m_FileName, m_TypeName, m_LinkName;
public Type[] m_Interfaces;
public Type m_Type, m_BaseType, m_Declaring;
private readonly string m_FileName;
private readonly string m_TypeName;
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)
{
@ -437,8 +441,6 @@ namespace Server.Commands
public string LinkName(string dirRoot) => m_LinkName.Replace("@directory@", dirRoot);
}
#region FileSystem
private static readonly char[] ReplaceChars = "<>".ToCharArray();
public static string GetFileName(string root, string name, string ext)
@ -460,7 +462,7 @@ namespace Server.Commands
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)
{
@ -482,11 +484,7 @@ namespace Server.Commands
private static StreamWriter GetWriter(string path) => new StreamWriter(Path.Combine(m_RootDirectory, path));
#endregion
#region GetPair
private static string[,] m_Aliases =
private static readonly string[,] m_Aliases =
{
{ "System.Object", "<font color=\"blue\">object</font>" },
{ "System.String", "<font color=\"blue\">string</font>" },
@ -506,7 +504,7 @@ namespace Server.Commands
{ "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)
{
@ -600,10 +598,6 @@ namespace Server.Commands
return string.Concat(prepend, aliased, append, name);
}
#endregion
#region Root documentation
private static bool Document()
{
try
@ -634,7 +628,6 @@ namespace Server.Commands
List<Assembly> assemblies = new List<Assembly> { Core.Assembly };
foreach (Assembly asm in AssemblyHandler.Assemblies)
assemblies.Add(asm);
@ -713,10 +706,6 @@ namespace Server.Commands
html.WriteLine("</html>");
}
#endregion
#region BODs
private const int Iron = 0xCCCCDD;
private const int DullCopper = 0xAAAAAA;
private const int ShadowIron = 0x777799;
@ -763,7 +752,6 @@ namespace Server.Commands
html.WriteLine(" <br><br>");
html.WriteLine(" <br><br>");
sbod.Type = typeof(PlateArms);
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,
bool expandPlain)
{
@ -1221,20 +1207,20 @@ namespace Server.Commands
switch (material)
{
case BulkMaterialType.None:
{
if (type.IsSubclassOf(typeof(BaseArmor)) || type.IsSubclassOf(typeof(BaseShoes)))
{
style = "pl";
name = "Plain";
}
else
{
style = "cl";
name = "Cloth";
}
if (type.IsSubclassOf(typeof(BaseArmor)) || type.IsSubclassOf(typeof(BaseShoes)))
{
style = "pl";
name = "Plain";
}
else
{
style = "cl";
name = "Cloth";
}
break;
}
break;
}
case BulkMaterialType.Spined:
style = "sp";
name = "Spined";
@ -1281,10 +1267,6 @@ namespace Server.Commands
html.WriteLine(" </tr>");
}
#endregion
#region Smith Bods
private static void WriteSmithLBOD(StreamWriter html, string name, SmallBulkEntry[] entries)
{
LargeBOD lbod = new LargeSmithBOD();
@ -1564,12 +1546,6 @@ namespace Server.Commands
html.WriteLine(" </tr>");
}
#endregion
#endregion
#region Bodies
public static List<BodyEntry> LoadBodies()
{
List<BodyEntry> list = new List<BodyEntry>();
@ -1689,10 +1665,6 @@ namespace Server.Commands
html.WriteLine("</html>");
}
#endregion
#region Speech
private static void DocumentKeywords()
{
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);
entry.Strings.Sort(); //( new EnglishPrioStringSorter() );
entry.Strings.Sort(); // ( new EnglishPrioStringSorter() );
for (int j = 0; j < entry.Strings.Count; ++j)
{
@ -1776,9 +1748,9 @@ namespace Server.Commands
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>
@ -1833,10 +1805,6 @@ namespace Server.Commands
return tables;
}
#endregion
#region Commands
public class DocCommandEntry
{
public DocCommandEntry(AccessLevel accessLevel, string name, string[] aliases, string usage, string description)
@ -1848,15 +1816,15 @@ namespace Server.Commands
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>
@ -2112,12 +2080,10 @@ namespace Server.Commands
html.WriteLine("</tr>");
}
#endregion
#region Constructible Objects
private static Type typeofItem = typeof(Item), typeofMobile = typeof(Mobile), typeofMap = typeof(Map);
private static Type typeofCustomEnum = typeof(CustomEnumAttribute);
private static readonly Type typeofItem = typeof(Item);
private static readonly Type typeofMobile = typeof(Mobile);
private static readonly Type typeofMap = typeof(Map);
private static readonly Type typeofCustomEnum = typeof(CustomEnumAttribute);
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>");
}
#endregion
#region Tooltips
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(sbyte), "Numeric value in the range from negative 128 to positive 127, inclusive." },
@ -2319,10 +2281,6 @@ namespace Server.Commands
return "";
}
#endregion
#region Const Strings
private const string RefString = "<font color=\"blue\">ref</font> ";
private const string GetString = " <font color=\"blue\">get</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 StaticString = "(<font color=\"blue\">static</font>) ";
#endregion
#region Write[...]
private static void WriteEnum(TypeInfo info, StreamWriter typeHtml)
{
Type type = info.m_Type;
@ -2381,7 +2335,7 @@ namespace Server.Commands
if (decInfo == null)
typeHtml.Write(decType.Name);
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(") - ");
@ -2452,7 +2406,7 @@ namespace Server.Commands
if (i != 0)
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)}");
}
@ -2474,7 +2428,7 @@ namespace Server.Commands
if (i != 0)
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)}");
}
@ -2600,12 +2554,8 @@ namespace Server.Commands
html.WriteLine(")<br>");
}
#endregion
}
#region BodyEntry & BodyType
public enum ModelBodyType
{
Invalid = -1,
@ -2625,11 +2575,11 @@ namespace Server.Commands
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)
{
@ -2657,6 +2607,4 @@ namespace Server.Commands
return a?.Name.CompareTo(b?.Name) ?? 1;
}
}
#endregion
}

View file

@ -1,8 +1,8 @@
using System;
using System.Reflection;
using Server.Items;
using Server.Targeting;
using Server.Utilities;
using System;
using System.Reflection;
namespace Server.Commands
{
@ -48,14 +48,14 @@ namespace Server.Commands
}
catch
{
//Console.WriteLine( "Denied" );
// Console.WriteLine( "Denied" );
}
}
private class DupeTarget : Target
{
private int m_Amount;
private bool m_InBag;
private readonly int m_Amount;
private readonly bool m_InBag;
public DupeTarget(bool inbag, int amount)
: base(15, false, TargetFlags.None)
@ -103,7 +103,7 @@ namespace Server.Commands
for (int i = 0; i < m_Amount; i++)
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);
newItem.Parent = null;

View file

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

View file

@ -13,9 +13,9 @@ namespace Server.Commands
{
private static CategoryEntry m_RootItems, m_RootMobiles;
private static Type typeofItem = typeof(Item);
private static Type typeofMobile = typeof(Mobile);
private static Type typeofConstructible = typeof(ConstructibleAttribute);
private static readonly Type typeofItem = typeof(Item);
private static readonly Type typeofMobile = typeof(Mobile);
private static readonly Type typeofConstructible = typeof(ConstructibleAttribute);
public static CategoryEntry Items
{
@ -275,9 +275,9 @@ namespace Server.Commands
Object = ActivatorUtil.CreateInstance(type);
}
public Type Type{ get; }
public Type Type { get; }
public object Object{ get; }
public object Object { get; }
}
public class CategoryEntry
@ -286,8 +286,8 @@ namespace Server.Commands
{
Parent = parent;
Title = title;
SubCategories = subCats ?? new CategoryEntry[0];
Matches = new Type[0];
SubCategories = subCats ?? Array.Empty<CategoryEntry>();
Matches = Array.Empty<Type>();
Matched = new List<CategoryTypeEntry>();
}
@ -342,15 +342,15 @@ namespace Server.Commands
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)
{
@ -380,9 +380,9 @@ namespace Server.Commands
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)
{

View file

@ -1,10 +1,10 @@
using Server.Items;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
using Server.Items;
using Server.Json;
namespace Server.Commands
@ -122,7 +122,7 @@ namespace Server.Commands
public int Count { 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)
{

View file

@ -12,22 +12,22 @@ namespace Server.Commands.Generic
public abstract class BaseCommand
{
private List<MessageEntry> m_Responses = new List<MessageEntry>();
private List<MessageEntry> m_Failures = new List<MessageEntry>();
private readonly List<MessageEntry> m_Responses = 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)
{
@ -117,7 +117,7 @@ namespace Server.Commands.Generic
private class MessageEntry
{
public int m_Count;
public string m_Message;
public readonly string m_Message;
public MessageEntry(string message)
{

View file

@ -14,7 +14,7 @@ namespace Server.Commands.Generic
{
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()
{
@ -348,7 +348,7 @@ namespace Server.Commands.Generic
public class TellCommand : BaseCommand
{
private bool m_InGump;
private readonly bool m_InGump;
public TellCommand(bool inGump)
{
@ -511,7 +511,7 @@ namespace Server.Commands.Generic
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 toLoc = new Point3D(p);
@ -683,8 +683,8 @@ namespace Server.Commands.Generic
public class AliasedSetCommand : BaseCommand
{
private string m_Name;
private string m_Value;
private readonly string m_Name;
private readonly string m_Value;
public AliasedSetCommand(AccessLevel level, string command, string name, string value, ObjectTypes objects)
{
@ -830,7 +830,7 @@ namespace Server.Commands.Generic
public class KillCommand : BaseCommand
{
private bool m_Value;
private readonly bool m_Value;
public KillCommand(bool value)
{
@ -916,7 +916,7 @@ namespace Server.Commands.Generic
public class HideCommand : BaseCommand
{
private bool m_Value;
private readonly bool m_Value;
public HideCommand(bool value)
{
@ -1011,7 +1011,7 @@ namespace Server.Commands.Generic
public class KickCommand : BaseCommand
{
private bool m_Ban;
private readonly bool m_Ban;
public KickCommand(bool ban)
{

View file

@ -35,7 +35,7 @@ namespace Server.Commands.Generic
{
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;
house = BaseHouse.FindHouseAt(item) as HouseFoundation;
@ -69,8 +69,6 @@ namespace Server.Commands.Generic
return true;
}
#region Single targeting mode
public override void Execute(CommandEventArgs e, object obj)
{
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 List<HouseFoundation> m_Foundations;
private bool m_StaticsOnly;
private readonly List<HouseFoundation> m_Foundations;
private readonly bool m_StaticsOnly;
public DesignInsertTarget(List<HouseFoundation> foundations, bool staticsOnly)
: base(-1, false, TargetFlags.None)
@ -107,39 +105,35 @@ namespace Server.Commands.Generic
switch (result)
{
case DesignInsertResult.Valid:
{
if (m_Foundations.Count == 0)
from.SendMessage(
"The item has been inserted into the house design. Press ESC when you are finished.");
else
from.SendMessage("The item has been inserted into the house design.");
{
if (m_Foundations.Count == 0)
from.SendMessage(
"The item has been inserted into the house design. Press ESC when you are finished.");
else
from.SendMessage("The item has been inserted into the house design.");
if (!m_Foundations.Contains(house))
m_Foundations.Add(house);
if (!m_Foundations.Contains(house))
m_Foundations.Add(house);
break;
}
break;
}
case DesignInsertResult.InvalidItem:
{
from.SendMessage("That cannot be inserted. Try again.");
break;
}
{
from.SendMessage("That cannot be inserted. Try again.");
break;
}
case DesignInsertResult.NotInHouse:
case DesignInsertResult.OutsideHouseBounds:
{
from.SendMessage("That item is not inside a customizable house. Try again.");
break;
}
{
from.SendMessage("That item is not inside a customizable house. Try again.");
break;
}
}
from.Target = new DesignInsertTarget(m_Foundations, m_StaticsOnly);
}
}
#endregion
#region Area targeting mode
public override void ExecuteList(CommandEventArgs e, List<object> list)
{
Mobile from = e.Mobile;
@ -165,25 +159,25 @@ namespace Server.Commands.Generic
switch (result)
{
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))
foundations.Add(house);
if (!foundations.Contains(house))
foundations.Add(house);
break;
}
break;
}
case DesignInsertResult.InvalidItem:
{
LogFailure("That cannot be inserted.");
break;
}
{
LogFailure("That cannot be inserted.");
break;
}
case DesignInsertResult.NotInHouse:
case DesignInsertResult.OutsideHouseBounds:
{
LogFailure("That item is not inside a customizable house.");
break;
}
{
LogFailure("That item is not inside a customizable house.");
break;
}
}
}
@ -197,7 +191,5 @@ namespace Server.Commands.Generic
Flush(from, flushToLog);
}
#endregion
}
}

View file

@ -25,7 +25,6 @@ namespace Server.Commands.Generic
{
List<string> columns = new List<string> { "Object" };
if (e.Length > 0)
{
int offset = 0;
@ -50,13 +49,13 @@ namespace Server.Commands.Generic
{
private const int EntriesPerPage = 15;
private string[] m_Columns;
private Mobile m_From;
private readonly string[] m_Columns;
private readonly Mobile m_From;
private List<object> m_List;
private int m_Page;
private readonly List<object> m_List;
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)
{
@ -197,57 +196,57 @@ namespace Server.Commands.Generic
switch (info.ButtonID)
{
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.
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Select));
break;
object obj = m_List[v];
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)
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;
}
break;
}
}
}
}
public class InterfaceItemGump : BaseGridGump
{
private string[] m_Columns;
private Mobile m_From;
private readonly string[] m_Columns;
private readonly Mobile m_From;
private Item m_Item;
private readonly Item m_Item;
private List<object> m_List;
private int m_Page;
private readonly List<object> m_List;
private readonly int m_Page;
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 1:
{
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
break;
}
{
m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
break;
}
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.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
{
private string[] m_Columns;
private Mobile m_From;
private readonly string[] m_Columns;
private readonly Mobile m_From;
private List<object> m_List;
private readonly List<object> m_List;
private Mobile m_Mobile;
private int m_Page;
private readonly Mobile m_Mobile;
private readonly int m_Page;
public InterfaceMobileGump(Mobile from, string[] columns, List<object> list, int page, Mobile mob)
: base(30, 30)
@ -482,86 +481,86 @@ namespace Server.Commands.Generic
{
case 0:
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));
break;
}
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
case 2: // Properties
{
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;
}
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)
case 3: // Delete
{
m_Mobile.PlaySound(0x214);
m_Mobile.FixedEffect(0x376A, 10, 16);
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_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
{
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)
m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState));
if (m_Mobile.NetState != null)
m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState));
break;
}
break;
}
}
}
}

View file

@ -17,18 +17,18 @@ namespace Server.Commands.Generic
Constructor = constructor;
}
public static Dictionary<string, ExtensionInfo> Table{ get; } =
public static Dictionary<string, ExtensionInfo> Table { get; } =
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 ExtensionConstructor Constructor{ get; }
public ExtensionConstructor Constructor { get; }
public static void Register(ExtensionInfo ext)
{
@ -103,7 +103,7 @@ namespace Server.Commands.Generic
public abstract class BaseExtension
{
public abstract ExtensionInfo Info{ get; }
public abstract ExtensionInfo Info { get; }
public string Name => Info.Name;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -32,19 +32,19 @@ namespace Server.Commands.Generic
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
{
@ -110,43 +110,43 @@ namespace Server.Commands.Generic
{
case ObjectTypes.All:
case ObjectTypes.Both:
{
if (condIsItem)
items = true;
{
if (condIsItem)
items = true;
if (condIsMobile)
mobiles = true;
if (condIsMobile)
mobiles = true;
break;
}
break;
}
case ObjectTypes.Items:
{
if (condIsItem)
{
items = true;
}
else if (condIsMobile)
{
from.SendMessage("You may not use a mobile type condition for this command.");
return false;
}
if (condIsItem)
{
items = true;
}
else if (condIsMobile)
{
from.SendMessage("You may not use a mobile type condition for this command.");
return false;
}
break;
}
break;
}
case ObjectTypes.Mobiles:
{
if (condIsMobile)
{
mobiles = true;
}
else if (condIsItem)
{
from.SendMessage("You may not use an item type condition for this command.");
return false;
}
if (condIsMobile)
{
mobiles = true;
}
else if (condIsItem)
{
from.SendMessage("You may not use an item type condition for this command.");
return false;
}
break;
}
break;
}
}
return true;
@ -199,8 +199,8 @@ namespace Server.Commands.Generic
public void RunCommand(Mobile from, object obj, BaseCommand command, string[] args)
{
// try
// {
// try
// {
CommandEventArgs e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args);
if (!command.ValidateArgs(this, e))
@ -226,17 +226,17 @@ namespace Server.Commands.Generic
else if (obj != null)
{
if (command.ListOptimized)
command.ExecuteList(e, new List<object>{ obj });
command.ExecuteList(e, new List<object> { obj });
else
command.Execute(e, obj);
}
command.Flush(from, flushToLog);
// }
// catch ( Exception ex )
// {
// from.SendMessage( ex.Message );
// }
// }
// catch ( Exception ex )
// {
// from.SendMessage( ex.Message );
// }
}
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.");
return;
}
try
{
Extensions ext = Extensions.Parse(from, ref args);

View file

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

View file

@ -12,7 +12,7 @@ namespace Server.Commands.Generic
private IConditional[] m_Conditionals;
private ICondition[][] m_Conditions;
private readonly ICondition[][] m_Conditions;
public ObjectConditional(Type objectType, ICondition[][] conditions)
{
@ -20,7 +20,7 @@ namespace Server.Commands.Generic
m_Conditions = conditions;
}
public Type Type{ get; }
public Type Type { get; }
public bool IsItem => Type == null || Type == typeofItem || Type.IsSubclassOf(typeofItem);

View file

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

View file

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

View file

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

View file

@ -287,7 +287,7 @@ namespace Server.Commands
foreach (Mobile m in World.Mobiles.Values)
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);
if (pets.Count > 0)
@ -408,7 +408,7 @@ namespace Server.Commands
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)
{
@ -782,7 +782,7 @@ namespace Server.Commands
private class EquipMenu : ItemListMenu
{
private Mobile m_Mobile;
private readonly Mobile m_Mobile;
public EquipMenu(Mobile from, Mobile m, ItemListEntry[] entries) : base("Equipment", entries)
{
@ -804,8 +804,8 @@ namespace Server.Commands
private class EquipDetailsMenu : QuestionMenu
{
private Item m_Item;
private Mobile m_Mobile;
private readonly Item m_Item;
private readonly Mobile m_Mobile;
public EquipDetailsMenu(Mobile m, Item item) : base($"{item.Layer}: {item.GetType().Name}",
new[] { "Move", "Delete", "Props" })

View file

@ -11,9 +11,9 @@ namespace Server.Commands
{
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)]
public static void Initialize()
@ -106,7 +106,6 @@ namespace Server.Commands
}
}
for (int i = 0; i < TargetCommands.AllCommands.Count; ++i)
{
BaseCommand command = TargetCommands.AllCommands[i];
@ -221,9 +220,9 @@ namespace Server.Commands
public class CommandListGump : BaseGridGump
{
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)
: base(30, 30)
@ -290,51 +289,50 @@ namespace Server.Commands
switch (info.ButtonID)
{
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];
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));
}
m.CloseGump<CommandInfoGump>();
break;
}
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 CommandInfoGump(CommandInfo info, int width = 320, int height = 200)
@ -344,13 +342,13 @@ namespace Server.Commands
AddBackground(0, 0, width, height, 5054);
//AddImageTiled( 10, 10, width - 20, 20, 2624 );
//AddAlphaRegion( 10, 10, width - 20, 20 );
//AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false );
// AddImageTiled( 10, 10, width - 20, 20, 2624 );
// AddAlphaRegion( 10, 10, width - 20, 20 );
// AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false );
AddHtml(10, 10, width - 20, 20, Color(Center(info.Name), 0xFF0000));
//AddImageTiled( 10, 40, width - 20, height - 80, 2624 );
//AddAlphaRegion( 10, 40, width - 20, height - 80 );
// AddImageTiled( 10, 40, width - 20, height - 80, 2624 );
// AddAlphaRegion( 10, 40, width - 20, height - 80 );
StringBuilder sb = new StringBuilder();
@ -384,8 +382,8 @@ namespace Server.Commands
AddHtml(10, 40, width - 20, height - 80, sb.ToString(), false, true);
//AddImageTiled( 10, height - 30, width - 20, 20, 2624 );
//AddAlphaRegion( 10, height - 30, width - 20, 20 );
// AddImageTiled( 10, height - 30, width - 20, 20, 2624 );
// AddAlphaRegion( 10, height - 30, width - 20, 20 );
}
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.Globalization;
using Server.Commands.Generic;
using Server.Items;
using Server.Targeting;
using System.Globalization;
namespace Server.Commands
{
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()
{

View file

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

View file

@ -6,7 +6,7 @@ using Server.Diagnostics;
namespace Server.Commands
{
public class Profiling
public static class Profiling
{
public static void Initialize()
{
@ -168,10 +168,10 @@ namespace Server.Commands
if ((flags & ExpandFlag.Blessed) != 0)
++countTable[4];
/*if ( ( flags & ExpandFlag.TempFlag ) != 0 )
/*if (( flags & ExpandFlag.TempFlag ) != 0)
++countTable[5];
if ( ( flags & ExpandFlag.SaveFlag ) != 0 )
if (( flags & ExpandFlag.SaveFlag ) != 0)
++countTable[6];*/
if ((flags & ExpandFlag.Weight) != 0)
@ -243,7 +243,8 @@ namespace Server.Commands
{
parms[0]++;
parms[1] += item.Amount;
} else
}
else
table[type] = new[] { 1, item.Amount };
}

View file

@ -18,25 +18,25 @@ namespace Server.Commands
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 Type typeofParsable = typeof(ParsableAttribute);
private static readonly Type typeofTimeSpan = typeof(TimeSpan);
private static readonly Type typeofParsable = typeof(ParsableAttribute);
private static Type[] m_ParseTypes = { typeof(string) };
private static object[] m_ParseParams = new object[1];
private static readonly Type[] m_ParseTypes = { typeof(string) };
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(short), typeof(ushort),
@ -602,8 +602,8 @@ namespace Server
{
}
public AccessLevel PlayerAccess{ get; set; }
public AccessLevel NeededAccess{ get; set; }
public AccessLevel PlayerAccess { get; set; }
public AccessLevel NeededAccess { get; set; }
}
public sealed class ReadAccessException : ClearanceException
@ -630,11 +630,11 @@ namespace Server
public Property(PropertyInfo[] chain) => m_Chain = chain;
public string Binding{ get; }
public string Binding { get; }
public bool IsBound => m_Chain != null;
public PropertyAccess Access{ get; private set; }
public PropertyAccess Access { get; private set; }
public PropertyInfo[] Chain
{

View file

@ -6,7 +6,7 @@ namespace Server.Commands
{
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()
{
@ -119,10 +119,10 @@ namespace Server.Commands
private class SignEntry
{
public int m_ItemID;
public Point3D m_Location;
public int m_Map;
public string m_Text;
public readonly int m_ItemID;
public readonly Point3D m_Location;
public readonly int m_Map;
public readonly string m_Text;
public SignEntry(string text, Point3D pt, int itemID, int mapLoc)
{

View file

@ -58,7 +58,7 @@ namespace Server.Commands
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;
@ -82,9 +82,9 @@ namespace Server.Commands
public class SkillTarget : Target
{
private bool m_Set;
private SkillName m_Skill;
private double m_Value;
private readonly bool m_Set;
private readonly SkillName m_Skill;
private readonly double m_Value;
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. " +
"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;
@ -45,7 +45,7 @@ namespace Server
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")]
[Description("Makes a targeted area of dynamic items static.")]
@ -361,79 +361,79 @@ namespace Server
BinaryWriter mulWriter = new BinaryWriter(mulStream);
for (int x = xStartBlock; x <= xEndBlock; ++x)
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)
for (int y = yStartBlock; y <= yEndBlock; ++y)
{
StaticTile oldTile = oldTiles[i];
StaticTile[] oldTiles = ReadStaticBlock(idxReader, mulStream, x, y, matrix.BlockWidth,
matrix.BlockHeight, out int oldTileCount);
int px = baseX + oldTile.X;
int py = baseY + oldTile.Y;
if (oldTileCount < 0)
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)
@ -551,8 +551,9 @@ namespace Server
private class DeltaState
{
public List<Item> m_List;
public int m_X, m_Y;
public readonly List<Item> m_List;
public readonly int m_X;
public readonly int m_Y;
public DeltaState(Point2D p)
{

View file

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

View file

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

View file

@ -18,7 +18,7 @@ namespace Server.ContextMenus
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;

View file

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

View file

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

View file

@ -2,7 +2,7 @@ namespace Server.ContextMenus
{
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;

View file

@ -5,9 +5,9 @@ namespace Server.ContextMenus
{
public class TeachEntry : ContextMenuEntry
{
private Mobile m_From;
private BaseCreature m_Mobile;
private SkillName m_Skill;
private readonly Mobile m_From;
private readonly BaseCreature m_Mobile;
private readonly SkillName m_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
{
private BaseBOD m_Deed;
private readonly BaseBOD m_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)))
{
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;
}

View file

@ -12,9 +12,9 @@ namespace Server.Engines.BulkOrders
{
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);
random -= chances[i];
@ -41,30 +41,30 @@ namespace Server.Engines.BulkOrders
{
}
public abstract bool Complete{ get; }
public abstract bool Complete { get; }
[CommandProperty(AccessLevel.GameMaster)]
public sealed override int Hue{ get; set; }
public sealed override int Hue { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int AmountMax
{
get => m_AmountMax;
set{ m_AmountMax = value; InvalidateProperties(); }
set { m_AmountMax = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public bool RequireExceptional
{
get => m_RequireExceptional;
set{ m_RequireExceptional = value; InvalidateProperties(); }
set { m_RequireExceptional = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public BulkMaterialType Material
{
get => m_Material;
set{ m_Material = value; InvalidateProperties(); }
set { m_Material = value; InvalidateProperties(); }
}
public abstract RewardGroup GetRewardGroup();
@ -118,35 +118,35 @@ namespace Server.Engines.BulkOrders
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_RequireExceptional );
writer.Write( (int) m_Material );
writer.Write(m_AmountMax);
writer.Write(m_RequireExceptional);
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();
switch ( version )
switch (version)
{
case 0:
{
m_AmountMax = reader.ReadInt();
m_RequireExceptional = reader.ReadBool();
m_Material = (BulkMaterialType)reader.ReadInt();
break;
}
{
m_AmountMax = reader.ReadInt();
m_RequireExceptional = reader.ReadBool();
m_Material = (BulkMaterialType)reader.ReadInt();
break;
}
}
if ( Parent == null && Map == Map.Internal && Location == Point3D.Zero )
if (Parent == null && Map == Map.Internal && Location == Point3D.Zero)
Delete();
}
}

View file

@ -13,26 +13,26 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 1:
{
Type = reader.ReadEncodedInt();
Quality = reader.ReadEncodedInt();
Material = reader.ReadEncodedInt();
Quantity = reader.ReadEncodedInt();
{
Type = reader.ReadEncodedInt();
Quality = reader.ReadEncodedInt();
Material = reader.ReadEncodedInt();
Quantity = reader.ReadEncodedInt();
break;
}
break;
}
}
}
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()
{

View file

@ -8,7 +8,7 @@ namespace Server.Engines.BulkOrders
{
private const int LabelColor = 0x7FFF;
private static int[,] m_MaterialFilters =
private static readonly int[,] m_MaterialFilters =
{
{ 1044067, 1 }, // Blacksmithy
{ 1062226, 3 }, // Iron
@ -16,14 +16,12 @@ namespace Server.Engines.BulkOrders
{ 1018333, 5 }, // Shadow Iron
{ 1018334, 6 }, // Copper
{ 1018335, 7 }, // Bronze
{ 0, 0 }, // --Blank--
{ 1018336, 8 }, // Golden
{ 1018337, 9 }, // Agapite
{ 1018338, 10 }, // Verite
{ 1018339, 11 }, // Valorite
{ 0, 0 }, // --Blank--
{ 1044094, 2 }, // Tailoring
{ 1044286, 12 }, // Cloth
{ 1062235, 13 }, // Leather
@ -32,21 +30,21 @@ namespace Server.Engines.BulkOrders
{ 1062238, 16 } // Barbed
};
private static int[,] m_TypeFilters =
private static readonly int[,] m_TypeFilters =
{
{ 1062229, 0 }, // All
{ 1062224, 1 }, // Small
{ 1062225, 2 } // Large
};
private static int[,] m_QualityFilters =
private static readonly int[,] m_QualityFilters =
{
{ 1062229, 0 }, // All
{ 1011542, 1 }, // Normal
{ 1060636, 2 } // Exceptional
};
private static int[,] m_AmountFilters =
private static readonly int[,] m_AmountFilters =
{
{ 1062229, 0 }, // All
{ 1049706, 1 }, // 10
@ -54,7 +52,7 @@ namespace Server.Engines.BulkOrders
{ 1062239, 3 } // 20
};
private static int[][,] m_Filters =
private static readonly int[][,] m_Filters =
{
m_TypeFilters,
m_QualityFilters,
@ -62,15 +60,15 @@ namespace Server.Engines.BulkOrders
m_AmountFilters
};
private static int[] m_XOffsets_Type = { 0, 75, 170 };
private static int[] m_XOffsets_Quality = { 0, 75, 170 };
private static 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_Type = { 0, 75, 170 };
private static readonly int[] m_XOffsets_Quality = { 0, 75, 170 };
private static readonly int[] m_XOffsets_Amount = { 0, 75, 180, 275 };
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 int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 };
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private static readonly int[] m_XWidths_Small = { 50, 50, 70, 50 };
private static readonly int[] m_XWidths_Large = { 80, 50, 50, 50, 50, 50 };
private readonly BulkOrderBook m_Book;
private readonly PlayerMobile m_From;
public BOBFilterGump(PlayerMobile from, BulkOrderBook book) : base(12, 24)
{
@ -132,7 +130,7 @@ namespace Server.Engines.BulkOrders
continue;
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,
xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor);
@ -150,70 +148,70 @@ namespace Server.Engines.BulkOrders
switch (index)
{
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))
{
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;
}
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
{
private const int LabelColor = 0x7FFF;
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private List<IBOBEntry> m_List;
private readonly BulkOrderBook m_Book;
private readonly PlayerMobile m_From;
private readonly List<IBOBEntry> m_List;
private int m_Page;
@ -173,7 +173,7 @@ namespace Server.Engines.BulkOrders
if (canDrop)
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);
AddLabel(495, y, 1152, entry.Price.ToString());
@ -214,7 +214,7 @@ namespace Server.Engines.BulkOrders
if (canDrop)
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);
AddLabel(495, y, 1152, smallEntry.Price.ToString());
@ -281,22 +281,22 @@ namespace Server.Engines.BulkOrders
return f.Material switch
{
1 => (deedType == BODType.Smith),
2 => (deedType == BODType.Tailor),
3 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron),
4 => (mat == BulkMaterialType.DullCopper),
5 => (mat == BulkMaterialType.ShadowIron),
6 => (mat == BulkMaterialType.Copper),
7 => (mat == BulkMaterialType.Bronze),
8 => (mat == BulkMaterialType.Gold),
9 => (mat == BulkMaterialType.Agapite),
10 => (mat == BulkMaterialType.Verite),
11 => (mat == BulkMaterialType.Valorite),
12 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth),
13 => (mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather),
14 => (mat == BulkMaterialType.Spined),
15 => (mat == BulkMaterialType.Horned),
16 => (mat == BulkMaterialType.Barbed),
1 => deedType == BODType.Smith,
2 => deedType == BODType.Tailor,
3 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Iron,
4 => mat == BulkMaterialType.DullCopper,
5 => mat == BulkMaterialType.ShadowIron,
6 => mat == BulkMaterialType.Copper,
7 => mat == BulkMaterialType.Bronze,
8 => mat == BulkMaterialType.Gold,
9 => mat == BulkMaterialType.Agapite,
10 => mat == BulkMaterialType.Verite,
11 => mat == BulkMaterialType.Valorite,
12 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Cloth,
13 => mat == BulkMaterialType.None && BGTClassifier.Classify(deedType, itemType) == BulkGenericType.Leather,
14 => mat == BulkMaterialType.Spined,
15 => mat == BulkMaterialType.Horned,
16 => mat == BulkMaterialType.Barbed,
_ => true
};
}
@ -391,46 +391,45 @@ namespace Server.Engines.BulkOrders
return page;
}
public object GetMaterialName(BulkMaterialType mat, BODType type, Type itemType)
{
switch (type)
{
case BODType.Smith:
{
switch (mat)
{
case BulkMaterialType.None: return 1062226;
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:
switch (mat)
{
if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)))
return 1062235;
return 1044286;
case BulkMaterialType.None: return 1062226;
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;
}
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";
@ -443,148 +442,148 @@ namespace Server.Engines.BulkOrders
switch (index)
{
case 0: // EXIT
{
break;
}
{
break;
}
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
{
if (m_Page > 0)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List));
{
if (m_Page > 0)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List));
return;
}
return;
}
case 3: // Next page
{
if (GetIndexForPage(m_Page + 1) < m_List.Count)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List));
{
if (GetIndexForPage(m_Page + 1) < m_List.Count)
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page + 1, m_List));
break;
}
break;
}
case 4: // Price all
{
if (m_Book.IsChildOf(m_From.Backpack))
{
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:");
}
if (m_Book.IsChildOf(m_From.Backpack))
{
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:
{
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.
break;
}
index -= 5;
if (type == 0) // Drop
{
if (m_Book.IsChildOf(m_From.Backpack))
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))
{
Item item = bobEntry.Reconstruct();
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.
}
}
}
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
break;
}
}
else // Set Price | Buy
{
if (m_Book.IsChildOf(m_From.Backpack))
if (type == 0) // Drop
{
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);
if (vi?.IsForSale != false)
return;
int sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
int price = bobEntry.Price;
if (price == 0)
if (m_Book.IsChildOf(m_From.Backpack))
{
m_From.SendLocalizedMessage(1062382); // The deed selected is not available.
}
else
{
if (m_Book.Entries.Count > 0)
Item item = bobEntry.Reconstruct();
Container pack = m_From.Backpack;
if (pack?.CheckHold(m_From, item, true, true, 0,
item.PileWeight + item.TotalWeight) != true)
{
m_Page = GetPageForIndex(index, sizeOfDroppedBod);
m_From.SendGump(new BODBuyGump(m_From, m_Book, bobEntry, m_Page, price));
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
{
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 BulkOrderBook m_Book;
private List<IBOBEntry> m_List;
private IBOBEntry m_Entry;
private int m_Page;
private readonly BulkOrderBook m_Book;
private readonly List<IBOBEntry> m_List;
private readonly IBOBEntry m_Entry;
private readonly int m_Page;
public SetPricePrompt(BulkOrderBook book, IBOBEntry entry, int page, List<IBOBEntry> list)
{

View file

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

View file

@ -19,28 +19,28 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 0:
{
string type = reader.ReadString();
{
string type = reader.ReadString();
if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type);
if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type);
AmountCur = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt();
Number = 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)
{

View file

@ -28,45 +28,45 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 0:
{
string type = reader.ReadString();
{
string type = reader.ReadString();
if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type);
if (type != null)
ItemType = AssemblyHandler.FindFirstTypeForName(type);
RequireExceptional = reader.ReadBool();
RequireExceptional = reader.ReadBool();
DeedType = (BODType)reader.ReadEncodedInt();
DeedType = (BODType)reader.ReadEncodedInt();
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = reader.ReadEncodedInt();
Price = reader.ReadEncodedInt();
Material = (BulkMaterialType)reader.ReadEncodedInt();
AmountCur = reader.ReadEncodedInt();
AmountMax = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();
Graphic = 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()
{

View file

@ -7,11 +7,11 @@ namespace Server.Engines.BulkOrders
{
public class BODBuyGump : Gump
{
private BulkOrderBook m_Book;
private PlayerMobile m_From;
private IBOBEntry m_Entry;
private int m_Page;
private int m_Price;
private readonly BulkOrderBook m_Book;
private readonly PlayerMobile m_From;
private readonly IBOBEntry m_Entry;
private readonly int m_Page;
private readonly int m_Price;
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;
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public string 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 List<IBOBEntry> Entries { get; private set; }
@ -29,7 +29,7 @@ namespace Server.Engines.BulkOrders
public int ItemCount { get; set; }
[Constructible]
public BulkOrderBook() : base( 0x2259 )
public BulkOrderBook() : base(0x2259)
{
Weight = 1.0;
LootType = LootType.Blessed;
@ -40,89 +40,89 @@ namespace Server.Engines.BulkOrders
Level = SecureLevel.CoOwners;
}
public override void OnDoubleClick( Mobile from )
public override void OnDoubleClick(Mobile from)
{
if ( !from.InRange( GetWorldLocation(), 2 ) )
from.LocalOverheadMessage( Network.MessageType.Regular, 0x3B2, 1019045 ); // I can't reach that.
else if ( Entries.Count == 0 )
from.SendLocalizedMessage( 1062381 ); // The book is empty.
else if ( from is PlayerMobile mobile )
mobile.SendGump( new BOBGump( mobile, this ) );
if (!from.InRange(GetWorldLocation(), 2))
from.LocalOverheadMessage(Network.MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
else if (Entries.Count == 0)
from.SendLocalizedMessage(1062381); // The book is empty.
else if (from is PlayerMobile mobile)
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
{
from.SendGump( new BOBGump( (PlayerMobile)from, this ) );
from.SendGump(new BOBGump((PlayerMobile)from, this));
SecureTrade trade = GetSecureTradeCont()?.Trade;
if (trade?.From.Mobile == from )
trade.To.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.To.Mobile, this ) );
else if (trade?.To.Mobile == from )
trade.From.Mobile.SendGump( new BOBGump( (PlayerMobile)trade.From.Mobile, this ) );
if (trade?.From.Mobile == from)
trade.To.Mobile.SendGump(new BOBGump((PlayerMobile)trade.To.Mobile, this));
else if (trade?.To.Mobile == from)
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;
}
if ( !from.Backpack.CheckHold( from, dropped, true, true ) )
if (!from.Backpack.CheckHold(from, dropped, true, true))
return false;
if ( Entries.Count < 500 )
if (Entries.Count < 500)
{
if ( dropped is LargeBOD bod )
Entries.Add( new BOBLargeEntry( bod ) );
if (dropped is LargeBOD bod)
Entries.Add(new BOBLargeEntry(bod));
else
Entries.Add( new BOBSmallEntry( (SmallBOD)dropped ) );
Entries.Add(new BOBSmallEntry((SmallBOD)dropped));
InvalidateProperties();
if ( Entries.Count / 5 > ItemCount )
if (Entries.Count / 5 > ItemCount)
{
ItemCount++;
InvalidateItems();
}
from.SendSound(0x42, GetWorldLocation());
from.SendLocalizedMessage( 1062386 ); // Deed added to book.
from.SendLocalizedMessage(1062386); // Deed added to book.
if ( from is PlayerMobile pm )
pm.SendGump( new BOBGump( pm, this ) );
if (from is PlayerMobile pm)
pm.SendGump(new BOBGump(pm, this));
dropped.Delete();
return true;
}
from.SendLocalizedMessage( 1062387 ); // The book is full of deeds.
from.SendLocalizedMessage(1062387); // The book is full of deeds.
return false;
}
from.SendLocalizedMessage( 1062388 ); // That is not a bulk order deed.
from.SendLocalizedMessage(1062388); // That is not a bulk order deed.
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;
return total;
@ -130,111 +130,111 @@ namespace Server.Engines.BulkOrders
public void InvalidateItems()
{
if ( RootParent is Mobile m )
if (RootParent is Mobile m)
{
m.UpdateTotals();
InvalidateContainers( Parent );
InvalidateContainers(Parent);
}
}
public void InvalidateContainers(IEntity parent)
{
if ( parent is Container c )
if (parent is Container c)
{
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];
if ( obj is BOBLargeEntry entry )
if (obj is BOBLargeEntry entry)
{
writer.WriteEncodedInt( 0 );
entry.Serialize( writer );
writer.WriteEncodedInt(0);
entry.Serialize(writer);
}
else
{
writer.WriteEncodedInt( 1 );
((BOBSmallEntry)obj).Serialize( writer );
writer.WriteEncodedInt(1);
((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();
switch ( version )
switch (version)
{
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();
switch ( v )
{
case 0: Entries.Add( new BOBLargeEntry( reader ) ); break;
case 1: Entries.Add( new BOBSmallEntry( reader ) ); break;
}
ItemCount = reader.ReadInt();
goto case 1;
}
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) )
list.Add( 1062481, m_BookName ); // Book Name: ~1_val~
if (!string.IsNullOrEmpty(m_BookName))
list.Add(1062481, m_BookName); // Book Name: ~1_val~
}
public override void OnSingleClick(Mobile from)
@ -247,22 +247,22 @@ namespace Server.Engines.BulkOrders
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 ) )
list.Add( new NameBookEntry( from, this ) );
if (from.CheckAlive() && IsChildOf(from.Backpack))
list.Add(new NameBookEntry(from, this));
SetSecureLevelEntry.AddTo( from, this, list );
SetSecureLevelEntry.AddTo(from, this, list);
}
private class NameBookEntry : ContextMenuEntry
{
private Mobile m_From;
private BulkOrderBook m_Book;
private readonly Mobile m_From;
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_Book = book;
@ -270,34 +270,34 @@ namespace Server.Engines.BulkOrders
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.SendLocalizedMessage( 1062479 ); // Type in the new name of the book:
m_From.Prompt = new NameBookPrompt(m_Book);
m_From.SendLocalizedMessage(1062479); // Type in the new name of the book:
}
}
}
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 )
text = text.Substring( 0, 40 );
if (text.Length > 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
{
bool RequireExceptional{ get; }
BODType DeedType{ get; }
BulkMaterialType Material{ get; }
int AmountMax{ get; }
int Price{ get; set; }
bool RequireExceptional { get; }
BODType DeedType { get; }
BulkMaterialType Material { get; }
int AmountMax { get; }
int Price { get; set; }
Item Reconstruct();
}
}

View file

@ -9,16 +9,16 @@ namespace Server.Engines.BulkOrders
public LargeBulkEntry[] Entries
{
get => m_Entries;
set{ m_Entries = value; InvalidateProperties(); }
set { m_Entries = value; InvalidateProperties(); }
}
[CommandProperty( AccessLevel.GameMaster )]
[CommandProperty(AccessLevel.GameMaster)]
public override bool Complete
{
get
{
for ( int i = 0; i < m_Entries.Length; ++i )
if ( m_Entries[i].Amount < AmountMax )
for (int i = 0; i < m_Entries.Length; ++i)
if (m_Entries[i].Amount < AmountMax)
return false;
return true;
@ -27,48 +27,47 @@ namespace Server.Engines.BulkOrders
public override int LabelNumber => 1045151; // a bulk order deed
public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) :
base(hue, amountMax, requireExeptional, material) =>
public LargeBOD(int hue, int amountMax, bool requireExeptional, BulkMaterialType material, LargeBulkEntry[] entries) : base(hue, amountMax, requireExeptional, material) =>
m_Entries = entries;
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 )
list.Add( 1045141 ); // All items must be exceptional.
if (RequireExceptional)
list.Add(1045141); // All items must be exceptional.
if ( Material != BulkMaterialType.None )
list.Add( LargeBODGump.GetMaterialNumberFor( Material ) ); // All items must be made with x material.
if (Material != BulkMaterialType.None)
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 )
list.Add( 1060658 + i, "#{0}\t{1}", m_Entries[i].Details.Number, m_Entries[i].Amount ); // ~1_val~: ~2_val~
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~
}
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 )
from.SendGump( new LargeBODGump( from, this ) );
if (IsChildOf(from.Backpack) || InSecureTrade || RootParent is PlayerVendor)
from.SendGump(new LargeBODGump(from, this));
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)
@ -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 )
m_Entries[i].Serialize( writer );
for (int i = 0; i < m_Entries.Length; ++i)
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();
switch ( version )
switch (version)
{
case 0:
{
m_Entries = new LargeBulkEntry[reader.ReadInt()];
{
m_Entries = new LargeBulkEntry[reader.ReadInt()];
for ( int i = 0; i < m_Entries.Length; ++i )
m_Entries[i] = new LargeBulkEntry( this, reader );
for (int i = 0; i < m_Entries.Length; ++i)
m_Entries[i] = new LargeBulkEntry(this, reader);
break;
}
break;
}
}
}
}

View file

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

View file

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

View file

@ -12,88 +12,86 @@ namespace Server.Engines.BulkOrders
public int Amount
{
get => m_Amount;
set{ m_Amount = value; Owner?.InvalidateProperties(); }
set { m_Amount = value; Owner?.InvalidateProperties(); }
}
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;
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)
{
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[]>();
if (!table.TryGetValue( name, out SmallBulkEntry[] entries ))
if (!table.TryGetValue(name, out SmallBulkEntry[] entries))
table[name] = entries = SmallBulkEntry.LoadEntries(type, name);
return entries;
}
public static LargeBulkEntry[] ConvertEntries( LargeBOD owner, SmallBulkEntry[] small )
public static LargeBulkEntry[] ConvertEntries(LargeBOD owner, SmallBulkEntry[] small)
{
LargeBulkEntry[] large = new LargeBulkEntry[small.Length];
for ( int i = 0; i < small.Length; ++i )
large[i] = new LargeBulkEntry( owner, small[i] );
for (int i = 0; i < small.Length; ++i)
large[i] = new LargeBulkEntry(owner, small[i]);
return large;
}
public LargeBulkEntry( LargeBOD owner, SmallBulkEntry details )
public LargeBulkEntry(LargeBOD owner, SmallBulkEntry details)
{
Owner = owner;
Details = details;
}
public LargeBulkEntry( LargeBOD owner, IGenericReader reader )
public LargeBulkEntry(LargeBOD owner, IGenericReader reader)
{
Owner = owner;
m_Amount = reader.ReadInt();
@ -102,18 +100,18 @@ namespace Server.Engines.BulkOrders
string type = reader.ReadString();
if ( type != null )
realType = AssemblyHandler.FindFirstTypeForName( type );
if (type != null)
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( Details.Type?.FullName );
writer.Write( Details.Number );
writer.Write( Details.Graphic );
writer.Write(m_Amount);
writer.Write(Details.Type?.FullName);
writer.Write(Details.Number);
writer.Write(Details.Graphic);
}
}
}

View file

@ -41,7 +41,7 @@ namespace Server.Engines.BulkOrders
int hue = 0x44E;
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.None;

View file

@ -69,7 +69,7 @@ namespace Server.Engines.BulkOrders
int hue = 0x483;
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.None;

View file

@ -13,9 +13,9 @@ namespace Server.Engines.BulkOrders
Types = types;
}
public int Points{ get; }
public int Points { get; }
public Type[] Types{ get; }
public Type[] Types { get; }
public bool Contains(Type type)
{
@ -36,11 +36,11 @@ namespace Server.Engines.BulkOrders
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()
{
@ -63,9 +63,9 @@ namespace Server.Engines.BulkOrders
Items = items;
}
public int Points{ get; }
public int Points { get; }
public RewardItem[] Items{ get; }
public RewardItem[] Items { get; }
public RewardItem AcquireItem()
{
@ -97,7 +97,7 @@ namespace Server.Engines.BulkOrders
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,
Type type);
@ -165,7 +165,7 @@ namespace Server.Engines.BulkOrders
private static readonly ConstructCallback AncientHammer = CreateAncientHammer;
public static readonly SmithRewardCalculator Instance = new SmithRewardCalculator();
private static int[][][] m_GoldTable =
private static readonly int[][][] m_GoldTable =
{
new[] // 1-part (regular)
{
@ -253,7 +253,7 @@ namespace Server.Engines.BulkOrders
}
};
private RewardType[] m_Types =
private readonly RewardType[] m_Types =
{
// Armors
new RewardType(200, typeof(RingmailGloves), typeof(RingmailChest), typeof(RingmailArms), typeof(RingmailLegs)),
@ -264,7 +264,7 @@ namespace Server.Engines.BulkOrders
// Weapons
new RewardType(200, typeof(Bardiche), typeof(Halberd)),
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),
typeof(LargeBattleAxe), typeof(TwoHandedAxe)),
new RewardType(350, typeof(Broadsword), typeof(Cutlass), typeof(Katana), typeof(Longsword),
@ -379,8 +379,6 @@ namespace Server.Engines.BulkOrders
return Utility.RandomMinMax(min, max);
}
#region Constructors
private static Item CreateSturdyShovel(int type) => new SturdyShovel();
private static Item CreateSturdyPickaxe(int type) => new SturdyPickaxe();
@ -427,8 +425,6 @@ namespace Server.Engines.BulkOrders
throw new InvalidOperationException();
}
#endregion
}
public sealed class TailorRewardCalculator : RewardCalculator
@ -443,7 +439,7 @@ namespace Server.Engines.BulkOrders
private static readonly ConstructCallback ClothingBlessDeed = CreateCBD;
public static readonly TailorRewardCalculator Instance = new TailorRewardCalculator();
private static int[][][] m_AosGoldTable =
private static readonly int[][][] m_AosGoldTable =
{
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)
{
@ -612,7 +608,7 @@ namespace Server.Engines.BulkOrders
4 => 1,
_ => 0
} * 2 + (exceptional ? 1 : 0);
int quanIndex = quantity switch
{
20 => 2,
@ -636,9 +632,7 @@ namespace Server.Engines.BulkOrders
return Utility.RandomMinMax(min, max);
}
#region Constructors
private static int[][] m_ClothHues =
private static readonly int[][] m_ClothHues =
{
new[] { 0x483, 0x48C, 0x488, 0x48A },
new[] { 0x495, 0x48B, 0x486, 0x485 },
@ -659,7 +653,7 @@ namespace Server.Engines.BulkOrders
throw new InvalidOperationException();
}
private static int[] m_SandalHues =
private static readonly int[] m_SandalHues =
{
0x489, 0x47F, 0x482,
0x47E, 0x48F, 0x494,
@ -718,7 +712,5 @@ namespace Server.Engines.BulkOrders
}
private static Item CreateCBD(int type) => new ClothingBlessDeed();
#endregion
}
}

View file

@ -38,7 +38,7 @@ namespace Server.Engines.BulkOrders
}
[CommandProperty(AccessLevel.GameMaster)]
public Type Type{ get; set; }
public Type Type { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Number
@ -52,7 +52,7 @@ namespace Server.Engines.BulkOrders
}
[CommandProperty(AccessLevel.GameMaster)]
public int Graphic{ get; set; }
public int Graphic { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public override bool Complete => m_AmountCur == AmountMax;
@ -121,8 +121,8 @@ namespace Server.Engines.BulkOrders
from.SendLocalizedMessage(
1045166); // The maximum amount of requested items have already been combined to this deed.
}
else if (Type == null || objectType != Type && !objectType.IsSubclassOf(Type) ||
!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing))
else if (Type == null || (objectType != Type && !objectType.IsSubclassOf(Type)) ||
(!(item is BaseWeapon) && !(item is BaseArmor) && !(item is BaseClothing)))
{
from.SendLocalizedMessage(1045169); // The item is not in the request.
}
@ -194,18 +194,18 @@ namespace Server.Engines.BulkOrders
switch (version)
{
case 0:
{
m_AmountCur = reader.ReadInt();
{
m_AmountCur = reader.ReadInt();
string type = reader.ReadString();
string type = reader.ReadString();
if (type != null)
Type = AssemblyHandler.FindFirstTypeForName(type);
if (type != null)
Type = AssemblyHandler.FindFirstTypeForName(type);
m_Number = reader.ReadInt();
Graphic = reader.ReadInt();
break;
}
m_Number = reader.ReadInt();
Graphic = reader.ReadInt();
break;
}
}
}
}

View file

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

View file

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

View file

@ -12,66 +12,66 @@ namespace Server.Engines.BulkOrders
public int Graphic { get; }
public SmallBulkEntry( Type type, int number, int graphic )
public SmallBulkEntry(Type type, int number, int graphic)
{
Type = type;
Number = number;
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;
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[]>>();
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[]>();
if (!table.TryGetValue( name, out SmallBulkEntry[] entries ))
if (!table.TryGetValue(name, out SmallBulkEntry[] entries))
table[name] = entries = LoadEntries(type, name);
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>();
if ( File.Exists( path ) )
if (File.Exists(path))
{
using StreamReader ip = new StreamReader( path );
using StreamReader ip = new StreamReader(path);
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;
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] );
int graphic = Utility.ToInt32( split[split.Length - 1] );
Type type = AssemblyHandler.FindFirstTypeForName(split[0]);
int graphic = Utility.ToInt32(split[split.Length - 1]);
if ( type != null && graphic > 0 )
list.Add( new SmallBulkEntry( type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic ) );
if (type != null && graphic > 0)
list.Add(new SmallBulkEntry(type, graphic < 0x4000 ? 1020000 + graphic : 1078872 + graphic, graphic));
}
}
catch

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -109,16 +109,16 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 0:
{
m_Power = reader.ReadItem() as ChampionSkullBrazier;
m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier;
m_Venom = reader.ReadItem() as ChampionSkullBrazier;
m_Pain = reader.ReadItem() as ChampionSkullBrazier;
m_Greed = reader.ReadItem() as ChampionSkullBrazier;
m_Death = reader.ReadItem() as ChampionSkullBrazier;
{
m_Power = reader.ReadItem() as ChampionSkullBrazier;
m_Enlightenment = reader.ReadItem() as ChampionSkullBrazier;
m_Venom = reader.ReadItem() as ChampionSkullBrazier;
m_Pain = reader.ReadItem() as ChampionSkullBrazier;
m_Greed = 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 ChampionSpawnRegion m_Region;
//private int m_SpawnRange;
// private int m_SpawnRange;
private Rectangle2D m_SpawnArea;
private int m_SPawnSzMod;
@ -68,13 +68,13 @@ namespace Server.Engines.CannedEvil
}
[CommandProperty(AccessLevel.GameMaster)]
public bool ConfinedRoaming{ get; set; }
public bool ConfinedRoaming { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool HasBeenAdvanced{ get; set; }
public bool HasBeenAdvanced { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool RandomizeType{ get; set; }
public bool RandomizeType { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Kills
@ -100,16 +100,16 @@ namespace Server.Engines.CannedEvil
}
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan RestartDelay{ get; set; }
public TimeSpan RestartDelay { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime RestartTime{ get; private set; }
public DateTime RestartTime { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public TimeSpan ExpireDelay{ get; set; }
public TimeSpan ExpireDelay { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public DateTime ExpireTime{ get; set; }
public DateTime ExpireTime { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public ChampionSpawnType Type
@ -138,7 +138,7 @@ namespace Server.Engines.CannedEvil
}
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Champion{ get; set; }
public Mobile Champion { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public int Level
@ -173,7 +173,7 @@ namespace Server.Engines.CannedEvil
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));
}
@ -188,7 +188,7 @@ namespace Server.Engines.CannedEvil
}
/*
if ( m_Region == null )
if (m_Region == null)
{
m_Region = new ChampionSpawnRegion( this );
}
@ -307,8 +307,6 @@ namespace Server.Engines.CannedEvil
Start();
}
#region Scroll of Transcendence
private ScrollofTranscendence CreateRandomSoT(bool felucca)
{
int level = Utility.RandomMinMax(1, 5);
@ -319,11 +317,9 @@ namespace Server.Engines.CannedEvil
return ScrollofTranscendence.CreateRandom(level, level);
}
#endregion
public static void GiveScrollTo(Mobile killer, SpecialScroll scroll)
{
if (scroll == null || killer == null) //sanity
if (scroll == null || killer == null) // sanity
return;
if (scroll is ScrollofTranscendence)
@ -437,8 +433,6 @@ namespace Server.Engines.CannedEvil
if (killer is PlayerMobile pm)
{
#region Scroll of Transcendence
if (Core.ML)
{
if (Map == Map.Felucca)
@ -467,8 +461,6 @@ namespace Server.Engines.CannedEvil
}
}
#endregion
int mobSubLevel = GetSubLevelFor(m) + 1;
if (mobSubLevel >= 0)
@ -484,7 +476,7 @@ namespace Server.Engines.CannedEvil
else
m.SendLocalizedMessage(1054030); // You have gained in Valor!
//No delay on Valor gains
// No delay on Valor gains
}
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(1060660, "Kills\t{0} of {1} ({2:F1}%)", m_Kills, MaxKills,
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
{
@ -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.
}
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.Backpack?.CheckHold(m, Artifact, false) == true;
m.Backpack?.CheckHold(m, artifact, false) == true;
public override void Serialize(IGenericWriter writer)
{
@ -1013,7 +1005,7 @@ namespace Server.Engines.CannedEvil
writer.Write(RandomizeType);
// writer.Write( m_SpawnRange );
// writer.Write( m_SpawnRange );
writer.Write(m_Kills);
writer.Write(m_Active);
@ -1045,97 +1037,97 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 6:
{
m_SPawnSzMod = reader.ReadInt();
goto case 5;
}
{
m_SPawnSzMod = reader.ReadInt();
goto case 5;
}
case 5:
{
int entries = reader.ReadInt();
for (int i = 0; i < entries; ++i)
{
Mobile m = reader.ReadMobile();
int damage = reader.ReadInt();
int entries = reader.ReadInt();
for (int i = 0; i < entries; ++i)
{
Mobile m = reader.ReadMobile();
int damage = reader.ReadInt();
if (m == null)
continue;
if (m == null)
continue;
m_DamageEntries.Add(m, damage);
m_DamageEntries.Add(m, damage);
}
goto case 4;
}
goto case 4;
}
case 4:
{
ConfinedRoaming = reader.ReadBool();
m_Idol = reader.ReadItem<IdolOfTheChampion>();
HasBeenAdvanced = reader.ReadBool();
{
ConfinedRoaming = reader.ReadBool();
m_Idol = reader.ReadItem<IdolOfTheChampion>();
HasBeenAdvanced = reader.ReadBool();
goto case 3;
}
goto case 3;
}
case 3:
{
m_SpawnArea = reader.ReadRect2D();
{
m_SpawnArea = reader.ReadRect2D();
goto case 2;
}
goto case 2;
}
case 2:
{
RandomizeType = reader.ReadBool();
{
RandomizeType = reader.ReadBool();
goto case 1;
}
goto 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),
new Point2D(X + oldRange, Y + oldRange));
m_SpawnArea = new Rectangle2D(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:
{
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();
BeginRestart(RestartTime - DateTime.UtcNow);
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();
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);
@ -1150,7 +1142,7 @@ namespace Server.Engines.CannedEvil
public override bool YoungProtected => false;
public ChampionSpawn ChampionSpawn{ get; }
public ChampionSpawn ChampionSpawn { get; }
public override bool AllowHousing(Mobile from, Point3D p) => false;
@ -1159,7 +1151,7 @@ namespace Server.Engines.CannedEvil
base.AlterLightLevel(m, ref global, ref personal);
global = Math.Max(global,
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";
@ -1204,14 +1196,14 @@ namespace Server.Engines.CannedEvil
switch (version)
{
case 0:
{
Spawn = reader.ReadItem() as ChampionSpawn;
{
Spawn = reader.ReadItem() as ChampionSpawn;
if (Spawn == null)
Delete();
if (Spawn == null)
Delete();
break;
}
break;
}
}
}
}

View file

@ -26,15 +26,15 @@ namespace Server.Engines.CannedEvil
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
{

View file

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

View file

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

View file

@ -4,7 +4,7 @@ namespace Server.Engines.CannedEvil
{
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))
{

View file

@ -65,25 +65,25 @@ namespace Server.Items
switch (version)
{
case 0:
{
m_Decays = reader.ReadBool();
if (m_Decays)
{
m_DecayTime = reader.ReadDeltaTime();
m_Decays = reader.ReadBool();
m_Timer = new InternalTimer(this, m_DecayTime);
m_Timer.Start();
if (m_Decays)
{
m_DecayTime = reader.ReadDeltaTime();
m_Timer = new InternalTimer(this, m_DecayTime);
m_Timer.Start();
}
break;
}
break;
}
}
}
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;

View file

@ -6,7 +6,10 @@ namespace Server.Engines.Chat
{
private string m_Name;
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;
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);
@ -100,7 +103,6 @@ namespace Server.Engines.Chat
from.Mobile.SendMessage("Your access level is too low to do this.");
return false;
}
public bool AddUser(ChatUser user, string password = null)
@ -132,7 +134,7 @@ namespace Server.Engines.Chat
m_Users.Add(user);
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);
SendUsersTo(user);

View file

@ -8,7 +8,7 @@ namespace Server.Engines.Chat
{
public class ChatSystem
{
public static bool Enabled{ get; set; } = true;
public static bool Enabled { get; set; } = true;
public static void Initialize()
{
@ -128,9 +128,10 @@ namespace Server.Engines.Chat
Channel channel = user.CurrentChannel;
if (handler.RequireConference && channel == null)
user.SendMessage(31); /* You must be in a conference to do this.
* To join a conference, select one from the Conference menu.
*/
/* You must be in a conference to do this.
* To join a conference, select one from the Conference menu.
*/
user.SendMessage(31);
else if (handler.RequireModerator && !user.IsModerator)
user.SendMessage(29); // You must have operator status to do this.
else
@ -147,4 +148,4 @@ namespace Server.Engines.Chat
}
}
}
}
}

View file

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

View file

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

View file

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

View file

@ -11,13 +11,14 @@ namespace Server.Engines.ConPVP
private const int LabelColor32 = 0xFFFFFF;
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 Mobile m_Challenger, m_Challenged;
private DuelContext m_Context;
private Participant m_Participant;
private int m_Slot;
private readonly Mobile m_Challenger;
private readonly Mobile m_Challenged;
private readonly DuelContext m_Context;
private readonly Participant m_Participant;
private readonly int m_Slot;
public AcceptDuelGump(Mobile challenger, Mobile challenged, DuelContext context, Participant p, int slot) : base(50,
50)
@ -34,15 +35,15 @@ namespace Server.Engines.ConPVP
AddPage(0);
//AddBackground( 0, 0, 400, 220, 9150 );
// AddBackground( 0, 0, 400, 220, 9150 );
AddBackground(1, 1, 398, 218, 3600);
//AddBackground( 16, 15, 369, 189, 9100 );
// AddBackground( 16, 15, 369, 189, 9100 );
AddImageTiled(16, 15, 369, 189, 3604);
AddAlphaRegion(16, 15, 369, 189);
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));
@ -251,9 +252,9 @@ namespace Server.Engines.ConPVP
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 Mobile m_Ignored;
public readonly Mobile m_Ignored;
public IgnoreEntry(Mobile ignored)
{

View file

@ -24,14 +24,14 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Arena Arena{ get; private set; }
public Arena Arena { get; private set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsPrivate{ get; set; }
public bool IsPrivate { get; set; }
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()
{
@ -67,16 +67,16 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 1:
{
IsPrivate = reader.ReadBool();
{
IsPrivate = reader.ReadBool();
goto case 0;
}
goto case 0;
}
case 0:
{
Arena = new Arena(reader);
break;
}
{
Arena = new Arena(reader);
break;
}
}
Instances.Add(this);
@ -96,7 +96,7 @@ namespace Server.Engines.ConPVP
Points[i] = reader.ReadPoint3D();
}
public Point3D[] Points{ get; }
public Point3D[] Points { get; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D EdgeWest
@ -194,74 +194,74 @@ namespace Server.Engines.ConPVP
switch (version)
{
case 7:
{
m_IsGuarded = reader.ReadBool();
{
m_IsGuarded = reader.ReadBool();
goto case 6;
}
goto case 6;
}
case 6:
{
Ladder = reader.ReadItem() as LadderController;
{
Ladder = reader.ReadItem() as LadderController;
goto case 5;
}
goto case 5;
}
case 5:
{
m_Tournament = reader.ReadItem() as TournamentController;
Announcer = reader.ReadMobile();
{
m_Tournament = reader.ReadItem() as TournamentController;
Announcer = reader.ReadMobile();
goto case 4;
}
goto case 4;
}
case 4:
{
m_Name = reader.ReadString();
{
m_Name = reader.ReadString();
goto case 3;
}
goto case 3;
}
case 3:
{
m_Zone = reader.ReadRect2D();
{
m_Zone = reader.ReadRect2D();
goto case 2;
}
goto case 2;
}
case 2:
{
GateIn = reader.ReadPoint3D();
m_GateOut = reader.ReadPoint3D();
Teleporter = reader.ReadItem();
{
GateIn = reader.ReadPoint3D();
m_GateOut = reader.ReadPoint3D();
Teleporter = reader.ReadItem();
goto case 1;
}
goto case 1;
}
case 1:
{
Players = reader.ReadStrongMobileList();
{
Players = reader.ReadStrongMobileList();
goto case 0;
}
goto case 0;
}
case 0:
{
m_Facet = reader.ReadMap();
m_Bounds = reader.ReadRect2D();
Outside = reader.ReadPoint3D();
Wall = reader.ReadPoint3D();
if (version == 0)
{
reader.ReadBool();
Players = new List<Mobile>();
m_Facet = reader.ReadMap();
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)
@ -275,7 +275,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public LadderController Ladder{ get; set; }
public LadderController Ladder { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsGuarded
@ -305,7 +305,7 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Mobile Announcer{ get; set; }
public Mobile Announcer { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public string Name
@ -385,10 +385,10 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Outside{ get; set; }
public Point3D Outside { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D GateIn{ get; set; }
public Point3D GateIn { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public Point3D GateOut
@ -403,17 +403,17 @@ namespace Server.Engines.ConPVP
}
[CommandProperty(AccessLevel.GameMaster)]
public Point3D Wall{ get; set; }
public Point3D Wall { get; set; }
[CommandProperty(AccessLevel.GameMaster)]
public bool IsOccupied => Players.Count > 0;
[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)]
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)
{
@ -738,7 +738,7 @@ namespace Server.Engines.ConPVP
private class ArenaEntry
{
public Arena m_Arena;
public readonly Arena m_Arena;
public int m_VotesAgainst;
public int m_VotesFor;
@ -747,9 +747,7 @@ namespace Server.Engines.ConPVP
public int Value => m_VotesFor;
}
#region Offsets & Rotation
private static Point2D[] m_EdgeOffsets =
private static readonly Point2D[] m_EdgeOffsets =
{
/*
* /\
@ -772,7 +770,7 @@ namespace Server.Engines.ConPVP
};
// 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)
};
private static int[][,] m_Rotate =
private static readonly int[][,] m_Rotate =
{
new[,] { { +1, 0 }, { 0, +1 } }, // west
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 } } // ne
};
#endregion
}
}

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