Revert "Updates Packets & Randomizer (#43)" (#61)

This reverts commit 179cb50557.
This commit is contained in:
Kamron Batman 2019-11-11 08:46:11 -08:00 • committed by GitHub
parent 179cb50557
commit c2ecc76457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
588 changed files with 16260 additions and 10926 deletions

View file

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Accounting;
using Server.Engines.Help;
using Server.Factions;
@ -13,7 +12,7 @@ using Server.Spells;
namespace Server.Commands.Generic
{
public static class TargetCommands
public class TargetCommands
{
public static List<BaseCommand> AllCommands{ get; } = new List<BaseCommand>();
@ -186,7 +185,10 @@ namespace Server.Commands.Generic
public override void ExecuteList(CommandEventArgs e, List<object> list)
{
AddResponse(list.Count == 1 ? "There is one matching object." : $"There are {list.Count} matching objects.");
if (list.Count == 1)
AddResponse("There is one matching object.");
else
AddResponse($"There are {list.Count} matching objects.");
}
}
@ -232,7 +234,9 @@ namespace Server.Commands.Generic
NetState ns = mob.NetState;
if (ns == null)
{
LogFailure("That player is not online.");
}
else
{
string url = e.GetString(0);
@ -240,7 +244,10 @@ 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);
AddResponse(echo ? "Awaiting user confirmation..." : "Open web browser request sent.");
if (echo)
AddResponse("Awaiting user confirmation...");
else
AddResponse("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,
@ -248,10 +255,14 @@ namespace Server.Commands.Generic
}
}
else
{
LogFailure("That is not a player.");
}
}
else
{
LogFailure("Format: OpenBrowser <url>");
}
}
public override void Execute(CommandEventArgs e, object obj)
@ -325,7 +336,7 @@ namespace Server.Commands.Generic
CommandLogging.WriteLine(from, "{0} {1} playing sound {2} for {3}", from.AccessLevel,
CommandLogging.Format(from), index, CommandLogging.Format(mob));
Packets.SendPlaySound(mob.NetState, index, mob.Location);
mob.Send(new PlaySound(index, mob.Location));
}
else
{
@ -447,10 +458,14 @@ 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
{
@ -619,9 +634,19 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
AddResponse(obj == null ?
"The object is null." :
$"The type of that object is {obj.GetType().FullName}.");
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}.");
}
}
}
@ -835,9 +860,13 @@ 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),
@ -931,7 +960,10 @@ namespace Server.Commands.Generic
m.PlaySound(0x228);
m.Hidden = m_Value;
AddResponse(m_Value ? "They have been hidden." : "They have been revealed.");
if (m_Value)
AddResponse("They have been hidden.");
else
AddResponse("They have been revealed.");
}
}
@ -970,7 +1002,9 @@ namespace Server.Commands.Generic
}
}
else
{
LogFailure("They are not online.");
}
}
}
@ -1064,11 +1098,12 @@ namespace Server.Commands.Generic
return;
}
foreach (BaseHouse house in BaseHouse.AllHouses.Where(house => house.HasSecureItem(item) || house.HasLockedDownItem(item)))
{
e.Mobile.SendGump(new PropertiesGump(e.Mobile, house));
return;
}
foreach (BaseHouse house in BaseHouse.AllHouses)
if (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, IReadOnlyList<object> list, bool staticsOnly)
private void OnConfirmCallback(Mobile from, bool okay, List<object> list, bool staticsOnly)
{
bool flushToLog = false;
@ -191,11 +191,13 @@ namespace Server.Commands.Generic
house.Delta(ItemDelta.Update);
}
else
{
AddResponse("Command aborted.");
}
Flush(from, flushToLog);
}
#endregion
}
}
}

View file

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

View file

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

View file

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

View file

@ -111,15 +111,20 @@ namespace Server.Commands.Generic
case ObjectTypes.All:
case ObjectTypes.Both:
{
items |= condIsItem;
mobiles |= condIsMobile;
if (condIsItem)
items = true;
if (condIsMobile)
mobiles = true;
break;
}
case ObjectTypes.Items:
{
if (condIsItem)
{
items = true;
}
else if (condIsMobile)
{
from.SendMessage("You may not use a mobile type condition for this command.");
@ -131,7 +136,9 @@ 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,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Server.Items;
using Server.Targeting;
@ -41,7 +40,7 @@ namespace Server.Commands.Generic
from.SendMessage("That is not a container.");
return;
}
try
{
Extensions ext = Extensions.Parse(from, ref args);
@ -71,4 +70,4 @@ namespace Server.Commands.Generic
}
}
}
}
}

View file

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

View file

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

View file

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

View file

@ -17,7 +17,7 @@ namespace Server.Commands.Generic
{
Serial serial = e.GetUInt32(0);
IEntity obj = null;
object obj = null;
if (serial.IsItem)
obj = World.FindItem(serial);
@ -25,16 +25,22 @@ 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)