Updates Packets & Randomizer (#43)

* Fixes a bug with the main loop. Removes unnecessary optimizations for RDRand.

* WIP - Rewriting packets.

* Cleanup and updates README

* Converts more packets

* Fixes header

* Converts Effects packets.

* Forgot the send command

* Adds the start of containers packets.

* Adds message packets with caching

* Extends the send methods

* Starts to add Acquire methods

* Converted the packets

* Cleanup

* Cleanup

* Adds more packets

* Adds more packets

* Fixes clearing arrays from pool. Adds Mobile Incoming

* Converts more packets.

* Moves more packets

* Moves more packets

* Test compression

* Merges

* Migrating to an idiomatic syntax that also supports compression, and proxying.

* Optimize the stack alloc. Changes attributes

* Converted container packets

* Visual Studio doesn't auto save files. I am still getting used to subpar IDEs.

* Adds static packet caching. Will profile later. Converts more packets

* Fixes packets and changes how compression is configured

* WIP - Adds basics for Gumps. Not finished though.

* Fix file

* Fixes formatting

* Changed SpanWriter to be more idiomatic.

* Fixes Span vs RawSpan and missing stackallocs

* Converts over some more gumps

* WIP - Deletes 32bit support.

* Drops RDRand32 support.

* Fixes gump compilation

* Converting gump components

* Removes old huffman compression function

* Revert signature for backwards compatibility

* WIP - Converting more gump components

* Creates ArraySet for the strings. Updates AppendTo to reference that.

* Converts the maining gump components

* Cleans up gump components

* Cleans up directives

* Cleans up ArraySet and moves it. Adds null-coalescing-assignment

* Cleanup, Target Packets, and C# 8 changes.

* Removed OPL Packet

* World packets

* Fixing packet uses

* Cleans up code. Fixes packet uses in various places.

* More cleanup for packets

* Code cleanup

* Converts more packet uses and cleans up more code

* More code cleanup

* Finishes fixing the packets in Item

* Updates secure trade packets

* Updates core and gets it to compile.

* Moved packets to scripts. Fixed account handler use of packets

* Code cleanup

* Updates chat packets

* Code cleanuo

* Adds party packets, but need to implement them.

* Party packets WIP

* Finishes party packets

* Rearrange movement namespaces and classes

* Finishes plant packets

* Code Formatting

* Fixes moving effects

* Code cleanup, eliminates equipinfo

* Adds more packets. Fixes bugs with various packets.

* Finishes mahjon packets

* Fixes mahjong packet

* Code cleanup

* Finishes mahjong packets

* Adds Map packets

* Add multifacet maps and charts

* Cleans up some packets with UTF8

* Optimizes packets

* Cleans up more packets. Moves the MessageHelper

* Removes assistant support. Removes extended protocol. Incorporates MapUO packets as normal packets.

* Updates protocol extensions packet receiver

* Fixes a few bugs. Fixes a few more packets.

* Code cleanup and fixing more packets

* Fixes packet effects

* Cleaned up more code

* Buff Icon cleanup

* Removed unused constructors

* Code Cleanup. Adds BoatHS Packets

* Moves house files. Updates house foundation packets.

* Deployment cleanup

* Fixes:

* Code cleanup

* More code cleanup

* More code cleanup

* Cleaned up BaseHouse

* Enforces styling

* Converts foreach to linq where possible.

* Dont need that

* Goals/Readme updates

* Removes 32bit support at the highest level. Turns on HRT by default.

* Code cleanup. Fixes extended features packet.

* Fixes various bugs

* Code cleanup

* Code cleanup

* Code cleanup. Fixes gump X/Y assignment.

* Code cleanup using |= operator

* More code cleanup

* Cleanup

* Fixes spacing issues. Thanks Visual Studio. You suck.

* Compiler error

* Fixes NPE from RunUO 2.7

* Renames ScriptCompiler to AssemblyHandler. Fixes packets. Updates README

* Fixes more packets. Stupid trailing nulls.

* Fixes various bugs.

* Fixes for gumps

* Fixes more gump stuff. Going to split it out later since it is getting insane

* Recoded the gump writing

* WIP

* *Added output path of scripts project to dev branch
*Activated debugging in code
This commit is contained in:
Kamron Batman 2019-11-11 03:40:16 -08:00 committed by 3HMonkey
parent 7aa8fd3df1
commit 179cb50557
588 changed files with 10843 additions and 16177 deletions

View file

@ -7,7 +7,7 @@ using CPA = Server.CommandPropertyAttribute;
namespace Server.Commands
{
public class Add
public static class Add
{
private static Type m_EntityType = typeof(IEntity);

View file

@ -120,8 +120,7 @@ namespace Server.Commands
command.ExecuteList(eventArgs[i], usedList);
if (list.Count > 20)
CommandLogging.Enabled = true;
CommandLogging.Enabled |= list.Count > 20;
command.Flush(e.Mobile, list.Count > 20);
}

View file

@ -1,6 +1,6 @@
using Server.Targeting;
namespace Server
namespace Server.Commands
{
public delegate void BoundingBoxCallback(Map map, Point3D start, Point3D end);
@ -60,4 +60,4 @@ namespace Server
}
}
}
}
}

View file

@ -7,7 +7,7 @@ using Server.Network;
namespace Server.Commands
{
public class ConvertPlayers
public static class ConvertPlayers
{
public static void Initialize()
{

View file

@ -9,7 +9,7 @@ using Server.Mobiles;
namespace Server.Commands
{
public class Decorate
public static class Decorate
{
private static Mobile m_Mobile;
private static int m_Count;
@ -878,9 +878,7 @@ namespace Server.Commands
res = true;
}
else if ((item.ItemData.Flags & TileFlag.LightSource) != 0 && item.ItemData.Name == srcName)
{
m_DeleteQueue.Enqueue(item);
}
}
}
else if (srcItem is Teleporter || srcItem is FillableContainer || srcItem is BaseBook)

View file

@ -10,7 +10,7 @@ using Server.Mobiles;
namespace Server.Commands
{
public class DecorateMag
public static class DecorateMag
{
private static Mobile m_Mobile;
private static int m_Count;

View file

@ -82,9 +82,7 @@ namespace Server.Commands
if (baseInfo == null)
m_Types[baseType] = baseInfo = new TypeInfo(baseType);
if (baseInfo.m_Derived == null)
baseInfo.m_Derived = new List<TypeInfo>();
baseInfo.m_Derived ??= new List<TypeInfo>();
baseInfo.m_Derived.Add(info);
}
@ -97,9 +95,7 @@ namespace Server.Commands
if (decInfo == null)
m_Types[decType] = decInfo = new TypeInfo(decType);
if (decInfo.m_Nested == null)
decInfo.m_Nested = new List<TypeInfo>();
decInfo.m_Nested ??= new List<TypeInfo>();
decInfo.m_Nested.Add(info);
}
@ -115,9 +111,7 @@ namespace Server.Commands
if (ifaceInfo == null)
m_Types[iface] = ifaceInfo = new TypeInfo(iface);
if (ifaceInfo.m_Derived == null)
ifaceInfo.m_Derived = new List<TypeInfo>();
ifaceInfo.m_Derived ??= new List<TypeInfo>();
ifaceInfo.m_Derived.Add(info);
}
}
@ -644,6 +638,7 @@ namespace Server.Commands
m_Namespaces = new Dictionary<string, List<TypeInfo>>();
List<Assembly> assemblies = new List<Assembly> { Core.Assembly };
assemblies.AddRange(AssemblyHandler.Assemblies);
foreach (Assembly asm in AssemblyHandler.Assemblies)
@ -1163,37 +1158,21 @@ namespace Server.Commands
Item item = items[i].Construct();
if (item is Sandals)
{
rewards[5] = true;
}
else if (item is SmallStretchedHideEastDeed || item is SmallStretchedHideSouthDeed)
{
rewards[10] = rewards[11] = true;
}
else if (item is MediumStretchedHideEastDeed || item is MediumStretchedHideSouthDeed)
{
rewards[10] = rewards[11] = true;
}
else if (item is LightFlowerTapestryEastDeed || item is LightFlowerTapestrySouthDeed)
{
rewards[12] = rewards[13] = true;
}
else if (item is DarkFlowerTapestryEastDeed || item is DarkFlowerTapestrySouthDeed)
{
rewards[12] = rewards[13] = true;
}
else if (item is BrownBearRugEastDeed || item is BrownBearRugSouthDeed)
{
rewards[14] = rewards[15] = true;
}
else if (item is PolarBearRugEastDeed || item is PolarBearRugSouthDeed)
{
rewards[14] = rewards[15] = true;
}
else if (item is ClothingBlessDeed)
{
rewards[16] = true;
}
else if (item is PowerScroll ps)
{
if (ps.Value == 105.0)
@ -1218,10 +1197,7 @@ namespace Server.Commands
else
rewards[4] = true;
}
else if (item is RunicSewingKit rkit)
{
rewards[16 + CraftResources.GetIndex(rkit.Resource)] = true;
}
else if (item is RunicSewingKit rkit) rewards[16 + CraftResources.GetIndex(rkit.Resource)] = true;
item.Delete();
}
@ -1439,37 +1415,21 @@ namespace Server.Commands
Item item = items[i].Construct();
if (item is SturdyPickaxe || item is SturdyShovel)
{
rewards[0] = true;
}
else if (item is LeatherGlovesOfMining)
{
rewards[1] = true;
}
else if (item is StuddedGlovesOfMining)
{
rewards[2] = true;
}
else if (item is RingmailGlovesOfMining)
{
rewards[3] = true;
}
else if (item is GargoylesPickaxe)
{
rewards[4] = true;
}
else if (item is ProspectorsTool)
{
rewards[5] = true;
}
else if (item is PowderOfTemperament)
{
rewards[6] = true;
}
else if (item is ColoredAnvil)
{
rewards[7] = true;
}
else if (item is PowerScroll ps)
{
if (ps.Value == 105.0)
@ -1482,9 +1442,7 @@ namespace Server.Commands
rewards[11] = true;
}
else if (item is RunicHammer rh)
{
rewards[11 + CraftResources.GetIndex(rh.Resource)] = true;
}
else if (item is AncientSmithyHammer ash)
{
if (ash.Bonus == 10)

View file

@ -3,7 +3,7 @@ using Server.Items;
namespace Server.Commands
{
public class GenTeleporter
public static class GenTeleporter
{
public static void Initialize()
{
@ -282,7 +282,7 @@ namespace Server.Commands
CreateTeleporter(2758, 2092, -20, 2756, 2097, 38, map, false);
CreateTeleporter(2759, 2092, -20, 2756, 2097, 38, map, false);
CreateTeleporter(2685, 2063, 39, 2685, 2063, -20, map,
false); // that should not be a teleporter: on OSI you simply fall under the ground
false); // that should not be a teleporter: on OSI you simply fall under the ground
// Misc
CreateTeleporter(5217, 18, 15, 5204, 74, 17, map, false);
@ -597,7 +597,7 @@ namespace Server.Commands
CreateTeleporter(11, 1519, -27, 11, 873, -28, map, false);
CreateTeleporter(12, 1519, -27, 12, 873, -27, map, false);
// Ratman Lair
// Ratman Lair
CreateTeleporter(636, 813, -62, 164, 743, -28, map, false);
CreateTeleporter(164, 746, -16, 636, 815, -52, map, false);
@ -775,47 +775,47 @@ namespace Server.Commands
CreateTeleporter(548, 455, -40, 428, 113, -28, map, true);
CreateTeleporter(429, 113, -28, 548, 455, -40, map, false);
CreateTeleporter(242, 27, -16, 372, 31, -31, map, false); // stairs - 0x754
CreateTeleporter(242, 26, -16, 372, 30, -31, map, false); // stairs - 0x754
CreateTeleporter(242, 25, -16, 372, 29, -31, map, false); // stairs - 0x754
CreateTeleporter(371, 31, -36, 241, 27, -18, map, false); // stairs - 0x754
CreateTeleporter(371, 30, -36, 241, 26, -18, map, false); // stairs - 0x754
CreateTeleporter(242, 27, -16, 372, 31, -31, map, false); // stairs - 0x754
CreateTeleporter(242, 26, -16, 372, 30, -31, map, false); // stairs - 0x754
CreateTeleporter(242, 25, -16, 372, 29, -31, map, false); // stairs - 0x754
CreateTeleporter(371, 31, -36, 241, 27, -18, map, false); // stairs - 0x754
CreateTeleporter(371, 30, -36, 241, 26, -18, map, false); // stairs - 0x754
DestroyTeleporter(371, 29, -36, map); //To remove old erroneous teleporter
CreateTeleporter(371, 29, -36, 241, 25, -18, map, false); // stairs - 0x754
CreateTeleporter(272, 141, -16, 555, 427, -1, map, false); // stairs - 1st 0x753
CreateTeleporter(273, 141, -16, 556, 427, -1, map, false); // stairs - 1st 0x753
CreateTeleporter(274, 141, -16, 557, 427, -1, map, false); // stairs - 1st 0x753
CreateTeleporter(555, 426, -6, 272, 140, -21, map, false); // stairs - 1st 0x753
CreateTeleporter(556, 426, -6, 273, 140, -21, map, false); // stairs - 1st 0x753
CreateTeleporter(557, 426, -6, 274, 140, -21, map, false); // stairs - 1st 0x753
CreateTeleporter(272, 141, -16, 555, 427, -1, map, false); // stairs - 1st 0x753
CreateTeleporter(273, 141, -16, 556, 427, -1, map, false); // stairs - 1st 0x753
CreateTeleporter(274, 141, -16, 557, 427, -1, map, false); // stairs - 1st 0x753
CreateTeleporter(555, 426, -6, 272, 140, -21, map, false); // stairs - 1st 0x753
CreateTeleporter(556, 426, -6, 273, 140, -21, map, false); // stairs - 1st 0x753
CreateTeleporter(557, 426, -6, 274, 140, -21, map, false); // stairs - 1st 0x753
CreateTeleporter(265, 130, -31, 284, 72, -21, map, false); // stairs - 0x753
CreateTeleporter(266, 130, -31, 285, 72, -21, map, false); // stairs - 0x753
CreateTeleporter(267, 130, -31, 286, 72, -21, map, false); // stairs - 0x753
CreateTeleporter(268, 130, -31, 287, 72, -21, map, false); // stairs - 0x753
CreateTeleporter(284, 73, -16, 265, 131, -28, map, false); // stairs - 0x753
CreateTeleporter(285, 73, -16, 266, 131, -28, map, false); // stairs - 0x753
CreateTeleporter(286, 73, -16, 267, 131, -28, map, false); // stairs - 0x753
CreateTeleporter(287, 73, -16, 268, 131, -28, map, false); // stairs - 0x753
CreateTeleporter(265, 130, -31, 284, 72, -21, map, false); // stairs - 0x753
CreateTeleporter(266, 130, -31, 285, 72, -21, map, false); // stairs - 0x753
CreateTeleporter(267, 130, -31, 286, 72, -21, map, false); // stairs - 0x753
CreateTeleporter(268, 130, -31, 287, 72, -21, map, false); // stairs - 0x753
CreateTeleporter(284, 73, -16, 265, 131, -28, map, false); // stairs - 0x753
CreateTeleporter(285, 73, -16, 266, 131, -28, map, false); // stairs - 0x753
CreateTeleporter(286, 73, -16, 267, 131, -28, map, false); // stairs - 0x753
CreateTeleporter(287, 73, -16, 268, 131, -28, map, false); // stairs - 0x753
CreateTeleporter(284, 67, -30, 131, 128, -21, map, false); // stairs - 0x753
CreateTeleporter(285, 67, -30, 132, 128, -21, map, false); // stairs - 0x753
CreateTeleporter(286, 67, -30, 133, 128, -21, map, false); // stairs - 0x753
CreateTeleporter(287, 67, -30, 134, 128, -21, map, false); // stairs - 0x753
CreateTeleporter(131, 129, -16, 284, 68, -28, map, false); // stairs - 0x753
CreateTeleporter(132, 129, -16, 285, 68, -28, map, false); // stairs - 0x753
CreateTeleporter(133, 129, -16, 286, 68, -28, map, false); // stairs - 0x753
CreateTeleporter(134, 129, -16, 287, 68, -28, map, false); // stairs - 0x753
CreateTeleporter(284, 67, -30, 131, 128, -21, map, false); // stairs - 0x753
CreateTeleporter(285, 67, -30, 132, 128, -21, map, false); // stairs - 0x753
CreateTeleporter(286, 67, -30, 133, 128, -21, map, false); // stairs - 0x753
CreateTeleporter(287, 67, -30, 134, 128, -21, map, false); // stairs - 0x753
CreateTeleporter(131, 129, -16, 284, 68, -28, map, false); // stairs - 0x753
CreateTeleporter(132, 129, -16, 285, 68, -28, map, false); // stairs - 0x753
CreateTeleporter(133, 129, -16, 286, 68, -28, map, false); // stairs - 0x753
CreateTeleporter(134, 129, -16, 287, 68, -28, map, false); // stairs - 0x753
CreateTeleporter(358, 40, -36, 156, 88, -18, map, false); // stairs - 0x73A
CreateTeleporter(358, 41, -36, 156, 89, -18, map, false); // stairs - 0x73A
CreateTeleporter(358, 42, -36, 156, 90, -18, map, false); // stairs - 0x73A
CreateTeleporter(155, 88, -16, 357, 40, -31, map, false); // stairs - 0x73A
CreateTeleporter(155, 89, -16, 357, 41, -31, map, false); // stairs - 0x73A
CreateTeleporter(155, 90, -16, 357, 42, -31, map, false); // stairs - 0x73A
CreateTeleporter(358, 40, -36, 156, 88, -18, map, false); // stairs - 0x73A
CreateTeleporter(358, 41, -36, 156, 89, -18, map, false); // stairs - 0x73A
CreateTeleporter(358, 42, -36, 156, 90, -18, map, false); // stairs - 0x73A
CreateTeleporter(155, 88, -16, 357, 40, -31, map, false); // stairs - 0x73A
CreateTeleporter(155, 89, -16, 357, 41, -31, map, false); // stairs - 0x73A
CreateTeleporter(155, 90, -16, 357, 42, -31, map, false); // stairs - 0x73A
CreateTeleporter(259, 90, -28, 236, 113, -28, map, true);
@ -923,7 +923,7 @@ namespace Server.Commands
public void CreateTeleportersMap3(Map map)
{
// CreateTeleporter( 408, 254, 2, 428, 319, 2, map, false ); // for doom quest; use blockers to avoid players teleporting into the ship!
// CreateTeleporter( 408, 254, 2, 428, 319, 2, map, false ); // for doom quest; use blockers to avoid players teleporting into the ship!
// CreateTeleporter( 428, 321, 2, 422, 328, -1, map, false ); // for doom quest; use blockers to avoid players teleporting into the ship!
// Doom Dungeon
@ -1040,4 +1040,4 @@ namespace Server.Commands
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Accounting;
using Server.Engines.Help;
using Server.Factions;
@ -12,7 +13,7 @@ using Server.Spells;
namespace Server.Commands.Generic
{
public class TargetCommands
public static class TargetCommands
{
public static List<BaseCommand> AllCommands{ get; } = new List<BaseCommand>();
@ -185,10 +186,7 @@ namespace Server.Commands.Generic
public override void ExecuteList(CommandEventArgs e, List<object> list)
{
if (list.Count == 1)
AddResponse("There is one matching object.");
else
AddResponse($"There are {list.Count} matching objects.");
AddResponse(list.Count == 1 ? "There is one matching object." : $"There are {list.Count} matching objects.");
}
}
@ -234,9 +232,7 @@ namespace Server.Commands.Generic
NetState ns = mob.NetState;
if (ns == null)
{
LogFailure("That player is not online.");
}
else
{
string url = e.GetString(0);
@ -244,10 +240,7 @@ namespace Server.Commands.Generic
CommandLogging.WriteLine(from, "{0} {1} requesting to open web browser of {2} to {3}",
from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(mob), url);
if (echo)
AddResponse("Awaiting user confirmation...");
else
AddResponse("Open web browser request sent.");
AddResponse(echo ? "Awaiting user confirmation..." : "Open web browser request sent.");
mob.SendGump(new WarningGump(1060637, 30720,
$"A game master is requesting to open your web browser to the following URL:<br>{url}", 0xFFC000,
@ -255,14 +248,10 @@ namespace Server.Commands.Generic
}
}
else
{
LogFailure("That is not a player.");
}
}
else
{
LogFailure("Format: OpenBrowser <url>");
}
}
public override void Execute(CommandEventArgs e, object obj)
@ -336,7 +325,7 @@ namespace Server.Commands.Generic
CommandLogging.WriteLine(from, "{0} {1} playing sound {2} for {3}", from.AccessLevel,
CommandLogging.Format(from), index, CommandLogging.Format(mob));
mob.Send(new PlaySound(index, mob.Location));
Packets.SendPlaySound(mob.NetState, index, mob.Location);
}
else
{
@ -458,14 +447,10 @@ namespace Server.Commands.Generic
e.Mobile.SendGump(new AddGump(e.Mobile, match, 0, Type.EmptyTypes, false));
}
else
{
e.Mobile.SendGump(new AddGump(e.Mobile, match, 0, AddGump.Match(match).ToArray(), true));
}
}
else
{
return true;
}
}
else
{
@ -634,19 +619,9 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (obj == null)
{
AddResponse("The object is null.");
}
else
{
Type type = obj.GetType();
if (type.DeclaringType == null)
AddResponse($"The type of that object is {type.Name}.");
else
AddResponse($"The type of that object is {type.FullName}.");
}
AddResponse(obj == null ?
"The object is null." :
$"The type of that object is {obj.GetType().FullName}.");
}
}
@ -860,13 +835,9 @@ namespace Server.Commands.Generic
if (m_Value)
{
if (!mob.Alive)
{
LogFailure("They are already dead.");
}
else if (!mob.CanBeDamaged())
{
LogFailure("They cannot be harmed.");
}
else
{
CommandLogging.WriteLine(from, "{0} {1} killing {2}", from.AccessLevel, CommandLogging.Format(from),
@ -960,10 +931,7 @@ namespace Server.Commands.Generic
m.PlaySound(0x228);
m.Hidden = m_Value;
if (m_Value)
AddResponse("They have been hidden.");
else
AddResponse("They have been revealed.");
AddResponse(m_Value ? "They have been hidden." : "They have been revealed.");
}
}
@ -1002,9 +970,7 @@ namespace Server.Commands.Generic
}
}
else
{
LogFailure("They are not online.");
}
}
}
@ -1098,12 +1064,11 @@ namespace Server.Commands.Generic
return;
}
foreach (BaseHouse house in BaseHouse.AllHouses)
if (house.HasSecureItem(item) || house.HasLockedDownItem(item))
{
e.Mobile.SendGump(new PropertiesGump(e.Mobile, house));
return;
}
foreach (BaseHouse house in BaseHouse.AllHouses.Where(house => house.HasSecureItem(item) || house.HasLockedDownItem(item)))
{
e.Mobile.SendGump(new PropertiesGump(e.Mobile, house));
return;
}
LogFailure("No house was found.");
}

View file

@ -149,7 +149,7 @@ namespace Server.Commands.Generic
AddResponse("Awaiting confirmation...");
}
private void OnConfirmCallback(Mobile from, bool okay, List<object> list, bool staticsOnly)
private void OnConfirmCallback(Mobile from, bool okay, IReadOnlyList<object> list, bool staticsOnly)
{
bool flushToLog = false;
@ -191,13 +191,11 @@ namespace Server.Commands.Generic
house.Delta(ItemDelta.Update);
}
else
{
AddResponse("Command aborted.");
}
Flush(from, flushToLog);
}
#endregion
}
}
}

View file

@ -160,10 +160,6 @@ namespace Server.Commands.Generic
FieldAttributes.Private | FieldAttributes.InitOnly
);
// 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);
@ -234,36 +230,17 @@ namespace Server.Commands.Generic
public override void Compile(MethodEmitter emitter)
{
bool inverse = false;
bool inverse = m_Operator == StringOperator.NotEqual;
string methodName;
switch (m_Operator)
string methodName = m_Operator switch
{
case StringOperator.Equal:
methodName = "Equals";
break;
case StringOperator.NotEqual:
methodName = "Equals";
inverse = true;
break;
case StringOperator.Contains:
methodName = "Contains";
break;
case StringOperator.StartsWith:
methodName = "StartsWith";
break;
case StringOperator.EndsWith:
methodName = "EndsWith";
break;
default:
throw new InvalidOperationException("Invalid string comparison operator.");
}
StringOperator.Equal => "Equals",
StringOperator.NotEqual => "Equals",
StringOperator.Contains => "Contains",
StringOperator.StartsWith => "StartsWith",
StringOperator.EndsWith => "EndsWith",
_ => throw new InvalidOperationException("Invalid string comparison operator.")
};
if (m_IgnoreCase || methodName == "Equals")
{

View file

@ -32,8 +32,7 @@ namespace Server.Commands.Generic
prop.CheckAccess(from);
}
if (assembly == null)
assembly = new AssemblyEmitter("__dynamic");
assembly ??= new AssemblyEmitter("__dynamic");
m_Comparer = DistinctCompiler.Compile<object>(assembly, baseType, m_Properties.ToArray());
}

View file

@ -31,8 +31,7 @@ namespace Server.Commands.Generic
order.Property.CheckAccess(from);
}
if (assembly == null)
assembly = new AssemblyEmitter("__dynamic");
assembly ??= new AssemblyEmitter("__dynamic");
m_Comparer = SortCompiler.Compile<object>(assembly, baseType, m_Orders.ToArray());
}
@ -69,7 +68,6 @@ namespace Server.Commands.Generic
case "up":
case "asc":
case "ascending":
isAscending = true;
++offset;
break;

View file

@ -111,20 +111,15 @@ namespace Server.Commands.Generic
case ObjectTypes.All:
case ObjectTypes.Both:
{
if (condIsItem)
items = true;
if (condIsMobile)
mobiles = true;
items |= condIsItem;
mobiles |= condIsMobile;
break;
}
case ObjectTypes.Items:
{
if (condIsItem)
{
items = true;
}
else if (condIsMobile)
{
from.SendMessage("You may not use a mobile type condition for this command.");
@ -136,9 +131,7 @@ namespace Server.Commands.Generic
case ObjectTypes.Mobiles:
{
if (condIsMobile)
{
mobiles = true;
}
else if (condIsItem)
{
from.SendMessage("You may not use an item type condition for this command.");

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Items;
using Server.Targeting;
@ -40,7 +41,7 @@ namespace Server.Commands.Generic
from.SendMessage("That is not a container.");
return;
}
try
{
Extensions ext = Extensions.Parse(from, ref args);
@ -70,4 +71,4 @@ namespace Server.Commands.Generic
}
}
}
}
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Server.Commands.Generic
{
@ -28,14 +29,10 @@ namespace Server.Commands.Generic
List<object> list = new List<object>();
if (items)
foreach (Item item in World.Items.Values)
if (ext.IsValid(item))
list.Add(item);
list.AddRange(World.Items.Values.Where(item => ext.IsValid(item)));
if (mobiles)
foreach (Mobile mob in World.Mobiles.Values)
if (ext.IsValid(mob))
list.Add(mob);
list.AddRange(World.Mobiles.Values.Where(mob => ext.IsValid(mob)));
ext.Filter(list);
@ -47,4 +44,4 @@ namespace Server.Commands.Generic
}
}
}
}
}

View file

@ -30,8 +30,7 @@ namespace Server.Commands.Generic
public void Compile(ref AssemblyEmitter emitter)
{
if (emitter == null)
emitter = new AssemblyEmitter("__dynamic");
emitter ??= new AssemblyEmitter("__dynamic");
m_Conditionals = new IConditional[m_Conditions.Length];

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Server.Commands.Generic
{
@ -30,16 +31,7 @@ namespace Server.Commands.Generic
List<object> list = new List<object>();
if (mobiles)
{
foreach (Mobile mob in reg.GetMobiles())
{
if (!BaseCommand.IsAccessible(from, mob))
continue;
if (ext.IsValid(mob))
list.Add(mob);
}
}
list.AddRange(reg.GetMobiles().Where(mob => BaseCommand.IsAccessible(from, mob)).Where(mob => ext.IsValid(mob)));
else
{
command.LogFailure("This command does not support items.");
@ -56,4 +48,4 @@ namespace Server.Commands.Generic
}
}
}
}
}

View file

@ -17,7 +17,7 @@ namespace Server.Commands.Generic
{
Serial serial = e.GetUInt32(0);
object obj = null;
IEntity obj = null;
if (serial.IsItem)
obj = World.FindItem(serial);
@ -25,22 +25,16 @@ namespace Server.Commands.Generic
obj = World.FindMobile(serial);
if (obj == null)
{
e.Mobile.SendMessage("That is not a valid serial.");
}
else
{
Commands.TryGetValue(e.GetString(1), out BaseCommand command);
if (command == null)
{
e.Mobile.SendMessage(
"That is either an invalid command name or one that does not support this modifier.");
}
else if (e.Mobile.AccessLevel < command.AccessLevel)
{
e.Mobile.SendMessage("You do not have access to that command.");
}
else
{
switch (command.ObjectTypes)

View file

@ -1,10 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Server.Commands.Generic;
using Server.Engines.Help;
using Server.Gumps;
using Server.Items;
using Server.Menus.ItemLists;
using Server.Menus;
using Server.Menus.Questions;
using Server.Misc;
using Server.Mobiles;
@ -16,7 +17,7 @@ using Server.Targets;
namespace Server.Commands
{
public class CommandHandlers
public static class CommandHandlers
{
public static void Initialize()
{
@ -88,19 +89,17 @@ namespace Server.Commands
{
if (e.Length == 1 && !e.GetBoolean(0))
{
from.Send(SpeedControl.Disable);
Packets.SendSpeedControlDisabled(from.NetState);
from.SendMessage("Speed boost has been disabled.");
}
else
{
from.Send(SpeedControl.MountSpeed);
Packets.SendSpeedControlMount(from.NetState);
from.SendMessage("Speed boost has been enabled.");
}
}
else
{
from.SendMessage("Format: SpeedBoost [true|false]");
}
}
[Usage("Where")]
@ -159,18 +158,16 @@ namespace Server.Commands
{
PageEntry pe = PageQueue.GetEntry(targ);
if (pe?.Handler == from)
from.SendMessage("You may only use this command if you are handling their help page.");
else
from.SendMessage("You may only use this command on someone who has paged you.");
from.SendMessage(pe?.Handler == from
? "You may only use this command if you are handling their help page."
: "You may only use this command on someone who has paged you.");
return;
}
if (targ.AddToBackpack(held))
from.SendMessage("The item they were holding has been placed into their backpack.");
else
from.SendMessage("The item they were holding has been placed at their feet.");
from.SendMessage(targ.AddToBackpack(held)
? "The item they were holding has been placed into their backpack."
: "The item they were holding has been placed at their feet.");
held.ClearBounce();
@ -220,14 +217,8 @@ namespace Server.Commands
}
List<IEntity> list = new List<IEntity>();
foreach (Item item in World.Items.Values)
if (item.Map == map && item.Parent == null)
list.Add(item);
foreach (Mobile m in World.Mobiles.Values)
if (m.Map == map && !m.Player)
list.Add(m);
list.AddRange(World.Items.Values.Where(item => item.Map == map && item.Parent == null));
list.AddRange(World.Mobiles.Values.Where(m => m.Map == map && !m.Player));
if (list.Count > 0)
{
@ -277,9 +268,7 @@ namespace Server.Commands
}
}
else
{
from.SendMessage("There were no pets found for that player.");
}
}
else if (obj is Mobile master && master.Player)
{
@ -308,9 +297,7 @@ namespace Server.Commands
}
}
else
{
from.SendMessage("There were no pets found for that player.");
}
}
else
{
@ -349,15 +336,9 @@ namespace Server.Commands
CommandLogging.WriteLine(m, "{0} {1} playing sound {2} (toAll={3})", m.AccessLevel, CommandLogging.Format(m),
index, toAll);
Packet p = new PlaySound(index, m.Location);
p.Acquire();
foreach (NetState state in m.GetClientsInRange(12))
if (toAll || state.Mobile.CanSee(m))
state.Send(p);
p.Release();
Packets.SendPlaySound(state, index, m.Location);
}
[Usage("Echo <text>")]
@ -366,10 +347,7 @@ namespace Server.Commands
{
string toEcho = e.ArgString.Trim();
if (toEcho.Length > 0)
e.Mobile.SendMessage(toEcho);
else
e.Mobile.SendMessage("Format: Echo \"<text>\"");
e.Mobile.SendMessage(toEcho.Length > 0 ? toEcho : "Format: Echo \"<text>\"");
}
[Usage("Bank")]
@ -528,16 +506,12 @@ namespace Server.Commands
Dictionary<string, Region> list = from.Map.Regions;
foreach (KeyValuePair<string, Region> kvp in list)
{
Region r = kvp.Value;
foreach (var (_, r) in list)
if (Insensitive.Equals(r.Name, name))
{
from.Location = new Point3D(r.GoLocation);
return;
}
}
for (int i = 0; i < Map.AllMaps.Count; ++i)
{
@ -618,11 +592,7 @@ namespace Server.Commands
{
Mobile m = e.Mobile;
List<CommandEntry> list = new List<CommandEntry>();
foreach (CommandEntry entry in CommandSystem.Entries.Values)
if (m.AccessLevel >= entry.AccessLevel)
list.Add(entry);
List<CommandEntry> list = CommandSystem.Entries.Values.Where(entry => m.AccessLevel >= entry.AccessLevel).ToList();
list.Sort();
@ -671,13 +641,8 @@ namespace Server.Commands
public static void BroadcastMessage(AccessLevel ac, int hue, string message)
{
foreach (NetState state in NetState.Instances)
{
Mobile m = state.Mobile;
if (m?.AccessLevel >= ac)
m.SendMessage(hue, message);
}
foreach (Mobile m in NetState.Instances.Select(state => state.Mobile).Where(m => m?.AccessLevel >= ac))
m.SendMessage(hue, message);
}
[Usage("AutoPageNotify")]

View file

@ -9,7 +9,7 @@ using CommandInfoSorter = Server.Commands.Docs.CommandEntrySorter;
namespace Server.Commands
{
public class HelpInfo
public static class HelpInfo
{
public static Dictionary<string, CommandInfo> HelpInfos{ get; } = new Dictionary<string, CommandInfo>();

View file

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

View file

@ -196,7 +196,7 @@ namespace Server.Commands
}
}
return chain[chain.Length - 1];
return chain[^1];
}
public static string GetValue(Mobile from, object o, string name)
@ -328,7 +328,7 @@ namespace Server.Commands
concat[i * 2 + 1] = i < chain.Length - 1 ? "." : " = ";
}
concat[concat.Length - 1] = toString;
concat[^1] = toString;
return string.Concat(concat);
}
@ -382,7 +382,7 @@ namespace Server.Commands
if (IsEnum(type))
try
{
toSet = Enum.Parse(type, value, true);
toSet = Enum.Parse(type, value ?? "", true);
}
catch
{
@ -654,7 +654,7 @@ namespace Server
if (!IsBound)
throw new NotYetBoundException(this);
return m_Chain[m_Chain.Length - 1].PropertyType;
return m_Chain[^1].PropertyType;
}
}

View file

@ -2,7 +2,7 @@
namespace Server.Commands
{
public class ShardTime
public static class ShardTime
{
public static void Initialize()
{
@ -16,4 +16,4 @@ namespace Server.Commands
e.Mobile.SendMessage(DateTime.UtcNow.ToString());
}
}
}
}

View file

@ -4,7 +4,7 @@ using Server.Items;
namespace Server.Commands
{
public class SignParser
public static class SignParser
{
private static Queue<Item> m_ToDelete = new Queue<Item>();
@ -76,9 +76,7 @@ namespace Server.Commands
from.SendMessage("Sign generating complete.");
}
else
{
from.SendMessage("{0} not found!", cfg);
}
}
public static void Add_Static(int itemID, Point3D location, Map map, string name)
@ -94,17 +92,8 @@ namespace Server.Commands
while (m_ToDelete.Count > 0)
m_ToDelete.Dequeue().Delete();
Item sign;
if (name.StartsWith("#"))
{
sign = new LocalizedSign(itemID, Utility.ToInt32(name.Substring(1)));
}
else
{
sign = new Sign(itemID);
sign.Name = name;
}
Item sign = name.StartsWith("#") ? new LocalizedSign(itemID, Utility.ToInt32(name.Substring(1))) :
new Sign(itemID) {Name = name};
if (map == Map.Malas)
{

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Commands
{
public class SkillsCommand
public static class SkillsCommand
{
public static void Initialize()
{
@ -123,4 +123,4 @@ namespace Server.Commands
}
}
}
}
}

View file

@ -3,7 +3,7 @@ using Server.Targeting;
namespace Server.Commands
{
public class Skills
public static class Skills
{
public static void Initialize()
{
@ -35,4 +35,4 @@ namespace Server.Commands
}
}
}
}
}

View file

@ -1,12 +1,11 @@
using System.Collections.Generic;
using System.IO;
using Server.Commands;
using Server.Gumps;
using Server.Items;
namespace Server
namespace Server.Commands
{
public class Statics
public static class Statics
{
private const string BaseFreezeWarning = "{0} " +
"Those items <u>will be removed from the world</u> and placed into the server data files. " +
@ -180,11 +179,8 @@ namespace Server
int totalFrozen = 0;
foreach (KeyValuePair<Map, Dictionary<Point2D, DeltaState>> de in mapTable)
foreach (var (map, table) in mapTable)
{
Map map = de.Key;
Dictionary<Point2D, DeltaState> table = de.Value;
TileMatrix matrix = map.Tiles;
using FileStream idxStream = OpenWrite(matrix.IndexStream);

View file

@ -49,9 +49,7 @@ namespace Server.Commands
pm.SendMessage("#{0}: {1}", i + 1, list[i].Name);
}
else
{
pm.SendMessage("Your visibility list is empty.");
}
}
}
@ -71,7 +69,7 @@ namespace Server.Commands
Mobile m = list[i];
if (!m.CanSee(pm) && Utility.InUpdateRange(m, pm))
m.Send(pm.RemovePacket);
Packets.SendRemoveEntity(m.NetState, pm.Serial);
}
}
}
@ -84,58 +82,54 @@ namespace Server.Commands
protected override void OnTarget(Mobile from, object targeted)
{
if (from is PlayerMobile pm && targeted is Mobile targ)
if (!(from is PlayerMobile pm) || !(targeted is Mobile targ))
{
if (targ.AccessLevel <= pm.AccessLevel)
{
List<Mobile> list = pm.VisibilityList;
from.SendMessage("Add only mobiles to your visibility list.");
return;
}
if (list.Contains(targ))
{
list.Remove(targ);
pm.SendMessage("{0} has been removed from your visibility list.", targ.Name);
}
else
{
list.Add(targ);
pm.SendMessage("{0} has been added to your visibility list.", targ.Name);
}
if (targ.AccessLevel > pm.AccessLevel)
{
pm.SendMessage("They can already see you!");
return;
}
if (Utility.InUpdateRange(targ, from))
{
NetState ns = targ.NetState;
List<Mobile> list = pm.VisibilityList;
if (ns != null)
{
if (targ.CanSee(pm))
{
ns.Send(MobileIncoming.Create(ns, targ, pm));
if (ObjectPropertyList.Enabled)
{
ns.Send(pm.OPLPacket);
foreach (Item item in pm.Items)
ns.Send(item.OPLPacket);
}
}
else
{
ns.Send(pm.RemovePacket);
}
}
}
}
else
{
pm.SendMessage("They can already see you!");
}
if (list.Contains(targ))
{
list.Remove(targ);
pm.SendMessage("{0} has been removed from your visibility list.", targ.Name);
}
else
{
from.SendMessage("Add only mobiles to your visibility list.");
list.Add(targ);
pm.SendMessage("{0} has been added to your visibility list.", targ.Name);
}
if (Utility.InUpdateRange(targ, from))
{
NetState ns = targ.NetState;
if (ns != null)
{
if (targ.CanSee(pm))
{
Packets.SendMobileIncoming(ns, targ, pm);
if (ObjectPropertyList.Enabled)
{
pm.PropertyList.Send(ns);
foreach (Item item in pm.Items)
item.PropertyList.SendOPLInfo(ns);
}
}
else
Packets.SendRemoveEntity(ns, pm.Serial);
}
}
}
}
}
}
}

View file

@ -5,7 +5,7 @@ using Server.Multis;
namespace Server.Commands
{
public class Wipe
public static class Wipe
{
[Flags]
public enum WipeType
@ -74,7 +74,7 @@ namespace Server.Commands
if (!items && !multis || !mobiles)
return;
eable = map.GetObjectsInBounds(rect);
foreach (IEntity obj in eable)
@ -91,4 +91,4 @@ namespace Server.Commands
toDelete[i].Delete();
}
}
}
}