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

@ -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)