Fixes brace style (#248)

This commit is contained in:
Kamron Batman 2020-09-13 21:49:46 -07:00 committed by GitHub
parent a236617ad9
commit 8149620b0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
1503 changed files with 28575 additions and 1717 deletions

View file

@ -33,7 +33,10 @@ namespace Server.Tests.Network.Packets
var packLength = (ulong)dest.Length - 8;
ZlibError ce = Zlib.Pack(dest.Slice(pos + 8), ref packLength, source, ZlibQuality.Default);
if (ce != ZlibError.Okay) Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce);
if (ce != ZlibError.Okay)
{
Console.WriteLine("ZLib error: {0} (#{1})", ce, (int)ce);
}
dest.Write(ref pos, (int)(4 + packLength));
dest.Write(ref pos, length);

View file

@ -137,15 +137,23 @@ namespace Server.Tests.Network.Packets
flags &= ~FeatureFlags.UOTD;
if (ns.Account.Limit > 6)
{
flags |= FeatureFlags.SeventhCharacterSlot;
}
else
{
flags |= FeatureFlags.SixthCharacterSlot;
}
}
if (ns.ExtendedSupportedFeatures)
{
expectedData.Write(ref pos, (uint)flags);
}
else
{
expectedData.Write(ref pos, (ushort)flags);
}
AssertThat.Equal(data, expectedData);
}
@ -194,7 +202,9 @@ namespace Server.Tests.Network.Packets
var map = m.Map;
if (map == null || map == Map.Internal)
{
map = m.LogoutMap;
}
expectedData.Write(ref pos, (ushort)(map?.Width ?? Map.Felucca.Width));
expectedData.Write(ref pos, (ushort)(map?.Height ?? Map.Felucca.Height));
@ -234,11 +244,13 @@ namespace Server.Tests.Network.Packets
var highSlot = -1;
for (var i = account.Length - 1; i >= 0; i--)
{
if (account[i] != null)
{
highSlot = i;
break;
}
}
var count = Math.Max(Math.Max(highSlot + 1, account.Limit), 5);
expectedData.Write(ref pos, (byte)count);
@ -303,11 +315,13 @@ namespace Server.Tests.Network.Packets
var highSlot = -1;
for (var i = account.Length - 1; i >= 0; i--)
{
if (account[i] != null)
{
highSlot = i;
break;
}
}
var count = Math.Max(Math.Max(highSlot + 1, account.Limit), 5);
expectedData.Write(ref pos, (byte)count);
@ -367,13 +381,19 @@ namespace Server.Tests.Network.Packets
var flags = ExpansionInfo.GetInfo(Expansion.EJ).CharacterListFlags;
if (count > 6)
{
flags |= CharacterListFlags.SeventhCharacterSlot |
CharacterListFlags.SixthCharacterSlot; // 7th Character Slot
}
else if (count == 6)
{
flags |= CharacterListFlags.SixthCharacterSlot; // 6th Character Slot
}
else if (account.Limit == 1)
{
flags |= CharacterListFlags.SlotLimit &
CharacterListFlags.OneCharacterSlot; // Limit Characters & One Character
}
expectedData.Write(ref pos, (int)flags);
expectedData.Write(ref pos, (short)-1);
@ -404,11 +424,13 @@ namespace Server.Tests.Network.Packets
var highSlot = -1;
for (var i = account.Length - 1; i >= 0; i--)
{
if (account[i] != null)
{
highSlot = i;
break;
}
}
var count = Math.Max(Math.Max(highSlot + 1, account.Limit), 5);
expectedData.Write(ref pos, (byte)count);
@ -458,13 +480,19 @@ namespace Server.Tests.Network.Packets
var flags = ExpansionInfo.GetInfo(Expansion.EJ).CharacterListFlags;
if (count > 6)
{
flags |= CharacterListFlags.SeventhCharacterSlot |
CharacterListFlags.SixthCharacterSlot; // 7th Character Slot
}
else if (count == 6)
{
flags |= CharacterListFlags.SixthCharacterSlot; // 6th Character Slot
}
else if (account.Limit == 1)
{
flags |= CharacterListFlags.SlotLimit &
CharacterListFlags.OneCharacterSlot; // Limit Characters & One Character
}
expectedData.Write(ref pos, (int)flags);
@ -546,8 +574,12 @@ namespace Server.Tests.Network.Packets
{
m_Mobiles = mobiles;
foreach (var mobile in mobiles)
{
if (mobile != null)
{
mobile.Account = this;
}
}
Length = mobiles.Length;
Count = mobiles.Count(t => t != null);
@ -571,7 +603,10 @@ namespace Server.Tests.Network.Packets
public bool WithdrawGold(int amount)
{
if (TotalGold - amount < 0) return false;
if (TotalGold - amount < 0)
{
return false;
}
TotalGold -= amount;
return true;
@ -579,7 +614,10 @@ namespace Server.Tests.Network.Packets
public bool WithdrawPlat(int amount)
{
if (TotalPlat - amount < 0) return false;
if (TotalPlat - amount < 0)
{
return false;
}
TotalPlat -= amount;
return true;

View file

@ -32,7 +32,10 @@ namespace Server.Tests.Network.Packets
var attrs = info.Attributes;
var length = 17 + (info.Unidentified ? 4 : 0) + attrs.Length * 6;
if (info.Crafter != null) length += 6 + (info.Crafter.Name?.Length ?? 0);
if (info.Crafter != null)
{
length += 6 + (info.Crafter.Name?.Length ?? 0);
}
Span<byte> expectedData = stackalloc byte[length];
@ -51,7 +54,10 @@ namespace Server.Tests.Network.Packets
expectedData.WriteAscii(ref pos, name);
}
if (info.Unidentified) expectedData.Write(ref pos, -4);
if (info.Unidentified)
{
expectedData.Write(ref pos, -4);
}
for (var i = 0; i < attrs.Length; i++)
{

View file

@ -120,7 +120,9 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, (ushort)gump.Strings.Count);
for (var i = 0; i < gump.Strings.Count; ++i)
{
expectedData.WriteBigUni(ref pos, gump.Strings[i] ?? "");
}
expectedData.Slice(1, 2).Write((ushort)pos); // Length
@ -198,7 +200,9 @@ namespace Server.Tests.Network.Packets
var bufferPos = 0;
foreach (var layout in layoutList)
{
buffer.WriteAscii(ref bufferPos, layout);
}
#if NO_LOCAL_INIT
buffer.Write(ref bufferPos, (byte)0); // Layout terminator
@ -216,7 +220,9 @@ namespace Server.Tests.Network.Packets
bufferPos = 0;
foreach (var str in gump.Strings)
{
buffer.WriteBigUni(ref bufferPos, str);
}
expectedData.WritePacked(ref pos, buffer.Slice(0, bufferPos));

View file

@ -43,23 +43,35 @@ namespace Server.Tests.Network.Packets
pos += 2; // Length
if (item.Amount != 0)
{
expectedData.Write(ref pos, serial | 0x80000000);
}
else
{
expectedData.Write(ref pos, serial & 0x7FFFFFFF);
}
if (item is BaseMulti)
{
expectedData.Write(ref pos, (ushort)(item.ItemID | 0x4000));
}
else
{
expectedData.Write(ref pos, (ushort)item.ItemID);
}
if (item.Amount != 0)
{
expectedData.Write(ref pos, (ushort)item.Amount);
}
var direction = (byte)item.Direction;
var x = (ushort)(item.X & 0x7FFF);
if (direction != 0)
{
x |= 0x8000;
}
expectedData.Write(ref pos, x);
@ -67,21 +79,34 @@ namespace Server.Tests.Network.Packets
var flags = item.GetPacketFlags();
var y = (ushort)(item.Y & 0x3FFF);
if (hue != 0) y |= 0x8000;
if (flags != 0) y |= 0x4000;
if (hue != 0)
{
y |= 0x8000;
}
if (flags != 0)
{
y |= 0x4000;
}
expectedData.Write(ref pos, y);
if (direction != 0)
{
expectedData.Write(ref pos, direction);
}
expectedData.Write(ref pos, (byte)item.Z);
if (hue != 0)
{
expectedData.Write(ref pos, (ushort)hue);
}
if (flags != 0)
{
expectedData.Write(ref pos, (byte)flags);
}
// Length
expectedData.Slice(1, 2).Write((ushort)pos);
@ -321,6 +346,7 @@ namespace Server.Tests.Network.Packets
ushort count = 0;
for (var i = 0; i < 64; i++)
{
if ((content & (1ul << i)) != 0)
{
expectedData.Write(ref pos, 0x7FFFFFFF - i);
@ -344,6 +370,7 @@ namespace Server.Tests.Network.Packets
#endif
count++;
}
}
expectedData.Slice(1, 2).Write((ushort)pos); // Length
expectedData.Slice(3, 2).Write(count); // Count
@ -371,6 +398,7 @@ namespace Server.Tests.Network.Packets
ushort count = 0;
for (var i = 0; i < 64; i++)
{
if ((content & (1ul << i)) != 0)
{
expectedData.Write(ref pos, 0x7FFFFFFF - i);
@ -395,6 +423,7 @@ namespace Server.Tests.Network.Packets
#endif
count++;
}
}
expectedData.Slice(1, 2).Write((ushort)pos); // Length
expectedData.Slice(3, 2).Write(count); // Count
@ -489,7 +518,9 @@ namespace Server.Tests.Network.Packets
{
var child = cont.Items[i];
if (child.Deleted || !m.CanSee(child))
{
continue;
}
expectedData.Write(ref pos, child.Serial);
expectedData.Write(ref pos, (ushort)child.ItemID);
@ -539,7 +570,9 @@ namespace Server.Tests.Network.Packets
{
var child = cont.Items[i];
if (child.Deleted || !m.CanSee(child))
{
continue;
}
expectedData.Write(ref pos, child.Serial);
expectedData.Write(ref pos, (ushort)child.ItemID);

View file

@ -52,7 +52,9 @@ namespace Server.Tests.Network.Packets
{
length += 5 + entry.Name.Length;
if (entriesCount == 255)
{
break;
}
entriesCount++;
}
@ -104,7 +106,9 @@ namespace Server.Tests.Network.Packets
{
length += 5 + answer.Length;
if (answersCount == 255)
{
break;
}
answersCount++;
}
@ -171,10 +175,14 @@ namespace Server.Tests.Network.Packets
var range = entry.Range;
if (range == -1)
{
range = 18;
}
if (!(entry.Enabled && menu.From.InRange(item.GetWorldLocation(), range)))
{
flags |= CMEFlags.Disabled;
}
expectedData.Write(ref pos, (ushort)flags);
}
@ -218,20 +226,28 @@ namespace Server.Tests.Network.Packets
var color = entry.Color & 0xFFFF;
if (color != 0xFFFF)
{
flags |= CMEFlags.Colored;
}
var range = entry.Range;
if (range == -1)
{
range = 18;
}
if (!(entry.Enabled && menu.From.InRange(item.GetWorldLocation(), range)))
{
flags |= CMEFlags.Disabled;
}
expectedData.Write(ref pos, (ushort)flags);
if ((flags & CMEFlags.Colored) != 0)
{
expectedData.Write(ref pos, (ushort)color);
}
}
AssertThat.Equal(data, expectedData);

View file

@ -261,10 +261,22 @@ namespace Server.Tests.Network.Packets
int type;
var notSelf = beholder != beheld;
if (notSelf) type = 0;
else if (Core.HS && ns.ExtendedStatus) type = 6;
else if (Core.ML && ns.SupportsExpansion(Expansion.ML)) type = 5;
else type = Core.AOS ? 4 : 3;
if (notSelf)
{
type = 0;
}
else if (Core.HS && ns.ExtendedStatus)
{
type = 6;
}
else if (Core.ML && ns.SupportsExpansion(Expansion.ML))
{
type = 5;
}
else
{
type = Core.AOS ? 4 : 3;
}
expectedData.Write(ref pos, beheld.Serial);
expectedData.WriteAsciiFixed(ref pos, beheld.Name, 30);
@ -320,8 +332,12 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, beheld.TithingPoints);
if (type >= 6)
{
for (var i = 0; i < 15; ++i)
{
expectedData.Write(ref pos, (ushort)beheld.GetAOSStatus(i));
}
}
}
expectedData.Slice(1, 2).Write((ushort)pos); // Length
@ -502,9 +518,14 @@ namespace Server.Tests.Network.Packets
var count = items.Count;
if (beheld.HairItemID > 0)
{
count++;
}
if (beheld.FacialHairItemID > 0)
{
count++;
}
var length = 23 + count * 9; // Max Size
@ -645,9 +666,14 @@ namespace Server.Tests.Network.Packets
var count = items.Count;
if (beheld.HairItemID > 0)
{
count++;
}
if (beheld.FacialHairItemID > 0)
{
count++;
}
var length = 23 + count * 9; // Max Size
@ -686,7 +712,9 @@ namespace Server.Tests.Network.Packets
hue = isSolidHue ? beheld.SolidHueOverride : item.Hue;
if (hue != 0)
{
itemId |= 0x8000;
}
expectedData.Write(ref pos, item.Serial);
expectedData.Write(ref pos, (ushort)itemId);
@ -703,7 +731,9 @@ namespace Server.Tests.Network.Packets
hue = isSolidHue ? beheld.SolidHueOverride : beheld.HairHue;
if (hue != 0)
{
itemId |= 0x8000;
}
expectedData.Write(ref pos, HairInfo.FakeSerial(beheld));
expectedData.Write(ref pos, (ushort)itemId);
@ -719,7 +749,9 @@ namespace Server.Tests.Network.Packets
hue = isSolidHue ? beheld.SolidHueOverride : beheld.FacialHairHue;
if (hue != 0)
{
itemId |= 0x8000;
}
expectedData.Write(ref pos, FacialHairInfo.FakeSerial(beheld));
expectedData.Write(ref pos, (ushort)itemId);

View file

@ -374,9 +374,14 @@ namespace Server.Tests.Network.Packets
expectedData.WriteAsciiFixed(ref pos, title, 60);
byte flags = 0x00;
if (warmode)
{
flags |= 0x01;
}
if (canLift)
{
flags |= 0x02;
}
expectedData.Write(ref pos, flags);

View file

@ -34,7 +34,9 @@ namespace Server.Tests.Network.Packets
expectedData.Write(ref pos, secondCont.Serial);
expectedData.Write(ref pos, hasName);
if (hasName)
{
expectedData.WriteAsciiFixed(ref pos, name, 30);
}
AssertThat.Equal(data, expectedData);
}

View file

@ -19,7 +19,9 @@ namespace Server.Tests.Accounting.Security
{
var passwordProtection = Activator.CreateInstance(protectionType) as IPasswordProtection;
if (passwordProtection == null)
{
Assert.False(true, $"{protectionType.Name} is not an IPasswordProtection.");
}
var encryptedPassword = passwordProtection.EncryptPassword(plainPassword);
@ -36,7 +38,9 @@ namespace Server.Tests.Accounting.Security
{
var passwordProtection = Activator.CreateInstance(protectionType) as IPasswordProtection;
if (passwordProtection == null)
{
Assert.False(true, $"{protectionType.Name} is not an IPasswordProtection.");
}
var encryptedPassword = passwordProtection.EncryptPassword(plainPassword);

View file

@ -47,7 +47,9 @@ namespace Server.Accounting
var filePath = Path.Combine("Saves/Accounts", "accounts.xml");
if (!File.Exists(filePath))
{
return;
}
var doc = new XmlDocument();
doc.Load(filePath);
@ -55,6 +57,7 @@ namespace Server.Accounting
var root = doc["accounts"];
foreach (XmlElement account in root.GetElementsByTagName("account"))
{
try
{
new Account(account);
@ -63,12 +66,15 @@ namespace Server.Accounting
{
Console.WriteLine("Warning: Account instance load failed");
}
}
}
public static void Save(bool message)
{
if (!Directory.Exists("Saves/Accounts"))
{
Directory.CreateDirectory("Saves/Accounts");
}
var filePath = Path.Combine("Saves/Accounts", "accounts.xml");
@ -82,7 +88,9 @@ namespace Server.Accounting
xml.WriteAttributeString("count", m_Accounts.Count.ToString());
foreach (Account a in GetAccounts())
{
a.Save(xml);
}
xml.WriteEndElement();

View file

@ -22,7 +22,9 @@ namespace Server
line = line.Trim();
if (line.Length == 0)
{
continue;
}
List.Add(ToFirewallEntry(line));
@ -46,11 +48,19 @@ namespace Server
public static IFirewallEntry ToFirewallEntry(object entry)
{
if (entry is IFirewallEntry firewallEntry)
{
return firewallEntry;
}
if (entry is IPAddress address)
{
return new IPFirewallEntry(address);
}
if (entry is string s)
{
return ToFirewallEntry(s);
}
return null;
}
@ -58,15 +68,23 @@ namespace Server
public static IFirewallEntry ToFirewallEntry(string entry)
{
if (IPAddress.TryParse(entry, out var addr))
{
return new IPFirewallEntry(addr);
}
// Try CIDR parse
var str = entry.Split('/');
if (str.Length == 2)
{
if (IPAddress.TryParse(str[0], out var cidrPrefix))
{
if (int.TryParse(str[1], out var cidrLength))
{
return new CIDRFirewallEntry(cidrPrefix, cidrLength);
}
}
}
return new WildcardIPFirewallEntry(entry);
}
@ -91,17 +109,25 @@ namespace Server
public static void Add(object obj)
{
if (obj is IPAddress address)
{
Add(address);
}
else if (obj is string s)
{
Add(s);
}
else if (obj is IFirewallEntry entry)
{
Add(entry);
}
}
public static void Add(IFirewallEntry entry)
{
if (!List.Contains(entry))
{
List.Add(entry);
}
Save();
}
@ -111,7 +137,9 @@ namespace Server
var entry = ToFirewallEntry(pattern);
if (!List.Contains(entry))
{
List.Add(entry);
}
Save();
}
@ -121,7 +149,9 @@ namespace Server
IFirewallEntry entry = new IPFirewallEntry(ip);
if (!List.Contains(entry))
{
List.Add(entry);
}
Save();
}
@ -132,14 +162,20 @@ namespace Server
using var op = new StreamWriter(path);
for (var i = 0; i < List.Count; ++i)
{
op.WriteLine(List[i]);
}
}
public static bool IsBlocked(IPAddress ip)
{
for (var i = 0; i < List.Count; i++)
{
if (List[i].IsBlocked(ip))
{
return true;
}
}
return false;
/*
@ -182,11 +218,16 @@ namespace Server
public override bool Equals(object obj)
{
if (obj is IPAddress)
{
return obj.Equals(m_Address);
}
if (obj is string s)
{
if (IPAddress.TryParse(s, out var otherAddress))
{
return otherAddress.Equals(m_Address);
}
}
else if (obj is IPFirewallEntry entry)
{
@ -221,9 +262,15 @@ namespace Server
var str = entry.Split('/');
if (str.Length == 2)
{
if (IPAddress.TryParse(str[0], out var cidrPrefix))
{
if (int.TryParse(str[1], out var cidrLength))
{
return m_CIDRPrefix.Equals(cidrPrefix) && m_CIDRLength.Equals(cidrLength);
}
}
}
}
else if (obj is CIDRFirewallEntry cidrEntry)
{
@ -247,7 +294,9 @@ 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.
}
var matched = Utility.IPMatch(m_Entry, address, out var valid);
m_Valid = valid;
@ -259,7 +308,9 @@ namespace Server
public override bool Equals(object obj)
{
if (obj is string)
{
return obj.Equals(m_Entry);
}
return obj is WildcardIPFirewallEntry entry && m_Entry.Equals(entry.m_Entry);
}

View file

@ -27,7 +27,9 @@ namespace Server.Misc
public static bool Verify(IPAddress ourAddress)
{
if (!Enabled || IsExempt(ourAddress))
{
return true;
}
var netStates = TcpServer.Instances;
@ -42,7 +44,9 @@ namespace Server.Misc
++count;
if (count >= MaxAddresses)
{
return false;
}
}
}

View file

@ -46,7 +46,9 @@ namespace Server.Accounting.Security
);
if (CurrentAlgorithm < PasswordProtectionAlgorithm.SHA2)
{
throw new Exception($"Security: {CurrentAlgorithm} is obsolete and not secure. Do not use it.");
}
}
public static IPasswordProtection GetPasswordProtection(PasswordProtectionAlgorithm algorithm)

View file

@ -60,7 +60,10 @@ namespace Server.Commands
return;
}
if (!command.ValidateArgs(Scope, eventArgs[i])) return;
if (!command.ValidateArgs(Scope, eventArgs[i]))
{
return;
}
}
for (var i = 0; i < commands.Length; ++i)
@ -69,7 +72,9 @@ namespace Server.Commands
var bc = BatchCommands[i];
if (list.Count > 20)
{
CommandLogging.Enabled = false;
}
List<object> usedList;
@ -88,12 +93,15 @@ namespace Server.Commands
var obj = list[j];
if (obj == null)
{
continue;
}
var type = obj.GetType();
var failReason = "";
if (!propertyChains.TryGetValue(type, out var chain))
{
propertyChains[type] = chain = Properties.GetPropertyInfoChain(
e.Mobile,
type,
@ -101,21 +109,28 @@ namespace Server.Commands
PropertyAccess.Read,
ref failReason
);
}
if (chain == null)
{
continue;
}
var endProp = Properties.GetPropertyInfo(ref obj, chain, ref failReason);
if (endProp == null)
{
continue;
}
try
{
obj = endProp.GetValue(obj, null);
if (obj != null)
{
usedList.Add(obj);
}
}
catch
{
@ -127,7 +142,9 @@ namespace Server.Commands
command.ExecuteList(eventArgs[i], usedList);
if (list.Count > 20)
{
CommandLogging.Enabled = true;
}
command.Flush(e.Mobile, list.Count > 20);
}
@ -304,12 +321,16 @@ namespace Server.Commands
public override void OnResponse(NetState sender, RelayInfo info)
{
if (!SplitButtonID(info.ButtonID, 1, out var type, out var index))
{
return;
}
var entry = info.GetTextEntry(0);
if (entry != null)
{
m_Batch.Condition = entry.Text;
}
for (var i = m_Batch.BatchCommands.Count - 1; i >= 0; --i)
{
@ -318,15 +339,21 @@ namespace Server.Commands
entry = info.GetTextEntry(1 + i * 2);
if (entry != null)
{
sc.Command = entry.Text;
}
entry = info.GetTextEntry(2 + i * 2);
if (entry != null)
{
sc.Object = entry.Text;
}
if (sc.Command.Length == 0 && sc.Object.Length == 0)
{
m_Batch.BatchCommands.RemoveAt(i);
}
}
switch (type)
@ -388,7 +415,9 @@ namespace Server.Commands
var impl = BaseCommandImplementor.Implementors[i];
if (m_From.AccessLevel < impl.AccessLevel)
{
continue;
}
AddNewLine();
@ -402,6 +431,7 @@ namespace Server.Commands
public override void OnResponse(NetState sender, RelayInfo info)
{
if (SplitButtonID(info.ButtonID, 1, out var type, out var index))
{
switch (type)
{
case 0:
@ -411,12 +441,15 @@ namespace Server.Commands
var impl = BaseCommandImplementor.Implementors[index];
if (m_From.AccessLevel >= impl.AccessLevel)
{
m_Batch.Scope = impl;
}
}
break;
}
}
}
m_From.SendGump(new BatchGump(m_From, m_Batch));
}

View file

@ -38,10 +38,14 @@ namespace Server
protected override void OnTarget(Mobile from, object targeted)
{
if (!(targeted is IPoint3D p))
{
return;
}
if (p is Item item)
{
p = item.GetWorldTop();
}
if (m_First)
{

File diff suppressed because it is too large Load diff

View file

@ -19,7 +19,10 @@ namespace Server.Commands
{
var amount = 1;
if (e.Length >= 1)
{
amount = e.GetInt32(0);
}
e.Mobile.Target = new DupeTarget(false, amount > 0 ? amount : 1);
e.Mobile.SendMessage("What do you wish to dupe?");
}
@ -30,7 +33,9 @@ namespace Server.Commands
{
var amount = 1;
if (e.Length >= 1)
{
amount = e.GetInt32(0);
}
e.Mobile.Target = new DupeTarget(true, amount > 0 ? amount : 1);
e.Mobile.SendMessage("What do you wish to dupe?");
@ -41,14 +46,19 @@ namespace Server.Commands
var props = src.GetType().GetProperties();
for (var i = 0; i < props.Length; i++)
{
try
{
if (props[i].CanRead && props[i].CanWrite) props[i].SetValue(dest, props[i].GetValue(src, null), null);
if (props[i].CanRead && props[i].CanWrite)
{
props[i].SetValue(dest, props[i].GetValue(src, null), null);
}
}
catch
{
// Console.WriteLine( "Denied" );
}
}
}
private class DupeTarget : Target
@ -88,9 +98,13 @@ namespace Server.Commands
if (m_InBag)
{
if (copy.Parent is Container cont)
{
pack = cont;
}
else if (copy.Parent is Mobile m)
{
pack = m.Backpack;
}
}
else
{
@ -102,11 +116,16 @@ namespace Server.Commands
{
var paramList = c.GetParameters();
var args = paramList.Length == 0 ? null : new object[paramList.Length];
if (args != null) Array.Fill(args, Type.Missing);
if (args != null)
{
Array.Fill(args, Type.Missing);
}
try
{
from.SendMessage("Duping {0}...", m_Amount);
for (var i = 0; i < m_Amount; i++)
{
if (c.Invoke(args) is Item newItem)
{
CopyProperties(newItem, copy); // copy.Dupe( item, copy.Amount );
@ -114,21 +133,26 @@ namespace Server.Commands
newItem.Parent = null;
if (pack != null)
{
pack.DropItem(newItem);
}
else
newItem.MoveToWorld(from.Location, from.Map);
{
newItem.MoveToWorld(@from.Location, @from.Map);
}
newItem.InvalidateProperties();
CommandLogging.WriteLine(
from,
@from,
"{0} {1} duped {2} creating {3}",
from.AccessLevel,
CommandLogging.Format(from),
@from.AccessLevel,
CommandLogging.Format(@from),
CommandLogging.Format(targ),
CommandLogging.Format(newItem)
);
}
}
from.SendMessage("Done");
done = true;
@ -140,7 +164,10 @@ namespace Server.Commands
}
}
if (!done) from.SendMessage("Unable to dupe. Item must have a 0 parameter constructor.");
if (!done)
{
@from.SendMessage("Unable to dupe. Item must have a 0 parameter constructor.");
}
}
}
}

View file

@ -23,6 +23,7 @@ namespace Server.Commands
e.Mobile.SendMessage("This will delete all static items in the world. Please make a backup.");
foreach (var item in World.Items.Values)
{
if ((item is Static || item is BaseFloor || item is BaseWall)
&& item.RootParent == null)
{
@ -50,11 +51,14 @@ namespace Server.Commands
remove.Add(item);
w.Flush();
}
}
w.Close();
foreach (var item in remove)
{
item.Delete();
}
e.Mobile.SendMessage("Export complete. Exported {0} statics.", count);
}

View file

@ -32,14 +32,20 @@ namespace Server.Commands.Generic
public static bool IsAccessible(Mobile from, object obj)
{
if (from.AccessLevel >= AccessLevel.Administrator || obj == null)
{
return true;
}
Mobile mob = null;
if (obj is Mobile m)
{
mob = m;
}
else if (obj is Item item)
{
mob = item.RootParent as Mobile;
}
return mob == null || mob == from || from.AccessLevel > mob.AccessLevel;
}
@ -47,7 +53,9 @@ namespace Server.Commands.Generic
public virtual void ExecuteList(CommandEventArgs e, List<object> list)
{
for (var i = 0; i < list.Count; ++i)
{
Execute(e, list[i]);
}
}
public virtual void Execute(CommandEventArgs e, object obj)
@ -70,7 +78,9 @@ namespace Server.Commands.Generic
}
if (m_Responses.Count == 10)
{
return;
}
m_Responses.Add(new MessageEntry(message));
}
@ -89,7 +99,9 @@ namespace Server.Commands.Generic
}
if (m_Failures.Count == 10)
{
return;
}
m_Failures.Add(new MessageEntry(message));
}
@ -97,18 +109,26 @@ namespace Server.Commands.Generic
public void Flush(Mobile from, bool flushToLog)
{
if (m_Responses.Count > 0)
{
for (var i = 0; i < m_Responses.Count; ++i)
{
var entry = m_Responses[i];
from.SendMessage(entry.ToString());
@from.SendMessage(entry.ToString());
if (flushToLog)
CommandLogging.WriteLine(from, entry.ToString());
{
CommandLogging.WriteLine(@from, entry.ToString());
}
}
}
else
{
for (var i = 0; i < m_Failures.Count; ++i)
from.SendMessage(m_Failures[i].ToString());
{
@from.SendMessage(m_Failures[i].ToString());
}
}
m_Responses.Clear();
m_Failures.Clear();

View file

@ -80,7 +80,9 @@ namespace Server.Commands.Generic
var impl = impls[i];
if ((command.Supports & impl.SupportRequirement) != 0)
{
impl.Register(command);
}
}
}
}
@ -106,10 +108,16 @@ namespace Server.Commands.Generic
var condition = ObjectConditional.Parse(e.Mobile, ref args);
for (var i = 0; i < list.Count; ++i)
{
if (condition.CheckCondition(list[i]))
{
AddResponse("True - that object matches the condition.");
}
else
{
AddResponse("False - that object does not match the condition.");
}
}
}
catch (Exception ex)
{
@ -135,9 +143,13 @@ namespace Server.Commands.Generic
if (obj is Item item)
{
if (e.Mobile.PlaceInBackpack(item))
{
AddResponse("The item has been placed in your backpack.");
}
else
{
AddResponse("Your backpack could not hold the item.");
}
}
}
}
@ -194,9 +206,13 @@ 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.");
}
}
}
@ -217,14 +233,18 @@ namespace Server.Commands.Generic
if (okay)
{
if (echo)
gm.SendMessage("{0} : has opened their web browser to : {1}", from.Name, url);
{
gm.SendMessage("{0} : has opened their web browser to : {1}", @from.Name, url);
}
from.LaunchBrowser(url);
}
else
{
if (echo)
gm.SendMessage("{0} : has chosen not to open their web browser to : {1}", from.Name, url);
{
gm.SendMessage("{0} : has chosen not to open their web browser to : {1}", @from.Name, url);
}
from.SendMessage("You have chosen not to open your web browser.");
}
@ -259,9 +279,13 @@ namespace Server.Commands.Generic
);
if (echo)
{
AddResponse("Awaiting user confirmation...");
}
else
{
AddResponse("Open web browser request sent.");
}
mob.SendGump(
new WarningGump(
@ -295,7 +319,9 @@ namespace Server.Commands.Generic
public override void ExecuteList(CommandEventArgs e, List<object> list)
{
for (var i = 0; i < list.Count; ++i)
{
Execute(e, list[i], false);
}
}
}
@ -324,9 +350,13 @@ namespace Server.Commands.Generic
if (result == "The property has been increased." || result == "The properties have been increased." ||
result == "The property has been decreased." || result == "The properties have been decreased." ||
result == "The properties have been changed.")
{
AddResponse(result);
}
else
{
LogFailure(result);
}
}
else
{
@ -415,9 +445,13 @@ namespace Server.Commands.Generic
);
if (m_InGump)
mob.SendGump(new MessageSentGump(mob, from.Name, e.ArgString));
{
mob.SendGump(new MessageSentGump(mob, @from.Name, e.ArgString));
}
else
{
mob.SendMessage(e.ArgString);
}
}
}
@ -438,7 +472,9 @@ namespace Server.Commands.Generic
public override void ExecuteList(CommandEventArgs e, List<object> list)
{
if (e.Arguments.Length == 0)
{
return;
}
var packs = new List<Container>(list.Count);
@ -448,14 +484,22 @@ namespace Server.Commands.Generic
Container cont = null;
if (obj is Mobile mobile)
{
cont = mobile.Backpack;
}
else if (obj is Container container)
{
cont = container;
}
if (cont != null)
{
packs.Add(cont);
}
else
{
LogFailure("That is not a container.");
}
}
Add.Invoke(e.Mobile, e.Mobile.Location, e.Mobile.Location, e.Arguments, packs);
@ -513,12 +557,18 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (!(obj is IPoint3D p))
{
return;
}
if (p is Item item)
{
p = item.GetWorldTop();
}
else if (p is Mobile m)
{
p = m.Location;
}
Add.Invoke(e.Mobile, new Point3D(p), new Point3D(p), e.Arguments);
}
@ -539,7 +589,9 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (!(obj is IPoint3D p))
{
return;
}
var from = e.Mobile;
@ -617,7 +669,9 @@ namespace Server.Commands.Generic
}
if (mob.Items.IndexOf(item) == -1)
{
--i;
}
}
}
@ -634,9 +688,13 @@ namespace Server.Commands.Generic
}
if (takenAction)
{
AddResponse("They have been dismounted.");
}
else
{
LogFailure("They were not mounted.");
}
}
}
@ -698,9 +756,13 @@ namespace Server.Commands.Generic
var 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}.");
}
}
}
}
@ -720,18 +782,26 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (e.Length >= 1)
{
for (var i = 0; i < e.Length; ++i)
{
var result = Properties.GetValue(e.Mobile, obj, e.GetString(i));
if (result == "Property not found." || result == "Property is write only." ||
result.StartsWith("Getting this property"))
{
LogFailure(result);
}
else
{
AddResponse(result);
}
}
}
else
{
LogFailure("Format: Get <propertyName>");
}
}
}
@ -748,11 +818,17 @@ namespace Server.Commands.Generic
AccessLevel = level;
if (objects == ObjectTypes.Items)
{
Supports = CommandSupport.AllItems;
}
else if (objects == ObjectTypes.Mobiles)
{
Supports = CommandSupport.AllMobiles;
}
else
{
Supports = CommandSupport.All;
}
Commands = new[] { command };
ObjectTypes = objects;
@ -765,9 +841,13 @@ namespace Server.Commands.Generic
var result = Properties.SetValue(e.Mobile, obj, m_Name, m_Value);
if (result == "Property has been set.")
{
AddResponse(result);
}
else
{
LogFailure(result);
}
}
}
@ -786,17 +866,25 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (e.Length >= 2)
{
for (var i = 0; i + 1 < e.Length; i += 2)
{
var result = Properties.SetValue(e.Mobile, obj, e.GetString(i), e.GetString(i + 1));
if (result == "Property has been set.")
{
AddResponse(result);
}
else
{
LogFailure(result);
}
}
}
else
{
LogFailure("Format: Set <propertyName> <value>");
}
}
}
@ -1055,9 +1143,13 @@ namespace Server.Commands.Generic
m.Hidden = m_Value;
if (m_Value)
{
AddResponse("They have been hidden.");
}
else
{
AddResponse("They have been revealed.");
}
}
}
@ -1195,7 +1287,9 @@ namespace Server.Commands.Generic
public override void Execute(CommandEventArgs e, object obj)
{
if (!(obj is Item item))
{
return;
}
if (!item.IsLockedDown && !item.IsSecure)
{
@ -1204,11 +1298,13 @@ namespace Server.Commands.Generic
}
foreach (var 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

@ -36,19 +36,25 @@ namespace Server.Commands.Generic
house = null;
if (item == null || item is BaseMulti || item is HouseSign || staticsOnly && !(item is Static))
{
return DesignInsertResult.InvalidItem;
}
house = BaseHouse.FindHouseAt(item) as HouseFoundation;
if (house == null)
{
return DesignInsertResult.NotInHouse;
}
var x = item.X - house.X;
var y = item.Y - house.Y;
var z = item.Z - house.Z;
if (!TryInsertIntoState(house.CurrentState, item.ItemID, x, y, z))
{
return DesignInsertResult.OutsideHouseBounds;
}
TryInsertIntoState(house.DesignState, item.ItemID, x, y, z);
item.Delete();
@ -61,7 +67,9 @@ namespace Server.Commands.Generic
var mcl = state.Components;
if (x < mcl.Min.X || y < mcl.Min.Y || x > mcl.Max.X || y > mcl.Max.Y)
{
return false;
}
mcl.Add(itemID, x, y, z);
state.OnRevised();
@ -112,7 +120,9 @@ namespace Server.Commands.Generic
AddResponse("The item has been inserted into the house design.");
if (!foundations.Contains(house))
{
foundations.Add(house);
}
break;
}
@ -131,7 +141,9 @@ namespace Server.Commands.Generic
}
foreach (var house in foundations)
{
house.Delta(ItemDelta.Update);
}
}
else
{
@ -160,7 +172,9 @@ namespace Server.Commands.Generic
from.SendMessage("Your changes have been committed. Updating...");
foreach (var house in m_Foundations)
{
house.Delta(ItemDelta.Update);
}
}
}
@ -173,14 +187,20 @@ namespace Server.Commands.Generic
case DesignInsertResult.Valid:
{
if (m_Foundations.Count == 0)
from.SendMessage(
{
@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.");
{
@from.SendMessage("The item has been inserted into the house design.");
}
if (!m_Foundations.Contains(house))
{
m_Foundations.Add(house);
}
break;
}

View file

@ -29,10 +29,14 @@ namespace Server.Commands.Generic
var offset = 0;
if (Insensitive.Equals(e.GetString(0), "view"))
{
++offset;
}
while (offset < e.Length)
{
columns.Add(e.GetString(offset++));
}
}
e.Mobile.SendGump(new InterfaceGump(e.Mobile, columns.ToArray(), list, 0, null));
@ -75,9 +79,13 @@ namespace Server.Commands.Generic
AddNewPage();
if (m_Page > 0)
{
AddEntryButton(20, ArrowLeftID1, ArrowLeftID2, 1, ArrowLeftWidth, ArrowLeftHeight);
}
else
{
AddEntryHeader(20);
}
AddEntryHtml(
40 + m_Columns.Length * 130 - 20 + (m_Columns.Length - 2) * OffsetSize,
@ -87,9 +95,13 @@ namespace Server.Commands.Generic
);
if ((m_Page + 1) * EntriesPerPage < m_List.Count)
{
AddEntryButton(20, ArrowRightID1, ArrowRightID2, 2, ArrowRightWidth, ArrowRightHeight);
}
else
{
AddEntryHeader(20);
}
if (m_Columns.Length > 1)
{
@ -119,7 +131,9 @@ namespace Server.Commands.Generic
for (var j = 0; j < chain.Length; ++j)
{
if (j > 0)
{
m_Columns[i] += '.';
}
m_Columns[i] += chain[j].Name;
}
@ -143,12 +157,16 @@ namespace Server.Commands.Generic
if (obj is Item item)
{
if (!(isDeleted = item.Deleted))
{
AddEntryHtml(40 + 130, item.GetType().Name);
}
}
else if (obj is Mobile mob)
{
if (!(isDeleted = mob.Deleted))
{
AddEntryHtml(40 + 130, mob.Name);
}
}
if (isDeleted)
@ -156,7 +174,9 @@ namespace Server.Commands.Generic
AddEntryHtml(40 + 130, "(deleted)");
for (var j = 1; j < m_Columns.Length; ++j)
{
AddEntryHtml(130, "---");
}
AddEntryHeader(20);
}
@ -186,9 +206,13 @@ namespace Server.Commands.Generic
var p = Properties.GetPropertyInfo(ref src, chain, ref failReason);
if (p == null)
{
value = "---";
}
else
{
value = PropertiesGump.ValueToString(src, p);
}
}
AddEntryHtml(130, value);
@ -217,14 +241,18 @@ namespace Server.Commands.Generic
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;
}
@ -244,11 +272,17 @@ namespace Server.Commands.Generic
}
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;
@ -561,7 +595,9 @@ namespace Server.Commands.Generic
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));
@ -586,7 +622,9 @@ namespace Server.Commands.Generic
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));
}
break;
}

View file

@ -41,8 +41,12 @@ namespace Server.Commands.Generic
public bool IsValid(object obj)
{
for (var i = 0; i < Count; ++i)
{
if (!this[i].IsValid(obj))
{
return false;
}
}
return true;
}
@ -50,7 +54,9 @@ namespace Server.Commands.Generic
public void Filter(List<object> list)
{
for (var i = 0; i < Count; ++i)
{
this[i].Filter(list);
}
}
public static Extensions Parse(Mobile from, ref string[] args)
@ -64,17 +70,23 @@ namespace Server.Commands.Generic
for (var i = args.Length - 1; i >= 0; --i)
{
if (!ExtensionInfo.Table.TryGetValue(args[i], out var extInfo))
{
continue;
}
if (extInfo.IsFixedSize && i != size - extInfo.Size - 1)
{
throw new Exception("Invalid extended argument count.");
}
var ext = extInfo.Constructor();
ext.Parse(from, args, i + 1, size - i - 1);
if (ext is WhereExtension extension)
{
baseType = extension.Conditional.Type;
}
parsed.Add(ext);
@ -86,7 +98,9 @@ namespace Server.Commands.Generic
AssemblyEmitter emitter = null;
foreach (var update in parsed)
update.Optimize(from, baseType, ref emitter);
{
update.Optimize(@from, baseType, ref emitter);
}
if (size != args.Length)
{
@ -94,7 +108,9 @@ namespace Server.Commands.Generic
args = new string[size];
for (var i = 0; i < args.Length; ++i)
{
args[i] = old[i];
}
}
return parsed;

View file

@ -69,30 +69,50 @@ namespace Server.Commands.Generic
else
{
if (Value is int i)
{
method.Load(i);
}
else if (Value is long l)
{
method.Load(l);
}
else if (Value is float f)
{
method.Load(f);
}
else if (Value is double d)
{
method.Load(d);
}
else if (Value is char c)
{
method.Load(c);
}
else if (Value is bool b)
{
method.Load(b);
}
else if (Value is string s)
{
method.Load(s);
}
else if (Value is Enum e)
{
method.Load(e);
}
else
{
throw new InvalidOperationException("Unrecognized comparison value.");
}
}
}
public void Acquire(TypeBuilder typeBuilder, ILGenerator il, string fieldName)
{
if (!(Value is string toParse))
{
return;
}
if (!Type.IsValueType && toParse == "null")
{
@ -101,7 +121,9 @@ namespace Server.Commands.Generic
else if (Type == typeof(string))
{
if (toParse == @"@""null""")
{
toParse = "null";
}
Value = toParse;
}
@ -169,7 +191,9 @@ namespace Server.Commands.Generic
il.Emit(OpCodes.Ldstr, toParse);
if (parseArgs.Length == 2) // dirty evil hack :-(
{
il.Emit(OpCodes.Ldc_I4, (int)parseArgs[1]);
}
il.Emit(OpCodes.Call, parseMethod);
il.Emit(OpCodes.Stfld, Field);
@ -330,7 +354,9 @@ namespace Server.Commands.Generic
}
if (m_Not != inverse)
{
emitter.LogicalNot();
}
}
}
@ -437,7 +463,9 @@ namespace Server.Commands.Generic
}
if (m_Not != inverse)
{
emitter.LogicalNot();
}
}
}
@ -464,7 +492,9 @@ namespace Server.Commands.Generic
il.Emit(OpCodes.Call, typeof(object).GetConstructor(Type.EmptyTypes));
for (var i = 0; i < conditions.Length; ++i)
{
conditions[i].Construct(typeBuilder, il, i);
}
// return;
il.Emit(OpCodes.Ret);

View file

@ -94,7 +94,9 @@ namespace Server.Commands.Generic
);
if (!couldCompare)
{
throw new InvalidOperationException("Property is not comparable.");
}
emitter.StoreLocal(v);
}
@ -225,7 +227,9 @@ namespace Server.Commands.Generic
}
if (i > 0)
{
emitter.Xor();
}
}
emitter.Return();

View file

@ -39,7 +39,9 @@ namespace Server.Commands.Generic
m_Order = Math.Sign(value);
if (m_Order == 0)
{
throw new InvalidOperationException("Sign cannot be zero.");
}
}
}
}
@ -133,7 +135,9 @@ namespace Server.Commands.Generic
);
if (!couldCompare)
{
throw new InvalidOperationException("Property is not comparable.");
}
emitter.StoreLocal(v);
}

View file

@ -24,7 +24,9 @@ namespace Server.Commands.Generic
public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly)
{
if (baseType == null)
{
throw new Exception("Distinct extension may only be used in combination with an object conditional.");
}
foreach (var prop in m_Properties)
{
@ -40,7 +42,9 @@ namespace Server.Commands.Generic
public override void Parse(Mobile from, string[] arguments, int offset, int size)
{
if (size < 1)
{
throw new Exception("Invalid distinction syntax.");
}
var end = offset + size;
@ -55,7 +59,9 @@ namespace Server.Commands.Generic
public override void Filter(List<object> list)
{
if (m_Comparer == null)
{
throw new InvalidOperationException("The extension must first be optimized.");
}
var copy = new List<object>(list);

View file

@ -21,13 +21,17 @@ namespace Server.Commands.Generic
Limit = Utility.ToInt32(arguments[offset]);
if (Limit < 0)
{
throw new Exception("Limit cannot be less than zero.");
}
}
public override void Filter(List<object> list)
{
if (list.Count > Limit)
{
list.RemoveRange(Limit, list.Count - Limit);
}
}
}
}

View file

@ -23,7 +23,9 @@ namespace Server.Commands.Generic
public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly)
{
if (baseType == null)
{
throw new Exception("The ordering extension may only be used in combination with an object conditional.");
}
foreach (var order in m_Orders)
{
@ -39,7 +41,9 @@ namespace Server.Commands.Generic
public override void Parse(Mobile from, string[] arguments, int offset, int size)
{
if (size < 1)
{
throw new Exception("Invalid ordering syntax.");
}
if (Insensitive.Equals(arguments[offset], "by"))
{
@ -47,7 +51,9 @@ namespace Server.Commands.Generic
--size;
if (size < 1)
{
throw new Exception("Invalid ordering syntax.");
}
}
var end = offset + size;
@ -91,7 +97,9 @@ namespace Server.Commands.Generic
public override void Filter(List<object> list)
{
if (m_Comparer == null)
{
throw new InvalidOperationException("The extension must first be optimized.");
}
list.Sort(m_Comparer);
}

View file

@ -18,7 +18,9 @@ namespace Server.Commands.Generic
public override void Optimize(Mobile from, Type baseType, ref AssemblyEmitter assembly)
{
if (baseType == null)
{
throw new InvalidOperationException("Insanity.");
}
Conditional.Compile(ref assembly);
}
@ -26,7 +28,9 @@ namespace Server.Commands.Generic
public override void Parse(Mobile from, string[] arguments, int offset, int size)
{
if (size < 1)
{
throw new Exception("Invalid condition syntax.");
}
Conditional = ObjectConditional.ParseDirect(from, arguments, offset, size);
}

View file

@ -34,18 +34,26 @@ namespace Server.Commands.Generic
var ext = Extensions.Parse(from, ref args);
if (!CheckObjectTypes(from, command, ext, out var items, out var mobiles))
{
return;
}
if (!(items || mobiles))
{
return;
}
var eable = map.GetObjectsInBounds(rect, items, mobiles);
var objs = new List<object>();
foreach (var obj in eable)
if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(from, obj) && ext.IsValid(obj))
{
if ((!mobiles || obj is Mobile) && BaseCommand.IsAccessible(@from, obj) && ext.IsValid(obj))
{
objs.Add(obj);
}
}
eable.Free();
ext.Filter(objs);

View file

@ -86,7 +86,9 @@ namespace Server.Commands.Generic
public virtual void Register(BaseCommand command)
{
for (var i = 0; i < command.Commands.Length; ++i)
{
Commands[command.Commands[i]] = command;
}
}
public bool CheckObjectTypes(Mobile from, BaseCommand command, Extensions ext, out bool items, out bool mobiles)
@ -96,12 +98,14 @@ namespace Server.Commands.Generic
var cond = ObjectConditional.Empty;
foreach (var check in ext)
{
if (check is WhereExtension extension)
{
cond = extension.Conditional;
break;
}
}
var condIsItem = cond.IsItem;
var condIsMobile = cond.IsMobile;
@ -112,10 +116,14 @@ namespace Server.Commands.Generic
case ObjectTypes.Both:
{
if (condIsItem)
{
items = true;
}
if (condIsMobile)
{
mobiles = true;
}
break;
}
@ -171,7 +179,9 @@ namespace Server.Commands.Generic
public string GenerateArgString(string[] args)
{
if (args.Length == 0)
{
return "";
}
// NOTE: this does not preserve the case where quotation marks are used on a single word
@ -180,7 +190,9 @@ namespace Server.Commands.Generic
for (var i = 0; i < args.Length; ++i)
{
if (i > 0)
{
sb.Append(' ');
}
if (args[i].IndexOf(' ') >= 0)
{
@ -204,16 +216,22 @@ namespace Server.Commands.Generic
var e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args);
if (!command.ValidateArgs(this, e))
{
return;
}
var flushToLog = false;
if (obj is List<object> list)
{
if (list.Count > 20)
{
CommandLogging.Enabled = false;
}
else if (list.Count == 0)
{
command.LogFailure("Nothing was found to use this command on.");
}
command.ExecuteList(e, list);
@ -226,9 +244,13 @@ namespace Server.Commands.Generic
else if (obj != null)
{
if (command.ListOptimized)
{
command.ExecuteList(e, new List<object> { obj });
}
else
{
command.Execute(e, obj);
}
}
command.Flush(from, flushToLog);
@ -264,7 +286,9 @@ namespace Server.Commands.Generic
var args = new string[oldArgs.Length - 1];
for (var i = 0; i < args.Length; ++i)
{
args[i] = oldArgs[i + 1];
}
Process(e.Mobile, command, args);
}
@ -278,10 +302,14 @@ namespace Server.Commands.Generic
public void Register()
{
if (Accessors == null)
{
return;
}
for (var i = 0; i < Accessors.Length; ++i)
{
CommandSystem.Register(Accessors[i], AccessLevel, Execute);
}
}
public static void Register(BaseCommandImplementor impl)

View file

@ -20,13 +20,15 @@ namespace Server.Commands.Generic
public override void Process(Mobile from, BaseCommand command, string[] args)
{
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
from.BeginTarget(
{
@from.BeginTarget(
-1,
command.ObjectTypes == ObjectTypes.All,
TargetFlags.None,
(m, targeted, a) => OnTarget(m, targeted, command, a),
args
);
}
}
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
@ -38,7 +40,9 @@ namespace Server.Commands.Generic
}
if (command.ObjectTypes == ObjectTypes.Mobiles)
{
return; // sanity check
}
if (!(targeted is Container cont))
{
@ -51,7 +55,9 @@ namespace Server.Commands.Generic
var ext = Extensions.Parse(from, ref args);
if (!CheckObjectTypes(from, command, ext, out var items, out var _))
{
return;
}
if (!items)
{
@ -62,8 +68,12 @@ namespace Server.Commands.Generic
var list = new List<object>();
foreach (var item in cont.FindItemsByType<Item>())
{
if (ext.IsValid(item))
{
list.Add(item);
}
}
ext.Filter(list);

View file

@ -18,12 +18,16 @@ namespace Server.Commands.Generic
var impl = AreaCommandImplementor.Instance;
if (impl == null)
{
return;
}
var map = from.Map;
if (map == null || map == Map.Internal)
{
return;
}
impl.OnTarget(from, map, Point3D.Zero, new Point3D(map.Width - 1, map.Height - 1, 0), command, args);
}

View file

@ -23,19 +23,33 @@ namespace Server.Commands.Generic
var ext = Extensions.Parse(from, ref args);
if (!CheckObjectTypes(from, command, ext, out var items, out var mobiles))
{
return;
}
var list = new List<object>();
if (items)
{
foreach (var item in World.Items.Values)
{
if (ext.IsValid(item))
{
list.Add(item);
}
}
}
if (mobiles)
{
foreach (var mob in World.Mobiles.Values)
{
if (ext.IsValid(mob))
{
list.Add(mob);
}
}
}
ext.Filter(list);

View file

@ -25,7 +25,9 @@ namespace Server.Commands.Generic
var ext = Extensions.Parse(from, ref args);
if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles))
{
return;
}
if (!mobiles) // sanity check
{

View file

@ -16,13 +16,15 @@ namespace Server.Commands.Generic
public override void Process(Mobile from, BaseCommand command, string[] args)
{
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
from.BeginTarget(
{
@from.BeginTarget(
-1,
command.ObjectTypes == ObjectTypes.All,
TargetFlags.None,
(m, targeted, a) => OnTarget(m, targeted, command, a),
args
);
}
}
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)

View file

@ -35,13 +35,17 @@ namespace Server.Commands.Generic
m_Conditionals = new IConditional[m_Conditions.Length];
for (var i = 0; i < m_Conditionals.Length; ++i)
{
m_Conditionals[i] = ConditionalCompiler.Compile(emitter, Type, m_Conditions[i], i);
}
}
public bool CheckCondition(object obj)
{
if (Type == null)
{
return true; // null type means no condition
}
if (!HasCompiled)
{
@ -51,8 +55,12 @@ namespace Server.Commands.Generic
}
for (var i = 0; i < m_Conditionals.Length; ++i)
{
if (m_Conditionals[i].Verify(obj))
{
return true;
}
}
return false; // all conditions false
}
@ -62,6 +70,7 @@ namespace Server.Commands.Generic
string[] conditionArgs = null;
for (var i = 0; i < args.Length; ++i)
{
if (Insensitive.Equals(args[i], "where"))
{
var origArgs = args;
@ -69,15 +78,20 @@ namespace Server.Commands.Generic
args = new string[i];
for (var j = 0; j < args.Length; ++j)
{
args[j] = origArgs[j];
}
conditionArgs = new string[origArgs.Length - i - 1];
for (var j = 0; j < conditionArgs.Length; ++j)
{
conditionArgs[j] = origArgs[i + j + 1];
}
break;
}
}
return ParseDirect(from, conditionArgs, 0, conditionArgs?.Length ?? 0);
}
@ -85,14 +99,18 @@ namespace Server.Commands.Generic
public static ObjectConditional ParseDirect(Mobile from, string[] args, int offset, int size)
{
if (args == null || size == 0)
{
return Empty;
}
var index = 0;
var objectType = AssemblyHandler.FindFirstTypeForName(args[offset + index], true);
if (objectType == null)
{
throw new Exception($"No type with that name ({args[offset + index]}) was found.");
}
++index;
@ -113,7 +131,9 @@ namespace Server.Commands.Generic
++index;
if (index >= size)
{
throw new Exception("Improperly formatted object conditional.");
}
}
else if (Insensitive.Equals(cur, "or") || cur == "||")
{
@ -134,13 +154,17 @@ namespace Server.Commands.Generic
index++;
if (index >= size)
{
throw new Exception("Improperly formatted object conditional.");
}
var oper = args[offset + index];
index++;
if (index >= size)
{
throw new Exception("Improperly formatted object conditional.");
}
var val = args[offset + index];
index++;
@ -181,7 +205,9 @@ namespace Server.Commands.Generic
};
if (condition == null)
{
throw new InvalidOperationException($"Unrecognized operator (\"{oper}\").");
}
current.Add(condition);
}

View file

@ -24,7 +24,9 @@ namespace Server.Commands.Generic
var ext = Extensions.Parse(from, ref args);
if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles))
{
return;
}
if (!mobiles) // sanity check
{
@ -42,13 +44,19 @@ namespace Server.Commands.Generic
var mob = ns.Mobile;
if (mob == null)
{
continue;
}
if (!BaseCommand.IsAccessible(from, mob))
{
continue;
}
if (ext.IsValid(mob))
{
list.Add(mob);
}
}
ext.Filter(list);

View file

@ -47,7 +47,9 @@ namespace Server.Commands.Generic
var args = new string[oldArgs.Length - 2];
for (var i = 0; i < args.Length; ++i)
{
args[i] = oldArgs[i + 2];
}
Process(range, e.Mobile, command, args);
}
@ -64,12 +66,16 @@ namespace Server.Commands.Generic
var impl = AreaCommandImplementor.Instance;
if (impl == null)
{
return;
}
var map = from.Map;
if (map == null || map == Map.Internal)
{
return;
}
var start = new Point3D(from.X - range, from.Y - range, from.Z);
var end = new Point3D(from.X + range, from.Y + range, from.Z);

View file

@ -23,7 +23,9 @@ namespace Server.Commands.Generic
var ext = Extensions.Parse(from, ref args);
if (!CheckObjectTypes(from, command, ext, out var _, out var mobiles))
{
return;
}
var reg = from.Region;
@ -34,10 +36,14 @@ namespace Server.Commands.Generic
foreach (var mob in reg.GetMobiles())
{
if (!BaseCommand.IsAccessible(from, mob))
{
continue;
}
if (ext.IsValid(mob))
{
list.Add(mob);
}
}
}
else

View file

@ -14,7 +14,9 @@ namespace Server.Commands.Generic
public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
{
if (command.ObjectTypes == ObjectTypes.Items)
{
return; // sanity check
}
obj = from;
}

View file

@ -20,9 +20,13 @@ namespace Server.Commands.Generic
object obj = null;
if (serial.IsItem)
{
obj = World.FindItem(serial);
}
else if (serial.IsMobile)
{
obj = World.FindMobile(serial);
}
if (obj == null)
{
@ -72,7 +76,9 @@ namespace Server.Commands.Generic
var args = new string[oldArgs.Length - 2];
for (var i = 0; i < args.Length; ++i)
{
args[i] = oldArgs[i + 2];
}
RunCommand(e.Mobile, obj, command, args);
}

View file

@ -19,7 +19,9 @@ namespace Server.Commands.Generic
base.Register(command);
for (var i = 0; i < command.Commands.Length; ++i)
{
CommandSystem.Register(command.Commands[i], command.AccessLevel, Redirect);
}
}
public void Redirect(CommandEventArgs e)
@ -27,23 +29,31 @@ namespace Server.Commands.Generic
Commands.TryGetValue(e.Command, out var 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 if (command.ValidateArgs(this, e))
{
Process(e.Mobile, command, e.Arguments);
}
}
public override void Process(Mobile from, BaseCommand command, string[] args)
{
if (command.ValidateArgs(this, new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args)))
from.BeginTarget(
{
@from.BeginTarget(
-1,
command.ObjectTypes == ObjectTypes.All,
TargetFlags.None,
(m, targeted, a) => OnTarget(m, targeted, command, a),
args
);
}
}
public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)

View file

@ -161,17 +161,25 @@ namespace Server.Commands
var pe = PageQueue.GetEntry(targ);
if (pe?.Handler == from)
from.SendMessage("You may only use this command if you are handling their help page.");
{
@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("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.");
{
@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("The item they were holding has been placed at their feet.");
}
held.ClearBounce();
@ -201,7 +209,9 @@ namespace Server.Commands
NetState.Pause();
for (var i = 0; i < list.Count; ++i)
{
list[i].Delete();
}
NetState.Resume();
@ -229,12 +239,20 @@ namespace Server.Commands
var list = new List<IEntity>();
foreach (var item in World.Items.Values)
{
if (item.Map == map && item.Parent == null)
{
list.Add(item);
}
}
foreach (var m in World.Mobiles.Values)
{
if (m.Map == map && !m.Player)
{
list.Add(m);
}
}
if (list.Count > 0)
{
@ -297,7 +315,9 @@ namespace Server.Commands
var pet = pets[i];
if (pet is IMount mount)
{
mount.Rider = null; // make sure it's dismounted
}
pet.MoveToWorld(from.Location, from.Map);
}
@ -312,9 +332,15 @@ namespace Server.Commands
var pets = new List<BaseCreature>();
foreach (var m in World.Mobiles.Values)
{
if (m is BaseCreature bc)
{
if (bc.Controlled && bc.ControlMaster == master || bc.Summoned && bc.SummonMaster == master)
{
pets.Add(bc);
}
}
}
if (pets.Count > 0)
{
@ -333,7 +359,9 @@ namespace Server.Commands
Mobile pet = pets[i];
if (pet is IMount mount)
{
mount.Rider = null; // make sure it's dismounted
}
pet.MoveToWorld(from.Location, from.Map);
}
@ -364,11 +392,17 @@ namespace Server.Commands
public static void Sound_OnCommand(CommandEventArgs e)
{
if (e.Length == 1)
{
PlaySound(e.Mobile, e.GetInt32(0), true);
}
else if (e.Length == 2)
{
PlaySound(e.Mobile, e.GetInt32(0), e.GetBoolean(1));
}
else
{
e.Mobile.SendMessage("Format: Sound <index> [toAll]");
}
}
private static void PlaySound(Mobile m, int index, bool toAll)
@ -376,7 +410,9 @@ namespace Server.Commands
var map = m.Map;
if (map == null)
{
return;
}
CommandLogging.WriteLine(
m,
@ -392,8 +428,12 @@ namespace Server.Commands
p.Acquire();
foreach (var state in m.GetClientsInRange(12))
{
if (toAll || state.Mobile.CanSee(m))
{
state.Send(p);
}
}
p.Release();
}
@ -405,9 +445,13 @@ namespace Server.Commands
var toEcho = e.ArgString.Trim();
if (toEcho.Length > 0)
{
e.Mobile.SendMessage(toEcho);
}
else
{
e.Mobile.SendMessage("Format: Echo \"<text>\"");
}
}
[Usage("Bank")]
@ -561,7 +605,9 @@ namespace Server.Commands
map = Map.AllMaps[i];
if (map.MapIndex == 0x7F || map.MapIndex == 0xFF)
{
continue;
}
if (Insensitive.Equals(name, map.Name))
{
@ -588,20 +634,28 @@ namespace Server.Commands
map = Map.AllMaps[i];
if (map.MapIndex == 0x7F || map.MapIndex == 0xFF || from.Map == map)
{
continue;
}
foreach (var r in map.Regions.Values)
{
if (Insensitive.Equals(r.Name, name))
{
from.MoveToWorld(r.GoLocation, map);
@from.MoveToWorld(r.GoLocation, map);
return;
}
}
}
if (ser != 0)
from.SendMessage("No object with that serial was found.");
{
@from.SendMessage("No object with that serial was found.");
}
else
from.SendMessage("No region with that name was found.");
{
@from.SendMessage("No region with that name was found.");
}
return;
}
@ -618,6 +672,7 @@ namespace Server.Commands
var map = from.Map;
if (map != null)
{
try
{
/*
@ -628,12 +683,13 @@ namespace Server.Commands
var y = int.Parse(e.GetString(1));
var z = e.Length == 3 ? int.Parse(e.GetString(2)) : map.GetAverageZ(x, y);
from.Location = new Point3D(x, y, z);
@from.Location = new Point3D(x, y, z);
}
catch
{
from.SendMessage("Region name not found.");
@from.SendMessage("Region name not found.");
}
}
}
else if (e.Length == 6)
{
@ -652,9 +708,13 @@ namespace Server.Commands
);
if (p != Point3D.Zero)
from.Location = p;
{
@from.Location = p;
}
else
from.SendMessage("Sextant reverse lookup failed.");
{
@from.SendMessage("Sextant reverse lookup failed.");
}
}
}
else
@ -672,15 +732,21 @@ namespace Server.Commands
var list = new List<CommandEntry>();
foreach (var entry in CommandSystem.Entries.Values)
{
if (m.AccessLevel >= entry.AccessLevel)
{
list.Add(entry);
}
}
list.Sort();
var sb = new StringBuilder();
if (list.Count > 0)
{
sb.Append(list[0].Command);
}
for (var i = 1; i < list.Count; ++i)
{
@ -700,7 +766,9 @@ namespace Server.Commands
}
if (sb.Length > 0)
{
m.SendAsciiMessage(0x482, sb.ToString());
}
}
[Usage("SMsg <text>")]
@ -727,7 +795,9 @@ namespace Server.Commands
var m = state.Mobile;
if (m?.AccessLevel >= ac)
{
m.SendMessage(hue, message);
}
}
}
@ -748,6 +818,7 @@ namespace Server.Commands
public static void Animate_OnCommand(CommandEventArgs e)
{
if (e.Length == 6)
{
e.Mobile.Animate(
e.GetInt32(0),
e.GetInt32(1),
@ -756,8 +827,11 @@ namespace Server.Commands
e.GetBoolean(4),
e.GetInt32(5)
);
}
else
{
e.Mobile.SendMessage("Format: Animate <action> <frameCount> <repeatCount> <forward> <repeat> <delay>");
}
}
[Usage("Cast <name>")]
@ -767,14 +841,20 @@ namespace Server.Commands
if (e.Length == 1)
{
if (!DesignContext.Check(e.Mobile))
{
return; // They are customizing
}
var spell = SpellRegistry.NewSpell(e.GetString(0), e.Mobile, null);
if (spell != null)
{
spell.Cast();
}
else
{
e.Mobile.SendMessage("That spell was not found.");
}
}
else
{
@ -820,7 +900,9 @@ namespace Server.Commands
}
if (targeted is Mobile mobile)
from.SendMenu(new EquipMenu(from, mobile, GetEquip(mobile)));
{
@from.SendMenu(new EquipMenu(@from, mobile, GetEquip(mobile)));
}
}
private static ItemListEntry[] GetEquip(Mobile m)
@ -949,9 +1031,13 @@ namespace Server.Commands
);
if (from == m)
{
box.Open();
}
else
box.DisplayTo(from);
{
box.DisplayTo(@from);
}
}
else
{
@ -988,10 +1074,14 @@ namespace Server.Commands
var mount = mountItem.Mount;
if (mount != null)
{
mount.Rider = null;
}
if (targ.Items.IndexOf(item) == -1)
{
--i;
}
}
}
@ -1042,9 +1132,13 @@ namespace Server.Commands
if (targeted is Mobile mobile)
{
if (mobile.AccessLevel >= from.AccessLevel && mobile != from)
from.SendMessage("You can't do that to someone with higher Accesslevel than you!");
{
@from.SendMessage("You can't do that to someone with higher Accesslevel than you!");
}
else
from.SendGump(new StuckMenu(from, mobile, false));
{
@from.SendGump(new StuckMenu(@from, mobile, false));
}
}
}
}

View file

@ -46,13 +46,17 @@ namespace Server.Commands
var numberStyles = arg.ToLower().StartsWith("0x") ? NumberStyles.HexNumber : NumberStyles.Integer;
if (int.TryParse(arg, numberStyles, CultureInfo.InvariantCulture, out var result))
{
graphics.Add(result);
}
}
}
var item = EffectItem.Create(new Point3D(point), e.Mobile.Map, EffectItem.DefaultDuration);
foreach (var graphic in graphics)
{
Effects.SendLocationParticles(item, graphic, 10, 50, 2023);
}
item.LabelTo(e.Mobile, label);
}

View file

@ -17,12 +17,16 @@ namespace Server.Commands
EventSink.Command += EventSink_Command;
if (!Directory.Exists("Logs"))
{
Directory.CreateDirectory("Logs");
}
var directory = "Logs/Commands";
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
try
{
@ -45,12 +49,17 @@ namespace Server.Commands
if (o is Mobile m)
{
if (m.Account == null)
{
return $"{m} (no account)";
}
return $"{m} ('{m.Account.Username}')";
}
if (o is Item item) return $"0x{item.Serial.Value:X} ({item.GetType().Name})";
if (o is Item item)
{
return $"0x{item.Serial.Value:X} ({item.GetType().Name})";
}
return o;
}
@ -58,7 +67,9 @@ namespace Server.Commands
public static void WriteLine(Mobile from, string format, params object[] args)
{
if (!Enabled)
{
return;
}
WriteLine(from, string.Format(format, args));
}
@ -66,7 +77,9 @@ namespace Server.Commands
public static void WriteLine(Mobile from, string text)
{
if (!Enabled)
{
return;
}
try
{
@ -95,28 +108,38 @@ namespace Server.Commands
path = Path.Combine(path, toAppend);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
}
public static string Safe(string ip)
{
if (ip == null)
{
return "null";
}
ip = ip.Trim().IsNullOrDefault("empty");
var isSafe = true;
for (var i = 0; isSafe && i < m_NotSafe.Length; ++i)
{
isSafe = ip.IndexOf(m_NotSafe[i]) == -1;
}
if (isSafe)
{
return ip;
}
var sb = new StringBuilder(ip);
for (var i = 0; i < m_NotSafe.Length; ++i)
{
sb.Replace(m_NotSafe[i], '_');
}
return sb.ToString();
}

View file

@ -64,14 +64,20 @@ namespace Server.Commands
sb.AppendFormat("{0} {1} building ", from.AccessLevel, CommandLogging.Format(from));
if (start == end)
sb.AppendFormat("at {0} in {1}", start, from.Map);
{
sb.AppendFormat("at {0} in {1}", start, @from.Map);
}
else
sb.AppendFormat("from {0} to {1} in {2}", start, end, from.Map);
{
sb.AppendFormat("from {0} to {1} in {2}", start, end, @from.Map);
}
sb.Append(":");
for (var i = 0; i < args.Length; ++i)
{
sb.AppendFormat(" \"{0}\"", args[i]);
}
CommandLogging.WriteLine(from, sb.ToString());
@ -82,6 +88,7 @@ namespace Server.Commands
string[,] props = null;
for (var i = 0; i < args.Length; ++i)
{
if (Insensitive.Equals(args[i], "set"))
{
var remains = args.Length - i - 1;
@ -103,6 +110,7 @@ namespace Server.Commands
break;
}
}
var type = AssemblyHandler.FindFirstTypeForName(name);
@ -117,14 +125,18 @@ namespace Server.Commands
var built = BuildObjects(from, type, start, end, args, props, packs, outline, mapAvg);
if (built > 0)
from.SendMessage(
{
@from.SendMessage(
"{0} object{1} generated in {2:F1} seconds.",
built,
built != 1 ? "s" : "",
(DateTime.UtcNow - time).TotalSeconds
);
}
else
SendUsage(type, from);
{
SendUsage(type, @from);
}
}
public static void FixSetString(ref string[] args, int index)
@ -166,8 +178,12 @@ namespace Server.Commands
var propName = props[i, 0];
for (var j = 0; thisProp == null && j < allProps.Length; ++j)
{
if (Insensitive.Equals(propName, allProps[j].Name))
{
thisProp = allProps[j];
}
}
if (thisProp == null)
{
@ -178,17 +194,25 @@ namespace Server.Commands
var attr = Properties.GetCPA(thisProp);
if (attr == null)
from.SendMessage("Property ({0}) not found.", propName);
{
@from.SendMessage("Property ({0}) not found.", propName);
}
else if (from.AccessLevel < attr.WriteLevel)
from.SendMessage(
{
@from.SendMessage(
"Setting this property ({0}) requires at least {1} access level.",
propName,
Mobile.GetAccessLevelName(attr.WriteLevel)
);
}
else if (!thisProp.CanWrite || attr.ReadOnly)
from.SendMessage("Property ({0}) is read only.", propName);
{
@from.SendMessage("Property ({0}) is read only.", propName);
}
else
{
realProps[i] = thisProp;
}
}
}
}
@ -200,7 +224,9 @@ namespace Server.Commands
var ctor = ctors[i];
if (!IsConstructible(ctor, from.AccessLevel))
{
continue;
}
// Handle optional constructors
var paramList = ctor.GetParameters();
@ -211,12 +237,16 @@ namespace Server.Commands
var paramValues = ParseValues(paramList, args);
if (paramValues == null)
{
continue;
}
var built = Build(from, start, end, ctor, paramValues, props, realProps, packs, outline, mapAvg);
if (built > 0)
{
return built;
}
}
}
@ -233,11 +263,17 @@ namespace Server.Commands
var value = ParseValue(param.ParameterType, a < args.Length ? args[a++] : null);
if (value != null)
{
values[i] = value;
}
else if (param.HasDefaultValue)
{
values[i] = Type.Missing;
}
else
{
return null;
}
}
return values;
@ -247,23 +283,43 @@ namespace Server.Commands
{
try
{
if (IsEnum(type)) return Enum.Parse(type, value, true);
if (IsType(type)) return AssemblyHandler.FindFirstTypeForName(value);
if (IsParsable(type)) return ParseParsable(type, value);
if (IsEnum(type))
{
return Enum.Parse(type, value, true);
}
if (IsType(type))
{
return AssemblyHandler.FindFirstTypeForName(value);
}
if (IsParsable(type))
{
return ParseParsable(type, value);
}
object obj = value;
if (value?.StartsWith("0x") == true)
{
if (IsSignedNumeric(type))
{
obj = Convert.ToInt64(value.Substring(2), 16);
}
else if (IsUnsignedNumeric(type))
{
obj = Convert.ToUInt64(value.Substring(2), 16);
}
else
{
obj = Convert.ToInt32(value.Substring(2), 16);
}
}
if (obj == null && !type.IsValueType)
{
return null;
}
return Convert.ChangeType(obj, type);
}
@ -287,7 +343,9 @@ namespace Server.Commands
for (var i = 0; i < realProps.Length; ++i)
{
if (realProps[i] == null)
{
continue;
}
var result =
Properties.InternalSetValue(from, built, built, realProps[i], props[i, 1], props[i, 1], false);
@ -295,14 +353,18 @@ namespace Server.Commands
if (result != "Property has been set.")
{
if (sendError)
from.SendMessage(result);
{
@from.SendMessage(result);
}
hadError = true;
}
}
if (hadError)
{
sendError = false;
}
}
return (IEntity)built;
@ -321,19 +383,29 @@ namespace Server.Commands
var height = end.Y - start.Y + 1;
if (outline && (width < 3 || height < 3))
{
outline = false;
}
int objectCount;
if (packs != null)
{
objectCount = packs.Count;
}
else if (outline)
{
objectCount = (width + height - 2) * 2;
}
else
{
objectCount = width * height;
}
if (objectCount >= 20)
from.SendMessage("Constructing {0} objects, please wait.", objectCount);
{
@from.SendMessage("Constructing {0} objects, please wait.", objectCount);
}
var sendError = true;
@ -349,9 +421,13 @@ namespace Server.Commands
sb.AppendFormat("0x{0:X}; ", built.Serial.Value);
if (built is Item item)
{
packs[i].DropItem(item);
}
else if (built is Mobile m)
{
m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map);
}
}
}
else
@ -359,23 +435,33 @@ namespace Server.Commands
var z = start.Z;
for (var x = start.X; x <= end.X; ++x)
{
for (var 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);
}
var built = Build(from, ctor, values, props, realProps, ref sendError);
var built = Build(@from, ctor, values, props, realProps, ref sendError);
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);
}
}
}
}
CommandLogging.WriteLine(from, sb.ToString());
@ -399,7 +485,9 @@ namespace Server.Commands
var ctor = ctors[i];
if (!IsConstructible(ctor, from.AccessLevel))
{
continue;
}
if (!foundCtor)
{
@ -411,7 +499,9 @@ namespace Server.Commands
}
if (!foundCtor)
from.SendMessage("That type is not marked constructible.");
{
@from.SendMessage("That type is not marked constructible.");
}
}
public static void SendCtor(Type type, ConstructorInfo ctor, Mobile from)
@ -425,7 +515,9 @@ namespace Server.Commands
for (var i = 0; i < paramList.Length; ++i)
{
if (i != 0)
{
sb.Append(',');
}
sb.Append(' ');
@ -463,16 +555,20 @@ namespace Server.Commands
var from = e.Mobile;
if (e.Length >= 1)
{
BoundingBoxPicker.Begin(
from,
@from,
(map, start, end) =>
TileBox_Callback(from, start, end, new TileState(TileZType.Start, 0, e.Arguments, outline))
TileBox_Callback(@from, start, end, new TileState(TileZType.Start, 0, e.Arguments, outline))
);
}
else
from.SendMessage(
{
@from.SendMessage(
"Format: {0} <type> [params] [set {{<propertyName> <value> ...}}]",
outline ? "Outline" : "Tile"
);
}
}
private static void InternalRXYZ_OnCommand(CommandEventArgs e, bool outline)
@ -485,7 +581,9 @@ namespace Server.Commands
var subArgs = new string[e.Length - 5];
for (var i = 0; i < subArgs.Length; ++i)
{
subArgs[i] = e.Arguments[i + 5];
}
Invoke(e.Mobile, p, p2, subArgs, null, outline);
}
@ -508,7 +606,9 @@ namespace Server.Commands
var subArgs = new string[e.Length - 5];
for (var i = 0; i < subArgs.Length; ++i)
{
subArgs[i] = e.Arguments[i + 5];
}
Invoke(e.Mobile, p, p2, subArgs, null, outline);
}
@ -530,7 +630,9 @@ namespace Server.Commands
var subArgs = new string[e.Length - 1];
for (var i = 0; i < subArgs.Length; ++i)
{
subArgs[i] = e.Arguments[i + 1];
}
BoundingBoxPicker.Begin(
from,
@ -552,16 +654,20 @@ namespace Server.Commands
var from = e.Mobile;
if (e.Length >= 1)
{
BoundingBoxPicker.Begin(
from,
@from,
(map, start, end) =>
TileBox_Callback(from, start, end, new TileState(TileZType.MapAverage, 0, e.Arguments, outline))
TileBox_Callback(@from, start, end, new TileState(TileZType.MapAverage, 0, e.Arguments, outline))
);
}
else
from.SendMessage(
{
@from.SendMessage(
"Format: {0}Avg <type> [params] [set {{<propertyName> <value> ...}}]",
outline ? "Outline" : "Tile"
);
}
}
[Usage("Tile <name> [params] [set {<propertyName> <value> ...}]")]
@ -681,8 +787,12 @@ namespace Server.Commands
public static bool IsSignedNumeric(Type type)
{
for (var i = 0; i < m_SignedNumerics.Length; ++i)
{
if (type == m_SignedNumerics[i])
{
return true;
}
}
return false;
}
@ -690,8 +800,12 @@ namespace Server.Commands
public static bool IsUnsignedNumeric(Type type)
{
for (var i = 0; i < m_UnsignedNumerics.Length; ++i)
{
if (type == m_UnsignedNumerics[i])
{
return true;
}
}
return false;
}

View file

@ -41,6 +41,7 @@ namespace Server.Gumps
AddAlphaRegion(10, 40, 400, 200);
if (searchResults.Length > 0)
{
for (var i = page * 10; i < (page + 1) * 10 && i < searchResults.Length; ++i)
{
var index = i % 10;
@ -48,23 +49,34 @@ namespace Server.Gumps
AddLabel(44, 39 + index * 20, 0x480, searchResults[i].Name);
AddButton(10, 39 + index * 20, 4023, 4025, 4 + i);
}
}
else
{
AddLabel(15, 44, 0x480, explicitSearch ? "Nothing matched your search terms." : "No results to display.");
}
AddImageTiled(10, 250, 400, 20, 2624);
AddAlphaRegion(10, 250, 400, 20);
if (m_Page > 0)
{
AddButton(10, 249, 4014, 4016, 2);
}
else
{
AddImage(10, 249, 4014);
}
AddHtmlLocalized(44, 250, 170, 20, 1061028, m_Page > 0 ? 0x7FFF : 0x5EF7); // Previous page
if ((m_Page + 1) * 10 < searchResults.Length)
{
AddButton(210, 249, 4005, 4007, 3);
}
else
{
AddImage(210, 249, 4005);
}
AddHtmlLocalized(
244,
@ -112,7 +124,9 @@ namespace Server.Gumps
private static void Match(string match, Type[] types, List<Type> results)
{
if (match.Length == 0)
{
return;
}
match = match.ToLower();
@ -126,12 +140,14 @@ namespace Server.Gumps
var ctors = t.GetConstructors();
for (var j = 0; j < ctors.Length; ++j)
{
if (ctors[j].GetParameters().Length == 0 &&
ctors[j].IsDefined(typeof(ConstructibleAttribute), false))
{
results.Add(t);
break;
}
}
}
}
}
@ -183,14 +199,18 @@ namespace Server.Gumps
case 2: // Previous page
{
if (m_Page > 0)
from.SendGump(new AddGump(from, m_SearchString, m_Page - 1, m_SearchResults, true));
{
@from.SendGump(new AddGump(@from, m_SearchString, m_Page - 1, m_SearchResults, true));
}
break;
}
case 3: // Next page
{
if ((m_Page + 1) * 10 < m_SearchResults.Length)
from.SendGump(new AddGump(from, m_SearchString, m_Page + 1, m_SearchResults, true));
{
@from.SendGump(new AddGump(@from, m_SearchString, m_Page + 1, m_SearchResults, true));
}
break;
}
@ -258,7 +278,9 @@ namespace Server.Gumps
protected override void OnTargetCancel(Mobile from, TargetCancelType cancelType)
{
if (cancelType == TargetCancelType.Canceled)
from.SendGump(new AddGump(from, m_SearchString, m_Page, m_SearchResults, true));
{
@from.SendGump(new AddGump(@from, m_SearchString, m_Page, m_SearchResults, true));
}
}
}
}

View file

@ -22,7 +22,9 @@ namespace Server.Commands
get
{
if (m_RootItems == null)
{
Load();
}
return m_RootItems;
}
@ -33,7 +35,9 @@ namespace Server.Commands
get
{
if (m_RootMobiles == null)
{
Load();
}
return m_RootMobiles;
}
@ -62,7 +66,9 @@ namespace Server.Commands
{
var list = new List<CAGJson>();
foreach (var ce in ceList)
{
RecurseExport(list, ce, null);
}
JsonConfig.Serialize(fileName, list);
}
@ -72,6 +78,7 @@ namespace Server.Commands
category = string.IsNullOrWhiteSpace(category) ? ce.Title : $"{category}{ce.Title}";
if (ce.Matched.Count > 0)
{
list.Add(
new CAGJson
{
@ -84,15 +91,21 @@ namespace Server.Commands
var itemID = item.ItemID;
if (item is BaseAddon addon && addon.Components.Count == 1)
{
itemID = addon.Components[0].ItemID;
}
if (itemID > TileData.MaxItemValue)
{
itemID = 1;
}
int? hue = item.Hue & 0x7FFF;
if ((hue & 0x4000) != 0)
{
hue = 0;
}
return new CAGObject
{
@ -109,7 +122,9 @@ namespace Server.Commands
int? hue = m.Hue & 0x7FFF;
if ((hue & 0x4000) != 0)
{
hue = 0;
}
return new CAGObject
{
@ -127,6 +142,7 @@ namespace Server.Commands
.ToArray()
}
);
}
var subCats = new List<CategoryEntry>(ce.SubCategories);
@ -146,7 +162,9 @@ namespace Server.Commands
AddTypes(Core.Assembly, types);
for (var i = 0; i < AssemblyHandler.Assemblies.Length; ++i)
{
AddTypes(AssemblyHandler.Assemblies[i], types);
}
m_RootItems = Load(types, "Data/items.cfg");
m_RootMobiles = Load(types, "Data/mobiles.cfg");
@ -156,7 +174,10 @@ namespace Server.Commands
{
var lines = CategoryLine.Load(config);
if (lines.Length <= 0) return new CategoryEntry();
if (lines.Length <= 0)
{
return new CategoryEntry();
}
var index = 0;
var root = new CategoryEntry(null, lines, ref index);
@ -169,7 +190,9 @@ namespace Server.Commands
private static bool IsConstructible(Type type)
{
if (!type.IsSubclassOf(typeofItem) && !type.IsSubclassOf(typeofMobile))
{
return false;
}
var ctor = type.GetConstructor(Type.EmptyTypes);
@ -185,10 +208,14 @@ namespace Server.Commands
var type = allTypes[i];
if (type.IsAbstract)
{
continue;
}
if (IsConstructible(type))
{
types.Add(type);
}
}
}
@ -200,7 +227,9 @@ namespace Server.Commands
var match = GetDeepestMatch(root, type);
if (match == null)
{
continue;
}
try
{
@ -216,14 +245,18 @@ namespace Server.Commands
private static CategoryEntry GetDeepestMatch(CategoryEntry root, Type type)
{
if (!root.IsMatch(type))
{
return null;
}
for (var i = 0; i < root.SubCategories.Length; ++i)
{
var check = GetDeepestMatch(root.SubCategories[i], type);
if (check != null)
{
return check;
}
}
return root;
@ -295,14 +328,18 @@ namespace Server.Commands
var start = text.IndexOf('(');
if (start < 0)
{
throw new FormatException($"Input string not correctly formatted ('{text}')");
}
Title = text.Substring(0, start).Trim();
var end = text.IndexOf(')', ++start);
if (end < start)
{
throw new FormatException($"Input string not correctly formatted ('{text}')");
}
text = text.Substring(start, end - start);
var split = text.Split(';');
@ -314,9 +351,13 @@ namespace Server.Commands
var type = AssemblyHandler.FindFirstTypeForName(split[i].Trim());
if (type == null)
{
Console.WriteLine("Match type not found ('{0}')", split[i].Trim());
}
else
{
list.Add(type);
}
}
Matches = list.ToArray();
@ -329,7 +370,9 @@ namespace Server.Commands
var entryList = new List<CategoryEntry>();
while (index < lines.Length && lines[index].Indentation > ourIndentation)
{
entryList.Add(new CategoryEntry(this, lines, ref index));
}
SubCategories = entryList.ToArray();
entryList.Clear();
@ -352,7 +395,9 @@ namespace Server.Commands
var isMatch = false;
for (var i = 0; !isMatch && i < Matches.Length; ++i)
{
isMatch = type == Matches[i] || type.IsSubclassOf(Matches[i]);
}
return isMatch;
}
@ -365,11 +410,17 @@ namespace Server.Commands
int index;
for (index = 0; index < input.Length; ++index)
{
if (char.IsLetter(input, index))
{
break;
}
}
if (index >= input.Length)
{
throw new FormatException($"Input string not correctly formatted ('{input}')");
}
Indentation = index;
Text = input.Substring(index);
@ -389,7 +440,9 @@ namespace Server.Commands
string line;
while ((line = ip.ReadLine()) != null)
{
list.Add(new CategoryLine(line));
}
}
return list.ToArray();

View file

@ -110,16 +110,22 @@ namespace Server.Gumps
var y = BorderSize + OffsetSize;
if (OldStyle)
{
AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID);
}
else
{
AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
}
if (m_Category.Parent != null)
{
AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1);
if (PrevLabel)
{
AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
}
}
x += PrevWidth + OffsetSize;
@ -128,6 +134,7 @@ namespace Server.Gumps
(OldStyle ? SetWidth + OffsetSize : 0);
if (!OldStyle)
{
AddImageTiled(
x - (OldStyle ? OffsetSize : 0),
y,
@ -135,6 +142,7 @@ namespace Server.Gumps
EntryHeight,
EntryGumpID
);
}
AddHtml(
x + TextOffsetX,
@ -147,29 +155,39 @@ namespace Server.Gumps
x += emptyWidth + OffsetSize;
if (OldStyle)
{
AddImageTiled(x, y, TotalWidth - OffsetSize * 3 - SetWidth, EntryHeight, HeaderGumpID);
}
else
{
AddImageTiled(x, y, PrevWidth, EntryHeight, HeaderGumpID);
}
if (page > 0)
{
AddButton(x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2);
if (PrevLabel)
{
AddLabel(x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous");
}
}
x += PrevWidth + OffsetSize;
if (!OldStyle)
{
AddImageTiled(x, y, NextWidth, EntryHeight, HeaderGumpID);
}
if ((page + 1) * EntryCount < nodes.Length)
{
AddButton(x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1);
if (NextLabel)
{
AddLabel(x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next");
}
}
for (int i = 0, index = page * EntryCount; i < EntryCount && index < nodes.Length; ++i, ++index)
@ -192,7 +210,9 @@ namespace Server.Gumps
x += EntryWidth + OffsetSize;
if (SetGumpID != 0)
{
AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
}
AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4);
@ -205,17 +225,21 @@ namespace Server.Gumps
if (itemID != 1 && bounds.Height < EntryHeight * 2)
{
if (bounds.Height < EntryHeight)
{
AddItem(
x - OffsetSize - 22 - i % 2 * 44 - bounds.Width / 2 - bounds.X,
y + EntryHeight / 2 - bounds.Height / 2 - bounds.Y,
itemID
);
}
else
{
AddItem(
x - OffsetSize - 22 - i % 2 * 44 - bounds.Width / 2 - bounds.X,
y + EntryHeight - 1 - bounds.Height - bounds.Y,
itemID
);
}
}
}
}
@ -238,7 +262,9 @@ namespace Server.Gumps
var index = Array.IndexOf(m_Category.Parent.Nodes, m_Category) / EntryCount;
if (index < 0)
{
index = 0;
}
from.SendGump(new CategorizedAddGump(from, m_Category.Parent, index));
}
@ -248,14 +274,18 @@ namespace Server.Gumps
case 2: // Previous
{
if (m_Page > 0)
from.SendGump(new CategorizedAddGump(from, m_Category, m_Page - 1));
{
@from.SendGump(new CategorizedAddGump(@from, m_Category, m_Page - 1));
}
break;
}
case 3: // Next
{
if ((m_Page + 1) * EntryCount < m_Category.Nodes.Length)
from.SendGump(new CategorizedAddGump(from, m_Category, m_Page + 1));
{
@from.SendGump(new CategorizedAddGump(@from, m_Category, m_Page + 1));
}
break;
}
@ -264,7 +294,9 @@ namespace Server.Gumps
var index = m_Page * EntryCount + (info.ButtonID - 4);
if (index >= 0 && index < m_Category.Nodes.Length)
m_Category.Nodes[index].OnClick(from, m_Page);
{
m_Category.Nodes[index].OnClick(@from, m_Page);
}
break;
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -56,13 +56,19 @@ namespace Server.Commands
void ProcessDeletion(TeleporterDefinition x)
{
count += TeleportersCreator.DeleteTeleporters(x.Source);
if (x.Back) count += TeleportersCreator.DeleteTeleporters(x.Destination);
if (x.Back)
{
count += TeleportersCreator.DeleteTeleporters(x.Destination);
}
}
if (!ProcessTeleporterData(from, ProcessDeletion))
{
if (count > 0)
from.SendMessage(WarningHue, $"Partial Completion, {count} Teleporters Removed.");
{
@from.SendMessage(WarningHue, $"Partial Completion, {count} Teleporters Removed.");
}
return;
}
@ -81,9 +87,15 @@ namespace Server.Commands
if (!ProcessTeleporterData(from, c.CreateTeleporter))
{
if (c.DelCount > 0)
from.SendMessage(WarningHue, $"Partial Completion: {c.DelCount} Teleporters Removed.");
{
@from.SendMessage(WarningHue, $"Partial Completion: {c.DelCount} Teleporters Removed.");
}
if (c.Count > 0)
from.SendMessage(WarningHue, $"Partial Completion: {c.Count} Teleporters Added.");
{
@from.SendMessage(WarningHue, $"Partial Completion: {c.Count} Teleporters Added.");
}
return;
}
@ -104,7 +116,9 @@ namespace Server.Commands
var teleporters = JsonSerializer.Deserialize<List<TeleporterDefinition>>(json, JsonOptions);
for (var i = 0; i < teleporters.Count; i++)
{
processor(teleporters[i]);
}
}
catch (Exception ex)
{
@ -144,7 +158,11 @@ namespace Server.Commands
DelCount += DeleteTeleporters(telDef.Source);
Count++;
new Teleporter(telDef.Destination, telDef.Destination.Map).MoveToWorld(telDef.Source, telDef.Source.Map);
if (!telDef.Back) return;
if (!telDef.Back)
{
return;
}
DelCount += DeleteTeleporters(telDef.Destination);
Count++;
new Teleporter(telDef.Source, telDef.Source.Map).MoveToWorld(telDef.Destination, telDef.Destination.Map);

View file

@ -60,9 +60,13 @@ namespace Server.Commands
public static void SetProfiles_OnCommand(CommandEventArgs e)
{
if (e.Length == 1)
{
Core.Profiling = e.GetBoolean(0);
}
else
{
Core.Profiling = !Core.Profiling;
}
e.Mobile.SendMessage("Profiling has been {0}.", Core.Profiling ? "enabled" : "disabled");
}
@ -148,29 +152,43 @@ namespace Server.Commands
var flags = item.GetExpandFlags();
if ((flags & ~(ExpandFlag.TempFlag | ExpandFlag.SaveFlag)) == 0)
{
continue;
}
var itemType = item.GetType();
do
{
if (!typeTable.TryGetValue(itemType, out var countTable))
{
typeTable[itemType] = countTable = new int[9];
}
if ((flags & ExpandFlag.Name) != 0)
{
++countTable[0];
}
if ((flags & ExpandFlag.Items) != 0)
{
++countTable[1];
}
if ((flags & ExpandFlag.Bounce) != 0)
{
++countTable[2];
}
if ((flags & ExpandFlag.Holder) != 0)
{
++countTable[3];
}
if ((flags & ExpandFlag.Blessed) != 0)
{
++countTable[4];
}
/*if (( flags & ExpandFlag.TempFlag ) != 0)
++countTable[5];
@ -179,10 +197,14 @@ namespace Server.Commands
++countTable[6];*/
if ((flags & ExpandFlag.Weight) != 0)
{
++countTable[7];
}
if ((flags & ExpandFlag.Spawner) != 0)
{
++countTable[8];
}
itemType = itemType.BaseType;
} while (itemType != typeof(object));
@ -215,8 +237,12 @@ namespace Server.Commands
op.WriteLine("# {0}", kvp.Key.FullName);
for (var i = 0; i < countTable.Length; ++i)
{
if (countTable[i] > 0)
{
op.WriteLine("{0}\t{1:N0}", names[i], countTable[i]);
}
}
op.WriteLine();
}
@ -237,7 +263,9 @@ namespace Server.Commands
foreach (var item in World.Items.Values)
{
if (item.Parent != null || item.Map != Map.Internal)
{
continue;
}
++totalCount;
@ -295,7 +323,9 @@ namespace Server.Commands
var count = bin.ReadInt32();
for (var i = 0; i < count; ++i)
{
types.Add(AssemblyHandler.FindFirstTypeForName(bin.ReadString()));
}
}
long total = 0;

View file

@ -58,11 +58,17 @@ namespace Server.Commands
var ent = World.FindEntity(e.GetUInt32(0));
if (ent == null)
{
e.Mobile.SendMessage("No object with that serial was found.");
}
else if (!BaseCommand.IsAccessible(e.Mobile, ent))
{
e.Mobile.SendLocalizedMessage(500447); // That is not accessible.
}
else
{
e.Mobile.SendGump(new PropertiesGump(e.Mobile, ent));
}
}
else
{
@ -77,7 +83,9 @@ namespace Server.Commands
var attrs = p.GetCustomAttributes(typeofCPA, false);
if (attrs.Length == 0)
{
return null;
}
return attrs[0] as CPA;
}
@ -90,7 +98,9 @@ namespace Server.Commands
var split = propertyString.Split('.');
if (split.Length == 0)
{
return null;
}
var info = new PropertyInfo[split.Length];
@ -99,7 +109,9 @@ namespace Server.Commands
var propertyName = split[i];
if (CIEqual(propertyName, "current"))
{
continue;
}
var props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);
@ -108,7 +120,9 @@ namespace Server.Commands
var access = endAccess;
if (!isFinal)
{
access |= PropertyAccess.Read;
}
for (var j = 0; j < props.Length; ++j)
{
@ -189,7 +203,9 @@ namespace Server.Commands
for (var i = 0; i < chain.Length - 1; ++i)
{
if (chain[i] == null)
{
continue;
}
obj = chain[i].GetValue(obj, null);
@ -210,7 +226,9 @@ namespace Server.Commands
var chain = GetPropertyInfoChain(from, o.GetType(), name, PropertyAccess.Read, ref failReason);
if (chain == null || chain.Length == 0)
{
return failReason;
}
var p = GetPropertyInfo(ref o, chain, ref failReason);
@ -237,9 +255,13 @@ namespace Server.Commands
var valueString = args[1 + i * 2];
if (valueString.StartsWith("0x"))
{
realValues[i] = Convert.ToInt32(valueString.Substring(2), 16);
}
else
{
realValues[i] = Convert.ToInt32(valueString);
}
}
catch
{
@ -247,21 +269,31 @@ namespace Server.Commands
}
if (realValues[i] > 0)
{
positive = true;
}
else if (realValues[i] < 0)
{
negative = true;
}
else
{
return "Zero is not a valid value to offset.";
}
string failReason = null;
realObjs[i] = o;
realProps[i] = GetPropertyInfo(from, ref realObjs[i], name, PropertyAccess.ReadWrite, ref failReason);
if (failReason != null)
{
return failReason;
}
if (realProps[i] == null)
{
return "Property not found.";
}
}
for (var i = 0; i < realProps.Length; ++i)
@ -269,7 +301,9 @@ namespace Server.Commands
var obj = realProps[i].GetValue(realObjs[i], null);
if (!(obj is IConvertible))
{
return "Property is not IConvertable.";
}
try
{
@ -287,16 +321,22 @@ namespace Server.Commands
if (realProps.Length == 1)
{
if (positive)
{
return "The property has been increased.";
}
return "The property has been decreased.";
}
if (positive && negative)
{
return "The properties have been changed.";
}
if (positive)
{
return "The properties have been increased.";
}
return "The properties have been decreased.";
}
@ -309,20 +349,34 @@ namespace Server.Commands
string toString;
if (value == null)
{
toString = "null";
}
else if (IsNumeric(type))
{
toString = $"{value} (0x{value:X})";
}
else if (IsChar(type))
{
toString = $"'{value}' ({(int)value} [0x{(int)value:X}])";
}
else if (IsString(type))
{
toString = (string)value == "null" ? @"@""null""" : $"\"{value}\"";
}
else if (IsText(type))
{
toString = ((TextDefinition)value).Format(false);
}
else
{
toString = value.ToString();
}
if (chain == null)
{
return $"{p.Name} = {toString}";
}
var concat = new string[chain.Length * 2 + 1];
@ -378,12 +432,17 @@ namespace Server.Commands
var isSerial = IsSerial(type);
if (isSerial) // mutate into int32
{
type = m_NumericTypes[4];
}
if (value == "(-null-)" && !type.IsValueType)
{
value = null;
}
if (IsEnum(type))
{
try
{
toSet = Enum.Parse(type, value ?? "", true);
@ -392,19 +451,25 @@ namespace Server.Commands
{
return "That is not a valid enumeration member.";
}
}
else if (IsType(type))
{
try
{
toSet = AssemblyHandler.FindFirstTypeForName(value);
if (toSet == null)
{
return "No type with that name was found.";
}
}
catch
{
return "No type with that name was found.";
}
}
else if (IsParsable(type))
{
try
{
toSet = Parse(obj, type, value);
@ -413,9 +478,13 @@ namespace Server.Commands
{
return "That is not properly formatted.";
}
}
else if (value == null)
{
toSet = null;
}
else if (value.StartsWith("0x") && IsNumeric(type))
{
try
{
toSet = Convert.ChangeType(Convert.ToUInt64(value.Substring(2), 16), type);
@ -424,7 +493,9 @@ namespace Server.Commands
{
return "That is not properly formatted.";
}
}
else
{
try
{
toSet = Convert.ChangeType(value, type);
@ -433,9 +504,12 @@ namespace Server.Commands
{
return "That is not properly formatted.";
}
}
if (isSerial) // mutate back
{
toSet = (Serial)(toSet ?? Serial.MinusOne);
}
constructed = toSet;
return null;
@ -453,21 +527,29 @@ namespace Server.Commands
var reqLevel = AccessLevel.Administrator;
if (newLevel == AccessLevel.Administrator)
{
reqLevel = AccessLevel.Developer;
}
else if (newLevel >= AccessLevel.Developer)
{
reqLevel = AccessLevel.Owner;
}
if (from.AccessLevel < reqLevel)
{
return "You do not have access to that level.";
}
}
if (shouldLog)
{
CommandLogging.LogChangeProperty(
from,
@from,
logObject,
givenName,
toSet?.ToString() ?? "(-null-)"
);
}
prop.SetValue(obj, toSet, null);
return "Property has been set.";
@ -482,7 +564,10 @@ namespace Server.Commands
{
try
{
if (toSet is AccessLevel) return "You do not have access to that level.";
if (toSet is AccessLevel)
{
return "You do not have access to that level.";
}
prop.SetValue(obj, toSet, null);
return "Property has been set.";
@ -521,9 +606,13 @@ namespace Server.Commands
protected override void OnTarget(Mobile from, object o)
{
if (!BaseCommand.IsAccessible(from, o))
from.SendLocalizedMessage(500447); // That is not accessible.
{
@from.SendLocalizedMessage(500447); // That is not accessible.
}
else
from.SendGump(new PropertiesGump(from, o));
{
@from.SendGump(new PropertiesGump(@from, o));
}
}
}
}
@ -655,7 +744,9 @@ namespace Server
get
{
if (!IsBound)
{
throw new NotYetBoundException(this);
}
return m_Chain;
}
@ -666,7 +757,9 @@ namespace Server
get
{
if (!IsBound)
{
throw new NotYetBoundException(this);
}
return m_Chain[^1].PropertyType;
}
@ -675,7 +768,9 @@ namespace Server
public bool CheckAccess(Mobile from)
{
if (!IsBound)
{
throw new NotYetBoundException(this);
}
for (var i = 0; i < m_Chain.Length; ++i)
{
@ -686,18 +781,26 @@ namespace Server
var access = Access;
if (!isFinal)
{
access |= PropertyAccess.Read;
}
var security = Properties.GetCPA(prop);
if (security == null)
{
throw new InternalAccessException(this);
}
if ((access & PropertyAccess.Read) != 0 && from.AccessLevel < security.ReadLevel)
throw new ReadAccessException(this, from.AccessLevel, security.ReadLevel);
{
throw new ReadAccessException(this, @from.AccessLevel, security.ReadLevel);
}
if ((access & PropertyAccess.Write) != 0 && (from.AccessLevel < security.WriteLevel || security.ReadOnly))
throw new WriteAccessException(this, from.AccessLevel, security.ReadLevel);
{
throw new WriteAccessException(this, @from.AccessLevel, security.ReadLevel);
}
}
return true;
@ -706,7 +809,9 @@ namespace Server
public void BindTo(Type objectType, PropertyAccess desiredAccess)
{
if (IsBound)
{
throw new AlreadyBoundException(this);
}
var split = Binding.Split('.');
@ -722,20 +827,28 @@ namespace Server
);
if (chain[i] == null)
{
throw new UnknownPropertyException(this, split[i]);
}
objectType = chain[i].PropertyType;
var access = desiredAccess;
if (!isFinal)
{
access |= PropertyAccess.Read;
}
if ((access & PropertyAccess.Read) != 0 && !chain[i].CanRead)
{
throw new WriteOnlyException(this);
}
if ((access & PropertyAccess.Write) != 0 && !chain[i].CanWrite)
{
throw new ReadOnlyException(this);
}
}
Access = desiredAccess;
@ -745,12 +858,16 @@ namespace Server
public override string ToString()
{
if (!IsBound)
{
return Binding;
}
var toJoin = new string[m_Chain.Length];
for (var i = 0; i < toJoin.Length; ++i)
{
toJoin[i] = m_Chain[i].Name;
}
return string.Join(".", toJoin);
}

View file

@ -74,7 +74,9 @@ namespace Server.Commands
};
for (var j = 0; maps?.Length > j; ++j)
{
Add_Static(e.m_ItemID, e.m_Location, maps[j], e.m_Text);
}
}
from.SendMessage("Sign generating complete.");
@ -90,13 +92,19 @@ namespace Server.Commands
var eable = map.GetItemsInRange(location, 0);
foreach (var item in eable)
{
if (item is Sign && item.Z == location.Z && item.ItemID == itemID)
{
m_ToDelete.Enqueue(item);
}
}
eable.Free();
while (m_ToDelete.Count > 0)
{
m_ToDelete.Dequeue().Delete();
}
Item sign;
@ -113,9 +121,13 @@ namespace Server.Commands
if (map == Map.Malas)
{
if (location.X >= 965 && location.Y >= 502 && location.X <= 1012 && location.Y <= 537)
{
sign.Hue = 0x47E;
}
else if (location.X >= 1960 && location.Y >= 1278 && location.X < 2106 && location.Y < 1413)
{
sign.Hue = 0x44E;
}
}
sign.MoveToWorld(location, map);

View file

@ -23,9 +23,13 @@ namespace Server.Commands
else
{
if (Enum.TryParse(arg.GetString(0), true, out SkillName skill))
{
arg.Mobile.Target = new SkillTarget(skill, arg.GetDouble(1));
}
else
{
arg.Mobile.SendLocalizedMessage(1005631); // You have specified an invalid skill to set.
}
}
}
@ -34,9 +38,13 @@ namespace Server.Commands
public static void SetAllSkills_OnCommand(CommandEventArgs arg)
{
if (arg.Length != 1)
{
arg.Mobile.SendMessage("SetAllSkills <value>");
}
else
{
arg.Mobile.Target = new AllSkillsTarget(arg.GetDouble(0));
}
}
[Usage("GetSkill <name>")]
@ -50,9 +58,13 @@ namespace Server.Commands
else
{
if (Enum.TryParse(arg.GetString(0), true, out SkillName skill))
{
arg.Mobile.Target = new SkillTarget(skill);
}
else
{
arg.Mobile.SendMessage("You have specified an invalid skill to get.");
}
}
}
@ -69,7 +81,9 @@ namespace Server.Commands
var skills = targ.Skills;
for (var i = 0; i < skills.Length; ++i)
{
skills[i].Base = m_Value;
}
CommandLogging.LogChangeProperty(from, targ, "EverySkill.Base", m_Value.ToString());
}
@ -106,7 +120,9 @@ namespace Server.Commands
var skill = targ.Skills[m_Skill];
if (skill == null)
{
return;
}
if (m_Set)
{

View file

@ -31,7 +31,9 @@ namespace Server.Commands
protected override void OnTarget(Mobile from, object o)
{
if (o is Mobile mobile)
from.SendGump(new SkillsGump(from, mobile));
{
@from.SendGump(new SkillsGump(@from, mobile));
}
}
}
}

View file

@ -63,8 +63,9 @@ namespace Server
var map = from.Map;
if (map != null && map != Map.Internal)
{
SendWarning(
from,
@from,
"You are about to freeze <u>all items in {0}</u>.",
BaseFreezeWarning,
map,
@ -72,6 +73,7 @@ namespace Server
NullP3D,
FreezeWarning_Callback
);
}
}
[Usage("FreezeWorld")]
@ -123,7 +125,9 @@ namespace Server
private static void FreezeWarning_Callback(Mobile from, bool okay, StateInfo si)
{
if (!okay)
{
return;
}
Freeze(from, si.m_Map, si.m_Start, si.m_End);
}
@ -135,43 +139,57 @@ namespace Server
if (start3d == NullP3D && end3d == NullP3D)
{
if (targetMap == null)
{
CommandLogging.WriteLine(
from,
@from,
"{0} {1} invoking freeze for every item in every map",
from.AccessLevel,
CommandLogging.Format(from)
@from.AccessLevel,
CommandLogging.Format(@from)
);
}
else
{
CommandLogging.WriteLine(
from,
@from,
"{0} {1} invoking freeze for every item in {0}",
from.AccessLevel,
CommandLogging.Format(from),
@from.AccessLevel,
CommandLogging.Format(@from),
targetMap
);
}
foreach (var item in World.Items.Values)
{
if (targetMap != null && item.Map != targetMap)
{
continue;
}
if (item.Parent != null)
{
continue;
}
if (item is Static || item is BaseFloor || item is BaseWall)
{
var itemMap = item.Map;
if (itemMap == null || itemMap == Map.Internal)
{
continue;
}
if (!mapTable.TryGetValue(itemMap, out var table))
{
mapTable[itemMap] = table = new Dictionary<Point2D, DeltaState>();
}
var p = new Point2D(item.X >> 3, item.Y >> 3);
if (!table.TryGetValue(p, out var state))
{
table[p] = state = new DeltaState(p);
}
state.m_List.Add(item);
}
@ -195,23 +213,31 @@ namespace Server
targetMap.GetItemsInBounds(new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1));
foreach (var item in eable)
{
if (item is Static || item is BaseFloor || item is BaseWall)
{
var itemMap = item.Map;
if (itemMap == null || itemMap == Map.Internal)
{
continue;
}
if (!mapTable.TryGetValue(itemMap, out var table))
{
mapTable[itemMap] = table = new Dictionary<Point2D, DeltaState>();
}
var p = new Point2D(item.X >> 3, item.Y >> 3);
if (!table.TryGetValue(p, out var state))
{
table[p] = state = new DeltaState(p);
}
state.m_List.Add(item);
}
}
eable.Free();
}
@ -268,7 +294,9 @@ namespace Server
);
if (oldTileCount < 0)
{
continue;
}
var newTileCount = 0;
var newTiles = new StaticTile[state.m_List.Count];
@ -281,7 +309,9 @@ namespace Server
var yOffset = item.Y - state.m_Y * 8;
if (xOffset < 0 || xOffset >= 8 || yOffset < 0 || yOffset >= 8)
{
continue;
}
var newTile = new StaticTile(
(ushort)item.ItemID,
@ -349,7 +379,8 @@ namespace Server
}
if (totalFrozen == 0 && badDataFile)
from.SendGump(
{
@from.SendGump(
new NoticeGump(
1060637,
30720,
@ -359,8 +390,10 @@ namespace Server
240
)
);
}
else
from.SendGump(
{
@from.SendGump(
new NoticeGump(
1060637,
30720,
@ -370,6 +403,7 @@ namespace Server
240
)
);
}
}
[Usage("Unfreeze")]
@ -387,6 +421,7 @@ namespace Server
var map = e.Mobile.Map;
if (map != null && map != Map.Internal)
{
SendWarning(
e.Mobile,
"You are about to unfreeze <u>all items in {0}</u>.",
@ -396,6 +431,7 @@ namespace Server
NullP3D,
UnfreezeWarning_Callback
);
}
}
[Usage("UnfreezeWorld")]
@ -429,7 +465,9 @@ namespace Server
private static void UnfreezeWarning_Callback(Mobile from, bool okay, StateInfo si)
{
if (!okay)
{
return;
}
Unfreeze(from, si.m_Map, si.m_Start, si.m_End);
}
@ -463,6 +501,7 @@ namespace Server
var mulWriter = new BinaryWriter(mulStream);
for (var x = xStartBlock; x <= xEndBlock; ++x)
{
for (var y = yStartBlock; y <= yEndBlock; ++y)
{
var oldTiles = ReadStaticBlock(
@ -476,7 +515,9 @@ namespace Server
);
if (oldTileCount < 0)
{
continue;
}
var newTileCount = 0;
var newTiles = new StaticTile[oldTileCount];
@ -543,6 +584,7 @@ namespace Server
matrix.SetStaticBlock(x, y, null);
}
}
}
public static void DoUnfreeze(Map map, ref bool badDataFile, ref int totalUnfrozen)
@ -598,7 +640,8 @@ namespace Server
}
if (totalUnfrozen == 0 && badDataFile)
from.SendGump(
{
@from.SendGump(
new NoticeGump(
1060637,
30720,
@ -608,8 +651,10 @@ namespace Server
240
)
);
}
else
from.SendGump(
{
@from.SendGump(
new NoticeGump(
1060637,
30720,
@ -619,12 +664,15 @@ namespace Server
240
)
);
}
}
private static FileStream OpenWrite(FileStream orig)
{
if (orig == null)
{
return null;
}
try
{
@ -665,18 +713,23 @@ namespace Server
mulStream.Seek(lookup, SeekOrigin.Begin);
if (m_TileBuffer.Length < count)
{
m_TileBuffer = new StaticTile[count];
}
var staTiles = m_TileBuffer;
if (m_Buffer == null || length > m_Buffer.Length)
{
m_Buffer = new byte[length];
}
mulStream.Read(m_Buffer, 0, length);
var index = 0;
for (var i = 0; i < count; ++i)
{
staTiles[i]
.Set(
(ushort)(m_Buffer[index++] | (m_Buffer[index++] << 8)),
@ -685,6 +738,7 @@ namespace Server
(sbyte)m_Buffer[index++],
(short)(m_Buffer[index++] | (m_Buffer[index++] << 8))
);
}
}
}
catch

View file

@ -47,7 +47,9 @@ namespace Server.Commands
pm.SendMessage("You are visible to {0} mobile{1}:", list.Count, list.Count == 1 ? "" : "s");
for (var i = 0; i < list.Count; ++i)
{
pm.SendMessage("#{0}: {1}", i + 1, list[i].Name);
}
}
else
{
@ -72,7 +74,9 @@ namespace Server.Commands
var m = list[i];
if (!m.CanSee(pm) && Utility.InUpdateRange(m, pm))
{
m.Send(pm.RemovePacket);
}
}
}
}
@ -117,7 +121,9 @@ namespace Server.Commands
ns.Send(pm.OPLPacket);
foreach (var item in pm.Items)
{
ns.Send(item.OPLPacket);
}
}
}
else

View file

@ -81,22 +81,34 @@ namespace Server.Commands
IPooledEnumerable<IEntity> eable;
if (!items && !multis || !mobiles)
{
return;
}
eable = map.GetObjectsInBounds(rect);
foreach (var obj in eable)
{
if (items && obj is Item && !(obj is BaseMulti || obj is HouseSign))
{
toDelete.Add(obj);
}
else if (multis && obj is BaseMulti)
{
toDelete.Add(obj);
}
else if (obj is Mobile mobile && !mobile.Player)
{
toDelete.Add(mobile);
}
}
eable.Free();
for (var i = 0; i < toDelete.Count; ++i)
{
toDelete[i].Delete();
}
}
}
}

View file

@ -29,8 +29,10 @@ namespace Server
AOS.DisableStatInfluences();
if (ObjectPropertyList.Enabled)
{
PacketHandlers.SingleClickProps =
true; // single click for everything is overridden to check object property list
}
Mobile.AOSStatusHandler = AOS.GetStatus;
}

View file

@ -19,19 +19,33 @@ namespace Server.ContextMenus
var mp = Party.Get(m_Target);
if (m_From == m_Target)
{
m_From.SendLocalizedMessage(1005439); // You cannot add yourself to a party.
}
else if (p != null && p.Leader != m_From)
{
m_From.SendLocalizedMessage(1005453); // You may only add members to the party if you are the leader.
}
else if (p != null && p.Members.Count + p.Candidates.Count >= Party.Capacity)
{
m_From.SendLocalizedMessage(1008095); // You may only have 10 in your party (this includes candidates).
}
else if (!m_Target.Player)
{
m_From.SendLocalizedMessage(1005444); // The creature ignores your offer.
}
else if (mp != null && mp == p)
{
m_From.SendLocalizedMessage(1005440); // This person is already in your party!
}
else if (mp != null)
{
m_From.SendLocalizedMessage(1005441); // This person is already in a party!
}
else
{
Party.Invite(m_From, m_Target);
}
}
}
}

View file

@ -13,7 +13,9 @@ namespace Server.ContextMenus
public override void OnClick()
{
if (Owner.From.CheckAlive() && Owner.Target is SpellScroll scroll)
{
Owner.From.Target = new InternalTarget(scroll);
}
}
private class InternalTarget : Target
@ -25,8 +27,9 @@ namespace Server.ContextMenus
protected override void OnTarget(Mobile from, object targeted)
{
if (targeted is Spellbook book)
if (from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 &&
m_Scroll.CheckItemUse(from))
{
if (@from.CheckAlive() && !m_Scroll.Deleted && m_Scroll.Movable && m_Scroll.Amount >= 1 &&
m_Scroll.CheckItemUse(@from))
{
var type = Spellbook.GetTypeForSpell(m_Scroll.SpellID);
@ -35,7 +38,7 @@ namespace Server.ContextMenus
}
else if (book.HasSpell(m_Scroll.SpellID))
{
from.SendLocalizedMessage(500179); // That spell is already present in that spellbook.
@from.SendLocalizedMessage(500179); // That spell is already present in that spellbook.
}
else
{
@ -47,10 +50,11 @@ namespace Server.ContextMenus
m_Scroll.Consume();
from.Send(new PlaySound(0x249, book.GetWorldLocation()));
@from.Send(new PlaySound(0x249, book.GetWorldLocation()));
}
}
}
}
}
}
}

View file

@ -16,7 +16,9 @@ namespace Server.ContextMenus
public override void OnClick()
{
if (m_Food?.Deleted != false || !m_Food.Movable || !m_From.CheckAlive() || !m_Food.CheckItemUse(m_From))
{
return;
}
m_Food.Eat(m_From);
}

View file

@ -18,7 +18,9 @@ namespace Server.ContextMenus
public override void OnClick()
{
if (!m_From.Alive || m_TargetHouse.Deleted || !m_TargetHouse.IsFriend(m_From))
{
return;
}
m_TargetHouse.Kick(m_From, m_Target);
}

View file

@ -9,12 +9,18 @@ namespace Server.ContextMenus
public override void OnClick()
{
if (!Owner.From.CheckAlive())
{
return;
}
if (Owner.From.Criminal)
{
m_Banker.Say(500378); // Thou art a criminal and cannot access thy bank box.
}
else
{
Owner.From.BankBox.Open();
}
}
}
}

View file

@ -16,13 +16,17 @@ namespace Server.ContextMenus
m_From = from;
if (!enabled)
{
Flags |= CMEFlags.Disabled;
}
}
public override void OnClick()
{
if (!m_From.CheckAlive())
{
return;
}
m_Mobile.Teach(m_Skill, m_From, 0, false);
}

View file

@ -11,7 +11,9 @@ namespace Server.Engines.BulkOrders
protected override void OnTarget(Mobile from, object targeted)
{
if (m_Deed.Deleted || !m_Deed.IsChildOf(from.Backpack))
{
return;
}
if (!(targeted is Item item && item.IsChildOf(from.Backpack)))
{

View file

@ -71,7 +71,9 @@ namespace Server.Engines.BulkOrders
for (var i = 0; i < chances.Length; ++i)
{
if (random < chances[i])
{
return i == 0 ? BulkMaterialType.None : start + (i - 1);
}
random -= chances[i];
}
@ -108,7 +110,9 @@ namespace Server.Engines.BulkOrders
var reward = rewardGroup.Items[i];
if (reward != null)
{
list.Add(reward);
}
}
}
else
@ -116,7 +120,9 @@ namespace Server.Engines.BulkOrders
var reward = rewardGroup.AcquireItem();
if (reward != null)
{
list.Add(reward);
}
}
return list;
@ -125,11 +131,15 @@ namespace Server.Engines.BulkOrders
public virtual void BeginCombine(Mobile from)
{
if (Complete)
from.SendLocalizedMessage(
{
@from.SendLocalizedMessage(
1045166
); // The maximum amount of requested items have already been combined to this deed.
}
else
from.Target = new BODTarget(this);
{
@from.Target = new BODTarget(this);
}
}
public override void Serialize(IGenericWriter writer)
@ -161,7 +171,9 @@ namespace Server.Engines.BulkOrders
}
if (Parent == null && Map == Map.Internal && Location == Point3D.Zero)
{
Delete();
}
}
}
}

View file

@ -129,7 +129,9 @@ namespace Server.Engines.BulkOrders
var number = filters[i, 0];
if (number == 0)
{
continue;
}
var isSelected = filters[i, 1] == filterValue ||
i % xOffsets.Length == 0 && filterValue == 0;
@ -201,7 +203,9 @@ namespace Server.Engines.BulkOrders
if (index >= 0 && index < filters.GetLength(0))
{
if (filters[index, 0] == 0)
{
break;
}
switch (type)
{

View file

@ -35,7 +35,9 @@ namespace Server.Engines.BulkOrders
var entry = book.Entries[i];
if (CheckFilter(entry))
{
list.Add(entry);
}
}
}
@ -62,7 +64,9 @@ namespace Server.Engines.BulkOrders
var width = 600;
if (!canPrice)
{
width = 516;
}
X = (624 - width) / 2;
@ -78,7 +82,9 @@ namespace Server.Engines.BulkOrders
}
if (canDrop)
{
AddImageTiled(24, 64, 32, 352, 1416);
}
AddImageTiled(58, 64, 36, 352, 200);
AddImageTiled(96, 64, 133, 352, 1416);
@ -91,7 +97,9 @@ namespace Server.Engines.BulkOrders
var entry = list[i];
if (!CheckFilter(entry))
{
continue;
}
AddImageTiled(24, 94 + tableIndex * 32, canPrice ? 573 : 489, 2, 2624);
tableIndex += entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
@ -116,17 +124,25 @@ namespace Server.Engines.BulkOrders
var f = from.UseOwnFilter ? from.BOBFilter : book.Filter;
if (f.IsDefault)
{
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062475, 16927); // Using No Filter
}
else if (from.UseOwnFilter)
{
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062451, 16927); // Using Your Filter
}
else
{
AddHtmlLocalized(canPrice ? 470 : 386, 32, 120, 32, 1062230, 16927); // Using Book Filter
}
AddButton(375, 416, 4017, 4018, 0);
AddHtmlLocalized(410, 416, 120, 20, 1011441, LabelColor); // EXIT
if (canDrop)
{
AddHtmlLocalized(26, 64, 50, 32, 1062212, LabelColor); // Drop
}
if (canPrice)
{
@ -164,14 +180,18 @@ namespace Server.Engines.BulkOrders
var entry = list[i];
if (!CheckFilter(entry))
{
continue;
}
if (entry is BOBLargeEntry largeEntry)
{
var y = 96 + tableIndex * 32;
if (canDrop)
{
AddButton(35, y + 2, 5602, 5606, 5 + i * 2);
}
if (canDrop || canBuy && entry.Price > 0)
{
@ -188,16 +208,24 @@ namespace Server.Engines.BulkOrders
AddHtmlLocalized(103, y, 130, 32, sub.Number, LabelColor);
if (entry.RequireExceptional)
{
AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional
}
else
{
AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal
}
var name = GetMaterialName(entry.Material, entry.DeedType, sub.ItemType);
if (name.Number > 0)
{
AddHtmlLocalized(316, y, 100, 20, name, LabelColor);
}
else
{
AddLabel(316, y, 1152, name);
}
AddLabel(421, y, 1152, $"{sub.AmountCur} / {entry.AmountMax}");
@ -212,7 +240,9 @@ namespace Server.Engines.BulkOrders
var y = 96 + tableIndex++ * 32;
if (canDrop)
{
AddButton(35, y + 2, 5602, 5606, 5 + i * 2);
}
if (canDrop || canBuy && smallEntry.Price > 0)
{
@ -225,16 +255,24 @@ namespace Server.Engines.BulkOrders
AddHtmlLocalized(103, y, 130, 32, smallEntry.Number, LabelColor);
if (smallEntry.RequireExceptional)
{
AddHtmlLocalized(235, y, 80, 20, 1060636, LabelColor); // exceptional
}
else
{
AddHtmlLocalized(235, y, 80, 20, 1011542, LabelColor); // normal
}
var name = GetMaterialName(smallEntry.Material, smallEntry.DeedType, smallEntry.ItemType);
if (name.Number > 0)
{
AddHtmlLocalized(316, y, 100, 20, name, LabelColor);
}
else
{
AddLabel(316, y, 1152, name);
}
AddLabel(421, y, 1152, $"{smallEntry.AmountCur} / {smallEntry.AmountMax}");
}
@ -244,6 +282,7 @@ namespace Server.Engines.BulkOrders
public bool CheckFilter(IBOBEntry entry)
{
if (entry is BOBLargeEntry largeEntry)
{
return CheckFilter(
entry.Material,
entry.AmountMax,
@ -252,8 +291,10 @@ namespace Server.Engines.BulkOrders
entry.DeedType,
largeEntry.Entries.Length > 0 ? largeEntry.Entries[0].ItemType : null
);
}
if (entry is BOBSmallEntry smallEntry)
{
return CheckFilter(
entry.Material,
entry.AmountMax,
@ -262,6 +303,7 @@ namespace Server.Engines.BulkOrders
entry.DeedType,
smallEntry.ItemType
);
}
return false;
}
@ -274,24 +316,44 @@ namespace Server.Engines.BulkOrders
var f = m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter;
if (f.IsDefault)
{
return true;
}
if (f.Quality == 1 && reqExc)
{
return false;
}
if (f.Quality == 2 && !reqExc)
{
return false;
}
if (f.Quantity == 1 && amountMax != 10)
{
return false;
}
if (f.Quantity == 2 && amountMax != 15)
{
return false;
}
if (f.Quantity == 3 && amountMax != 20)
{
return false;
}
if (f.Type == 1 && isLarge)
{
return false;
}
if (f.Type == 2 && !isLarge)
{
return false;
}
return f.Material switch
{
@ -320,7 +382,9 @@ namespace Server.Engines.BulkOrders
var index = 0;
while (page-- > 0)
{
index += GetCountForIndex(index);
}
return index;
}
@ -341,7 +405,9 @@ namespace Server.Engines.BulkOrders
var add = entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
if (slots + add > 10)
{
break;
}
slots += add;
}
@ -355,7 +421,9 @@ namespace Server.Engines.BulkOrders
public int GetPageForIndex(int index, int sizeDropped)
{
if (index <= 0)
{
return 0;
}
var count = 0;
var page = 0;
@ -366,7 +434,9 @@ namespace Server.Engines.BulkOrders
{
var entry = list[i];
if (!CheckFilter(entry))
{
continue;
}
var add = entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
count += add;
@ -393,13 +463,17 @@ namespace Server.Engines.BulkOrders
{
var entry = list[i];
if (CheckFilter(entry))
{
count += entry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
}
i++;
}
if (count > 10)
{
page++;
}
}
return page;
@ -433,7 +507,9 @@ namespace Server.Engines.BulkOrders
case BulkMaterialType.None:
{
if (itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes)))
{
return 1062235;
}
return 1044286;
}
@ -468,14 +544,18 @@ namespace Server.Engines.BulkOrders
case 2: // Previous page
{
if (m_Page > 0)
{
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page - 1, m_List));
}
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));
}
break;
}
@ -497,7 +577,9 @@ namespace Server.Engines.BulkOrders
index /= 2;
if (index < 0 || index >= m_List.Count)
{
break;
}
var bobEntry = m_List[index];
@ -570,7 +652,9 @@ namespace Server.Engines.BulkOrders
var vi = pv.GetVendorItem(m_Book);
if (vi?.IsForSale != false)
{
return;
}
var sizeOfDroppedBod = bobEntry is BOBLargeEntry largeEntry ? largeEntry.Entries.Length : 1;
var price = bobEntry.Price;
@ -635,7 +719,9 @@ namespace Server.Engines.BulkOrders
var entry = m_List[i];
if (!m_Book.Entries.Contains(entry))
{
continue;
}
entry.Price = price;
}
@ -643,14 +729,18 @@ namespace Server.Engines.BulkOrders
from.SendMessage("Deed prices set.");
if (from is PlayerMobile mobile)
{
mobile.SendGump(new BOBGump(mobile, m_Book, m_Page, m_List));
}
}
else
{
m_Entry.Price = price;
from.SendLocalizedMessage(1062384); // Deed price set.
if (from is PlayerMobile mobile)
{
mobile.SendGump(new BOBGump(mobile, m_Book, m_Page, m_List));
}
}
}
}

View file

@ -7,9 +7,13 @@ namespace Server.Engines.BulkOrders
RequireExceptional = bod.RequireExceptional;
if (bod is LargeTailorBOD)
{
DeedType = BODType.Tailor;
}
else if (bod is LargeSmithBOD)
{
DeedType = BODType.Smith;
}
Material = bod.Material;
AmountMax = bod.AmountMax;
@ -17,7 +21,9 @@ namespace Server.Engines.BulkOrders
Entries = new BOBLargeSubEntry[bod.Entries.Length];
for (var i = 0; i < Entries.Length; ++i)
{
Entries[i] = new BOBLargeSubEntry(bod.Entries[i]);
}
}
public BOBLargeEntry(IGenericReader reader)
@ -39,7 +45,9 @@ namespace Server.Engines.BulkOrders
Entries = new BOBLargeSubEntry[reader.ReadEncodedInt()];
for (var i = 0; i < Entries.Length; ++i)
{
Entries[i] = new BOBLargeSubEntry(reader);
}
break;
}
@ -63,12 +71,18 @@ namespace Server.Engines.BulkOrders
LargeBOD bod = null;
if (DeedType == BODType.Smith)
{
bod = new LargeSmithBOD(AmountMax, RequireExceptional, Material, ReconstructEntries());
}
else if (DeedType == BODType.Tailor)
{
bod = new LargeTailorBOD(AmountMax, RequireExceptional, Material, ReconstructEntries());
}
for (var i = 0; bod?.Entries.Length >= i; ++i)
{
bod.Entries[i].Owner = bod;
}
return bod;
}
@ -78,11 +92,13 @@ namespace Server.Engines.BulkOrders
var entries = new LargeBulkEntry[Entries.Length];
for (var 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 };
}
return entries;
}
@ -101,7 +117,9 @@ namespace Server.Engines.BulkOrders
writer.WriteEncodedInt(Entries.Length);
for (var i = 0; i < Entries.Length; ++i)
{
Entries[i].Serialize(writer);
}
}
}
}

View file

@ -23,7 +23,9 @@ namespace Server.Engines.BulkOrders
var type = reader.ReadString();
if (type != null)
{
ItemType = AssemblyHandler.FindFirstTypeForName(type);
}
AmountCur = reader.ReadEncodedInt();
Number = reader.ReadEncodedInt();

View file

@ -10,9 +10,13 @@ namespace Server.Engines.BulkOrders
RequireExceptional = bod.RequireExceptional;
if (bod is SmallTailorBOD)
{
DeedType = BODType.Tailor;
}
else if (bod is SmallSmithBOD)
{
DeedType = BODType.Smith;
}
Material = bod.Material;
AmountCur = bod.AmountCur;
@ -32,7 +36,9 @@ namespace Server.Engines.BulkOrders
var type = reader.ReadString();
if (type != null)
{
ItemType = AssemblyHandler.FindFirstTypeForName(type);
}
RequireExceptional = reader.ReadBool();
@ -73,9 +79,13 @@ namespace Server.Engines.BulkOrders
SmallBOD bod = null;
if (DeedType == BODType.Smith)
{
bod = new SmallSmithBOD(AmountCur, AmountMax, ItemType, Number, Graphic, RequireExceptional, Material);
}
else if (DeedType == BODType.Tailor)
{
bod = new SmallTailorBOD(AmountCur, AmountMax, ItemType, Number, Graphic, RequireExceptional, Material);
}
return bod;
}

View file

@ -61,7 +61,9 @@ namespace Server.Engines.BulkOrders
var price = 0;
if (pv.GetVendorItem(m_Book)?.IsForSale == false)
{
price = m_Entry.Price;
}
if (price != m_Price)
{
@ -116,9 +118,13 @@ namespace Server.Engines.BulkOrders
}
if (m_Book.Entries.Count > 0)
{
m_From.SendGump(new BOBGump(m_From, m_Book, m_Page));
}
else
{
m_From.SendLocalizedMessage(1062381); // The book is empty.
}
}
else
{

View file

@ -52,11 +52,17 @@ namespace Server.Engines.BulkOrders
public override void OnDoubleClick(Mobile from)
{
if (!from.InRange(GetWorldLocation(), 2))
from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
{
@from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that.
}
else if (Entries.Count == 0)
from.SendLocalizedMessage(1062381); // The book is empty.
{
@from.SendLocalizedMessage(1062381); // The book is empty.
}
else if (from is PlayerMobile mobile)
{
mobile.SendGump(new BOBGump(mobile, this));
}
}
public override void OnDoubleClickSecureTrade(Mobile from)
@ -76,9 +82,13 @@ namespace Server.Engines.BulkOrders
var 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));
}
}
}
@ -93,13 +103,20 @@ namespace Server.Engines.BulkOrders
}
if (!from.Backpack.CheckHold(from, dropped, true, true))
{
return false;
}
if (Entries.Count < 500)
{
if (dropped is LargeBOD bod)
{
Entries.Add(new BOBLargeEntry(bod));
}
else
{
Entries.Add(new BOBSmallEntry((SmallBOD)dropped));
}
InvalidateProperties();
@ -113,7 +130,9 @@ namespace Server.Engines.BulkOrders
from.SendLocalizedMessage(1062386); // Deed added to book.
if (from is PlayerMobile pm)
{
pm.SendGump(new BOBGump(pm, this));
}
dropped.Delete();
@ -133,7 +152,9 @@ namespace Server.Engines.BulkOrders
var total = base.GetTotal(type);
if (type == TotalType.Items)
{
total = ItemCount;
}
return total;
}
@ -244,7 +265,9 @@ namespace Server.Engines.BulkOrders
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~
}
}
public override void OnSingleClick(Mobile from)
@ -254,7 +277,9 @@ namespace Server.Engines.BulkOrders
LabelTo(from, 1062344, Entries.Count.ToString()); // Deeds in book: ~1_val~
if (!string.IsNullOrEmpty(m_BookName))
LabelTo(from, 1062481, m_BookName);
{
LabelTo(@from, 1062481, m_BookName);
}
}
public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
@ -262,7 +287,9 @@ namespace Server.Engines.BulkOrders
base.GetContextMenuEntries(from, list);
if (from.CheckAlive() && IsChildOf(from.Backpack))
list.Add(new NameBookEntry(from, this));
{
list.Add(new NameBookEntry(@from, this));
}
SetSecureLevelEntry.AddTo(from, this, list);
}
@ -297,7 +324,9 @@ namespace Server.Engines.BulkOrders
public override void OnResponse(Mobile from, string text)
{
if (text.Length > 40)
{
text = text.Substring(0, 40);
}
if (from.CheckAlive() && m_Book.IsChildOf(from.Backpack))
{

View file

@ -31,7 +31,9 @@ namespace Server.Engines.BulkOrders
public static BulkGenericType Classify(BODType deedType, Type itemType)
{
if (deedType != BODType.Tailor)
{
return BulkGenericType.Iron;
}
return itemType == null || itemType.IsSubclassOf(typeof(BaseArmor)) || itemType.IsSubclassOf(typeof(BaseShoes))
? BulkGenericType.Leather

View file

@ -35,8 +35,12 @@ namespace Server.Engines.BulkOrders
get
{
for (var i = 0; i < m_Entries.Length; ++i)
{
if (m_Entries[i].Amount < AmountMax)
{
return false;
}
}
return true;
}
@ -51,15 +55,21 @@ namespace Server.Engines.BulkOrders
list.Add(1060655); // large bulk order
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.
}
list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~
for (var 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)
@ -75,9 +85,13 @@ namespace Server.Engines.BulkOrders
public override void OnDoubleClick(Mobile from)
{
if (IsChildOf(from.Backpack) || InSecureTrade || RootParent is PlayerVendor)
from.SendGump(new LargeBODGump(from, this));
{
@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)
@ -91,11 +105,13 @@ namespace Server.Engines.BulkOrders
LargeBulkEntry entry = null;
for (var i = 0; i < m_Entries.Length; ++i)
{
if (m_Entries[i].Details.Type == small.Type)
{
entry = m_Entries[i];
break;
}
}
if (entry == null)
{
@ -140,7 +156,9 @@ namespace Server.Engines.BulkOrders
from.SendGump(new LargeBODGump(from, this));
if (!Complete)
BeginCombine(from);
{
BeginCombine(@from);
}
}
}
@ -153,7 +171,9 @@ namespace Server.Engines.BulkOrders
writer.Write(m_Entries.Length);
for (var i = 0; i < m_Entries.Length; ++i)
{
m_Entries[i].Serialize(writer);
}
}
public override void Deserialize(IGenericReader reader)
@ -169,7 +189,9 @@ namespace Server.Engines.BulkOrders
m_Entries = new LargeBulkEntry[reader.ReadInt()];
for (var i = 0; i < m_Entries.Length; ++i)
{
m_Entries[i] = new LargeBulkEntry(this, reader);
}
break;
}

View file

@ -42,7 +42,9 @@ namespace Server.Engines.BulkOrders
var y = 120;
for (var i = 0; i < entries.Length; ++i, y += 24)
{
AddHtmlLocalized(40, y, 210, 20, entries[i].Details.Number, 0x7FFF);
}
if (deed.RequireExceptional || deed.Material != BulkMaterialType.None)
{
@ -101,15 +103,22 @@ namespace Server.Engines.BulkOrders
public override void OnServerClose(NetState owner)
{
if (m_Deed?.Deleted == false)
{
m_Deed.Delete();
}
}
public static int GetMaterialNumberFor(BulkMaterialType material)
{
if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite)
{
return 1045142 + (material - BulkMaterialType.DullCopper);
}
if (material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed)
{
return 1049348 + (material - BulkMaterialType.Spined);
}
return 0;
}

View file

@ -64,6 +64,7 @@ namespace Server.Engines.BulkOrders
}
if (deed.Material != BulkMaterialType.None)
{
AddHtmlLocalized(
75,
y,
@ -72,6 +73,7 @@ namespace Server.Engines.BulkOrders
GetMaterialNumberFor(deed.Material),
0x7FFF
); // All items must be made with x material.
}
AddButton(125, 168 + entries.Length * 24, 4005, 4007, 2);
AddHtmlLocalized(
@ -90,7 +92,9 @@ namespace Server.Engines.BulkOrders
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Deed.Deleted || !m_Deed.IsChildOf(m_From.Backpack))
{
return;
}
if (info.ButtonID == 2) // Combine
{
@ -102,9 +106,14 @@ namespace Server.Engines.BulkOrders
public static int GetMaterialNumberFor(BulkMaterialType material)
{
if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite)
{
return 1045142 + (material - BulkMaterialType.DullCopper);
}
if (material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed)
{
return 1049348 + (material - BulkMaterialType.Spined);
}
return 0;
}

View file

@ -24,7 +24,9 @@ namespace Server.Engines.BulkOrders
var type = reader.ReadString();
if (type != null)
{
realType = AssemblyHandler.FindFirstTypeForName(type);
}
Details = new SmallBulkEntry(realType, reader.ReadInt(), reader.ReadInt());
}
@ -92,10 +94,14 @@ namespace Server.Engines.BulkOrders
m_Cache ??= new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>();
if (!m_Cache.TryGetValue(type, out var table))
{
m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>();
}
if (!table.TryGetValue(name, out var entries))
{
table[name] = entries = SmallBulkEntry.LoadEntries(type, name);
}
return entries;
}
@ -105,7 +111,9 @@ namespace Server.Engines.BulkOrders
var large = new LargeBulkEntry[small.Length];
for (var i = 0; i < small.Length; ++i)
{
large[i] = new LargeBulkEntry(owner, small[i]);
}
return large;
}

View file

@ -37,7 +37,9 @@ namespace Server.Engines.BulkOrders
};
if (rand > 2 && rand < 8)
{
useMaterials = false;
}
var hue = 0x44E;
var amountMax = Utility.RandomList(10, 15, 20, 20);

View file

@ -20,8 +20,12 @@ namespace Server.Engines.BulkOrders
public bool Contains(Type type)
{
for (var i = 0; i < Types.Length; ++i)
{
if (Types[i] == type)
{
return true;
}
}
return false;
}
@ -70,14 +74,21 @@ namespace Server.Engines.BulkOrders
public RewardItem AcquireItem()
{
if (Items.Length == 0)
{
return null;
}
if (Items.Length == 1)
{
return Items[0];
}
var totalWeight = 0;
for (var i = 0; i < Items.Length; ++i)
{
totalWeight += Items[i].Weight;
}
var randomWeight = Utility.Random(totalWeight);
@ -86,7 +97,9 @@ namespace Server.Engines.BulkOrders
var item = Items[i];
if (randomWeight < item.Weight)
{
return item;
}
randomWeight -= item.Weight;
}
@ -159,7 +172,9 @@ namespace Server.Engines.BulkOrders
var group = Groups[i];
if (points >= group.Points)
return group;
{
return @group;
}
}
return Groups[0];
@ -168,8 +183,12 @@ namespace Server.Engines.BulkOrders
public virtual int LookupTypePoints(RewardType[] types, Type type)
{
for (var i = 0; i < types.Length; ++i)
{
if (types[i].Contains(type))
{
return types[i].Points;
}
}
return 0;
}
@ -394,20 +413,32 @@ namespace Server.Engines.BulkOrders
var points = 0;
if (quantity == 10)
{
points += 10;
}
else if (quantity == 15)
{
points += 25;
}
else if (quantity == 20)
{
points += 50;
}
if (exceptional)
{
points += 200;
}
if (itemCount > 1)
{
points += LookupTypePoints(m_Types, type);
}
if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite)
{
points += 200 + 50 * (material - BulkMaterialType.DullCopper);
}
return points;
}
@ -416,18 +447,26 @@ namespace Server.Engines.BulkOrders
{
// Item count of 1 means it's a small BOD.
if (itemCount == 1)
{
return 0;
}
var typeIdx = 0;
// Loop through the RewardTypes defined earlier and find the correct one.
for (; typeIdx < 7; ++typeIdx)
{
if (m_Types[typeIdx].Contains(type))
{
break;
}
}
// Types 5, 6 and 7 are Large Weapon BODs with the same rewards.
if (typeIdx > 5)
{
typeIdx = 5;
}
return (typeIdx + 1) * 2;
}
@ -449,7 +488,9 @@ namespace Server.Engines.BulkOrders
: 0;
if (exceptional)
{
typeIndex++;
}
var gold = goldTable[typeIndex][quanIndex][mtrlIndex];
@ -483,7 +524,9 @@ namespace Server.Engines.BulkOrders
private static Item CreateRunicHammer(int type)
{
if (type >= 1 && type <= 8)
{
return new RunicHammer(CraftResource.Iron + type, Core.AOS ? 55 - type * 5 : 50);
}
throw new InvalidOperationException();
}
@ -491,7 +534,9 @@ namespace Server.Engines.BulkOrders
private static Item CreatePowerScroll(int type)
{
if (type == 5 || type == 10 || type == 15 || type == 20)
{
return new PowerScroll(SkillName.Blacksmith, 100 + type);
}
throw new InvalidOperationException();
}
@ -501,7 +546,9 @@ namespace Server.Engines.BulkOrders
private static Item CreateAncientHammer(int type)
{
if (type == 10 || type == 15 || type == 30 || type == 60)
{
return new AncientSmithyHammer(type);
}
throw new InvalidOperationException();
}
@ -669,28 +716,48 @@ namespace Server.Engines.BulkOrders
var points = 0;
if (quantity == 10)
{
points += 10;
}
else if (quantity == 15)
{
points += 25;
}
else if (quantity == 20)
{
points += 50;
}
if (exceptional)
{
points += 100;
}
if (itemCount == 4)
{
points += 300;
}
else if (itemCount == 5)
{
points += 400;
}
else if (itemCount == 6)
{
points += 500;
}
if (material == BulkMaterialType.Spined)
{
points += 50;
}
else if (material == BulkMaterialType.Horned)
{
points += 100;
}
else if (material == BulkMaterialType.Barbed)
{
points += 150;
}
return points;
}
@ -733,7 +800,9 @@ namespace Server.Engines.BulkOrders
private static Item CreateCloth(int type)
{
if (type >= 0 && type < m_ClothHues.Length)
{
return new UncutCloth(100) { Hue = m_ClothHues[type].RandomElement() };
}
throw new InvalidOperationException();
}
@ -770,7 +839,9 @@ namespace Server.Engines.BulkOrders
private static Item CreateRunicKit(int type)
{
if (type >= 1 && type <= 3)
{
return new RunicSewingKit(CraftResource.RegularLeather + type, 60 - type * 15);
}
throw new InvalidOperationException();
}
@ -778,7 +849,9 @@ namespace Server.Engines.BulkOrders
private static Item CreatePowerScroll(int type)
{
if (type == 5 || type == 10 || type == 15 || type == 20)
{
return new PowerScroll(SkillName.Tailoring, 100 + type);
}
throw new InvalidOperationException();
}

View file

@ -68,10 +68,14 @@ namespace Server.Engines.BulkOrders
list.Add(1060654); // small bulk order
if (RequireExceptional)
{
list.Add(1045141); // All items must be exceptional.
}
if (Material != BulkMaterialType.None)
{
list.Add(SmallBODGump.GetMaterialNumberFor(Material)); // All items must be made with x material.
}
list.Add(1060656, AmountMax.ToString()); // amount to make: ~1_val~
list.Add(1060658, "#{0}\t{1}", m_Number, m_AmountCur); // ~1_val~: ~2_val~
@ -80,9 +84,13 @@ namespace Server.Engines.BulkOrders
public override void OnDoubleClick(Mobile from)
{
if (IsChildOf(from.Backpack) || InSecureTrade || RootParent is PlayerVendor)
from.SendGump(new SmallBODGump(from, this));
{
@from.SendGump(new SmallBODGump(@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 OnDoubleClickNotAccessible(Mobile from)
@ -151,11 +159,17 @@ namespace Server.Engines.BulkOrders
bool isExceptional;
if (item is BaseWeapon weapon)
{
isExceptional = weapon.Quality == WeaponQuality.Exceptional;
}
else if (armor != null)
{
isExceptional = armor.Quality == ArmorQuality.Exceptional;
}
else
{
isExceptional = clothing.Quality == ClothingQuality.Exceptional;
}
if (RequireExceptional && !isExceptional)
{
@ -170,7 +184,9 @@ namespace Server.Engines.BulkOrders
from.SendGump(new SmallBODGump(from, this));
if (m_AmountCur < AmountMax)
BeginCombine(from);
{
BeginCombine(@from);
}
}
}
}
@ -203,7 +219,9 @@ namespace Server.Engines.BulkOrders
var type = reader.ReadString();
if (type != null)
{
Type = AssemblyHandler.FindFirstTypeForName(type);
}
m_Number = reader.ReadInt();
Graphic = reader.ReadInt();

View file

@ -43,9 +43,12 @@ namespace Server.Engines.BulkOrders
AddHtmlLocalized(40, 144, 210, 20, 1045140, 0x7FFF); // Special requirements to meet:
if (deed.RequireExceptional)
{
AddHtmlLocalized(40, 168, 350, 20, 1045141, 0x7FFF); // All items must be exceptional.
}
if (deed.Material != BulkMaterialType.None)
{
AddHtmlLocalized(
40,
deed.RequireExceptional ? 192 : 168,
@ -54,6 +57,7 @@ namespace Server.Engines.BulkOrders
GetMaterialNumberFor(deed.Material),
0x7FFF
); // All items must be made with x material.
}
}
AddHtmlLocalized(40, 216, 350, 20, 1045139, 0x7FFF); // Do you want to accept this order?
@ -88,15 +92,22 @@ namespace Server.Engines.BulkOrders
public override void OnServerClose(NetState owner)
{
if (m_Deed?.Deleted == false)
{
m_Deed.Delete();
}
}
public static int GetMaterialNumberFor(BulkMaterialType material)
{
if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite)
{
return 1045142 + (material - BulkMaterialType.DullCopper);
}
if (material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed)
{
return 1049348 + (material - BulkMaterialType.Spined);
}
return 0;
}

View file

@ -41,12 +41,17 @@ namespace Server.Engines.BulkOrders
AddLabel(275, 96, 0x480, deed.AmountCur.ToString());
if (deed.RequireExceptional || deed.Material != BulkMaterialType.None)
{
AddHtmlLocalized(75, 120, 200, 20, 1045140, 0x7FFF); // Special requirements to meet:
}
if (deed.RequireExceptional)
{
AddHtmlLocalized(75, 144, 300, 20, 1045141, 0x7FFF); // All items must be exceptional.
}
if (deed.Material != BulkMaterialType.None)
{
AddHtmlLocalized(
75,
deed.RequireExceptional ? 168 : 144,
@ -55,6 +60,7 @@ namespace Server.Engines.BulkOrders
GetMaterialNumberFor(deed.Material),
0x7FFF
); // All items must be made with x material.
}
AddButton(125, 192, 4005, 4007, 2);
AddHtmlLocalized(160, 192, 300, 20, 1045154, 0x7FFF); // Combine this deed with the item requested.
@ -66,7 +72,9 @@ namespace Server.Engines.BulkOrders
public override void OnResponse(NetState sender, RelayInfo info)
{
if (m_Deed.Deleted || !m_Deed.IsChildOf(m_From.Backpack))
{
return;
}
if (info.ButtonID == 2) // Combine
{
@ -78,9 +86,14 @@ namespace Server.Engines.BulkOrders
public static int GetMaterialNumberFor(BulkMaterialType material)
{
if (material >= BulkMaterialType.DullCopper && material <= BulkMaterialType.Valorite)
{
return 1045142 + (material - BulkMaterialType.DullCopper);
}
if (material >= BulkMaterialType.Spined && material <= BulkMaterialType.Barbed)
{
return 1049348 + (material - BulkMaterialType.Spined);
}
return 0;
}

View file

@ -32,13 +32,19 @@ namespace Server.Engines.BulkOrders
public static SmallBulkEntry[] GetEntries(string type, string name)
{
if (m_Cache == null)
{
m_Cache = new Dictionary<string, Dictionary<string, SmallBulkEntry[]>>();
}
if (!m_Cache.TryGetValue(type, out var table))
{
m_Cache[type] = table = new Dictionary<string, SmallBulkEntry[]>();
}
if (!table.TryGetValue(name, out var entries))
{
table[name] = entries = LoadEntries(type, name);
}
return entries;
}
@ -60,7 +66,9 @@ namespace Server.Engines.BulkOrders
while ((line = ip.ReadLine()) != null)
{
if (line.Length == 0 || line.StartsWith("#"))
{
continue;
}
try
{
@ -72,6 +80,7 @@ namespace Server.Engines.BulkOrders
var graphic = Utility.ToInt32(split[^1]);
if (type != null && graphic > 0)
{
list.Add(
new SmallBulkEntry(
type,
@ -79,6 +88,7 @@ namespace Server.Engines.BulkOrders
graphic
)
);
}
}
}
catch

View file

@ -32,7 +32,9 @@ namespace Server.Engines.BulkOrders
var entries = useMaterials ? SmallBulkEntry.BlacksmithArmor : SmallBulkEntry.BlacksmithWeapons;
if (entries.Length <= 0)
{
return;
}
var hue = 0x44E;
var amountMax = Utility.RandomList(10, 15, 20);
@ -79,21 +81,30 @@ namespace Server.Engines.BulkOrders
var entries = useMaterials ? SmallBulkEntry.BlacksmithArmor : SmallBulkEntry.BlacksmithWeapons;
if (entries.Length <= 0)
{
return null;
}
var theirSkill = m.Skills.Blacksmith.Base;
int amountMax;
if (theirSkill >= 70.1)
{
amountMax = Utility.RandomList(10, 15, 20, 20);
}
else if (theirSkill >= 50.1)
{
amountMax = Utility.RandomList(10, 15, 15, 20);
}
else
{
amountMax = Utility.RandomList(10, 10, 15, 20);
}
var material = BulkMaterialType.None;
if (useMaterials && theirSkill >= 70.1)
{
for (var i = 0; i < 20; ++i)
{
var check = GetRandomMaterial(BulkMaterialType.DullCopper, m_BlacksmithMaterialChances);
@ -120,6 +131,7 @@ namespace Server.Engines.BulkOrders
break;
}
}
}
var excChance = theirSkill >= 70.1 ? (theirSkill + 80.0) / 200.0 : 0.0;
@ -141,16 +153,22 @@ namespace Server.Engines.BulkOrders
if (allRequiredSkills && chance >= 0.0)
{
if (reqExceptional)
{
chance = item.GetExceptionalChance(system, chance, m);
}
if (chance > 0.0)
{
validEntries.Add(entries[i]);
}
}
}
}
if (validEntries.Count <= 0)
{
return null;
}
var entry = validEntries.RandomElement();
return new SmallSmithBOD(entry, material, amountMax, reqExceptional);

View file

@ -26,7 +26,9 @@ namespace Server.Engines.BulkOrders
var entries = useMaterials ? SmallBulkEntry.TailorLeather : SmallBulkEntry.TailorCloth;
if (entries.Length <= 0)
{
return;
}
var hue = 0x483;
var amountMax = Utility.RandomList(10, 15, 20);
@ -74,24 +76,35 @@ namespace Server.Engines.BulkOrders
// Ugly, but the easiest leather BOD is Leather Cap which requires at least 6.2 skill.
if (useMaterials && theirSkill >= 6.2)
{
entries = SmallBulkEntry.TailorLeather;
}
else
{
entries = SmallBulkEntry.TailorCloth;
}
if (entries.Length > 0)
{
int amountMax;
if (theirSkill >= 70.1)
{
amountMax = Utility.RandomList(10, 15, 20, 20);
}
else if (theirSkill >= 50.1)
{
amountMax = Utility.RandomList(10, 15, 15, 20);
}
else
{
amountMax = Utility.RandomList(10, 10, 15, 20);
}
var material = BulkMaterialType.None;
if (useMaterials && theirSkill >= 70.1)
{
for (var i = 0; i < 20; ++i)
{
var check = GetRandomMaterial(BulkMaterialType.Spined, m_TailoringMaterialChances);
@ -116,11 +129,14 @@ namespace Server.Engines.BulkOrders
break;
}
}
}
var excChance = 0.0;
if (theirSkill >= 70.1)
{
excChance = (theirSkill + 80.0) / 200.0;
}
var reqExceptional = excChance > Utility.RandomDouble();
@ -140,10 +156,14 @@ namespace Server.Engines.BulkOrders
if (allRequiredSkills && chance >= 0.0)
{
if (reqExceptional)
{
chance = item.GetExceptionalChance(system, chance, m);
}
if (chance > 0.0)
{
validEntries.Add(entries[i]);
}
}
}
}

View file

@ -41,7 +41,9 @@ namespace Server.Engines.CannedEvil
m_Spawn = reader.ReadItem() as ChampionSpawn;
if (m_Spawn == null)
{
Delete();
}
break;
}

View file

@ -11,12 +11,20 @@ namespace Server.Engines.CannedEvil
m_Spawn = spawn;
for (var x = -2; x <= 2; ++x)
{
for (var y = -2; y <= 2; ++y)
{
AddComponent(0x750, x, y, -5);
}
}
for (var x = -1; x <= 1; ++x)
{
for (var y = -1; y <= 1; ++y)
{
AddComponent(0x750, x, y, 0);
}
}
for (var i = -1; i <= 1; ++i)
{
@ -75,7 +83,9 @@ namespace Server.Engines.CannedEvil
m_Spawn = reader.ReadItem() as ChampionSpawn;
if (m_Spawn == null)
{
Delete();
}
break;
}

View file

@ -70,10 +70,14 @@ namespace Server.Items
if (version == 0)
{
if (LootType != LootType.Cursed)
{
LootType = LootType.Cursed;
}
if (Insured)
{
Insured = false;
}
}
}
}

View file

@ -59,10 +59,14 @@ namespace Server.Engines.CannedEvil
public void BeginSacrifice(Mobile from)
{
if (Deleted)
{
return;
}
if (m_Skull?.Deleted == true)
{
Skull = null;
}
if (from.Map != Map || !from.InRange(GetWorldLocation(), 3))
{
@ -86,10 +90,14 @@ namespace Server.Engines.CannedEvil
public void EndSacrifice(Mobile from, ChampionSkull skull)
{
if (Deleted)
{
return;
}
if (m_Skull?.Deleted == true)
{
Skull = null;
}
if (from.Map != Map || !from.InRange(GetWorldLocation(), 3))
{
@ -153,17 +161,23 @@ namespace Server.Engines.CannedEvil
m_Skull = reader.ReadItem();
if (Platform == null)
{
Delete();
}
break;
}
}
if (Hue == 0x497)
{
Hue = 0x455;
}
if (Light != LightType.Circle300)
{
Light = LightType.Circle300;
}
}
private class SacrificeTarget : Target

View file

@ -63,7 +63,9 @@ namespace Server.Engines.CannedEvil
Mobile harrower = Harrower.Spawn(new Point3D(X, Y, Z + 6), Map);
if (harrower == null)
{
return;
}
Clear(m_Power);
Clear(m_Enlightenment);

View file

@ -129,9 +129,13 @@ namespace Server.Engines.CannedEvil
set
{
if (value)
{
Start();
}
else
{
Stop();
}
InvalidateProperties();
}
@ -230,7 +234,9 @@ namespace Server.Engines.CannedEvil
public void Start()
{
if (m_Active || Deleted)
{
return;
}
m_Active = true;
HasBeenAdvanced = false;
@ -247,19 +253,27 @@ namespace Server.Engines.CannedEvil
if (m_Altar != null)
{
if (Champion != null)
{
m_Altar.Hue = 0x26;
}
else
{
m_Altar.Hue = 0;
}
}
if (m_Platform != null)
{
m_Platform.Hue = 0x452;
}
}
public void Stop()
{
if (!m_Active || Deleted)
{
return;
}
m_Active = false;
HasBeenAdvanced = false;
@ -273,10 +287,14 @@ namespace Server.Engines.CannedEvil
m_RestartTimer = null;
if (m_Altar != null)
{
m_Altar.Hue = 0;
}
if (m_Platform != null)
{
m_Platform.Hue = 0x497;
}
}
public void BeginRestart(TimeSpan ts)
@ -292,6 +310,7 @@ namespace Server.Engines.CannedEvil
public void EndRestart()
{
if (RandomizeType)
{
Type = Utility.Random(5) switch
{
0 => ChampionSpawnType.VerminHorde,
@ -301,6 +320,7 @@ namespace Server.Engines.CannedEvil
4 => ChampionSpawnType.Arachnid,
_ => Type
};
}
HasBeenAdvanced = false;
@ -312,7 +332,9 @@ namespace Server.Engines.CannedEvil
var level = Utility.RandomMinMax(1, 5);
if (felucca)
{
level += 5;
}
return ScrollofTranscendence.CreateRandom(level, level);
}
@ -320,12 +342,18 @@ namespace Server.Engines.CannedEvil
public static void GiveScrollTo(Mobile killer, SpecialScroll scroll)
{
if (scroll == null || killer == null) // sanity
{
return;
}
if (scroll is ScrollofTranscendence)
{
killer.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence!
}
else
{
killer.SendLocalizedMessage(1049524); // You have received a scroll of power!
}
if (killer.Alive)
{
@ -334,9 +362,13 @@ namespace Server.Engines.CannedEvil
else
{
if (killer.Corpse.Deleted == false)
{
killer.Corpse.DropItem(scroll);
}
else
{
killer.AddToBackpack(scroll);
}
}
// Justice reward
@ -347,7 +379,9 @@ namespace Server.Engines.CannedEvil
if (prot.Map != killer.Map || prot.Kills >= 5 || prot.Criminal ||
!JusticeVirtue.CheckMapRegion(killer, prot))
{
continue;
}
var chance = VirtueHelper.GetLevel(prot, VirtueName.Justice) switch
{
@ -358,6 +392,7 @@ namespace Server.Engines.CannedEvil
};
if (chance > Utility.Random(100))
{
try
{
prot.SendLocalizedMessage(1049368); // You have been rewarded for your dedication to Justice!
@ -373,13 +408,16 @@ namespace Server.Engines.CannedEvil
{
// ignored
}
}
}
}
public void OnSlice()
{
if (!m_Active || Deleted)
{
return;
}
if (Champion != null)
{
@ -388,19 +426,25 @@ namespace Server.Engines.CannedEvil
RegisterDamageTo(Champion);
if (Champion is BaseChampion champion)
{
AwardArtifact(champion.GetArtifact());
}
m_DamageEntries.Clear();
if (m_Platform != null)
{
m_Platform.Hue = 0x497;
}
if (m_Altar != null)
{
m_Altar.Hue = 0;
if (!Core.ML || Map == Map.Felucca)
{
new StarRoomGate(m_Altar.Location, m_Altar.Map, true);
}
}
Champion = null;
@ -420,7 +464,9 @@ namespace Server.Engines.CannedEvil
if (m.Deleted)
{
if (m.Corpse?.Deleted == false)
{
((Corpse)m.Corpse).BeginDecay(TimeSpan.FromMinutes(1));
}
m_Creatures.RemoveAt(i);
--i;
@ -431,13 +477,16 @@ namespace Server.Engines.CannedEvil
RegisterDamageTo(m);
if (killer is BaseCreature bc)
{
killer = bc.GetMaster();
}
if (killer is PlayerMobile pm)
{
if (Core.ML)
{
if (Map == Map.Felucca)
{
if (Utility.RandomDouble() < 0.001)
{
double random = Utility.Random(49);
@ -453,14 +502,17 @@ namespace Server.Engines.CannedEvil
GiveScrollTo(pm, PS);
}
}
}
if (Map == Map.Ilshenar || Map == Map.Tokuno || Map == Map.Malas)
{
if (Utility.RandomDouble() < 0.0015)
{
pm.SendLocalizedMessage(1094936); // You have received a Scroll of Transcendence!
var SoTT = CreateRandomSoT(false);
pm.AddToBackpack(SoTT);
}
}
}
var mobSubLevel = GetSubLevelFor(m) + 1;
@ -474,9 +526,13 @@ namespace Server.Engines.CannedEvil
if (VirtueHelper.Award(pm, VirtueName.Valor, pointsToGain, ref gainedPath))
{
if (gainedPath)
{
m.SendLocalizedMessage(1054032); // You have gained a path in Valor!
}
else
{
m.SendLocalizedMessage(1054030); // You have gained in Valor!
}
// No delay on Valor gains
}
@ -491,18 +547,26 @@ namespace Server.Engines.CannedEvil
// Only really needed once.
if (m_Kills > kills)
{
InvalidateProperties();
}
var n = m_Kills / (double)MaxKills;
var p = (int)(n * 100);
if (p >= 90)
{
AdvanceLevel();
}
else if (p > 0)
{
SetWhiteSkullCount(p / 20);
}
if (DateTime.UtcNow >= ExpireTime)
{
Expire();
}
Respawn();
}
@ -539,10 +603,14 @@ namespace Server.Engines.CannedEvil
public void SpawnChampion()
{
if (m_Altar != null)
{
m_Altar.Hue = 0x26;
}
if (m_Platform != null)
{
m_Platform.Hue = 0x452;
}
m_Kills = 0;
Level = 0;
@ -564,14 +632,18 @@ namespace Server.Engines.CannedEvil
public void Respawn()
{
if (!m_Active || Deleted || Champion != null)
{
return;
}
while (m_Creatures.Count < m_SPawnSzMod * (200 / 12) - GetSubLevel() * m_SPawnSzMod * (40 / 12))
{
var m = Spawn();
if (m == null)
{
return;
}
var loc = GetSpawnLocation();
@ -617,7 +689,9 @@ namespace Server.Engines.CannedEvil
var map = Map;
if (map == null)
{
return Location;
}
// Try 20 times to find a spawnable location.
for (var i = 0; i < 20; i++)
@ -633,11 +707,15 @@ namespace Server.Engines.CannedEvil
var z = Map.GetAverageZ(x, y);
if (Map.CanSpawnMobile(new Point2D(x, y), z))
{
return new Point3D(x, y, z);
}
/* try @ platform Z if map z fails */
if (Map.CanSpawnMobile(new Point2D(x, y), m_Platform.Location.Z))
{
return new Point3D(x, y, m_Platform.Location.Z);
}
}
return Location;
@ -648,11 +726,19 @@ namespace Server.Engines.CannedEvil
var level = Level;
if (level <= Level1)
{
return 0;
}
if (level <= Level2)
{
return 1;
}
if (level <= Level3)
{
return 2;
}
return 3;
}
@ -667,8 +753,12 @@ namespace Server.Engines.CannedEvil
var individualTypes = types[i];
for (var j = 0; j < individualTypes.Length; j++)
{
if (t == individualTypes[j])
{
return i;
}
}
}
return -1;
@ -681,7 +771,9 @@ namespace Server.Engines.CannedEvil
var v = GetSubLevel();
if (v >= 0 && v < types.Length)
{
return Spawn(types[v]);
}
return null;
}
@ -707,7 +799,9 @@ namespace Server.Engines.CannedEvil
// They didn't even get 20%, go back a level
if (Level > 0)
{
--Level;
}
InvalidateProperties();
}
@ -806,9 +900,13 @@ namespace Server.Engines.CannedEvil
public override void OnSingleClick(Mobile from)
{
if (m_Active)
LabelTo(from, "{0} (Active; Level: {1}; Kills: {2}/{3})", m_Type, Level, m_Kills, MaxKills);
{
LabelTo(@from, "{0} (Active; Level: {1}; Kills: {2}/{3})", m_Type, Level, m_Kills, MaxKills);
}
else
LabelTo(from, "{0} (Inactive)", m_Type);
{
LabelTo(@from, "{0} (Inactive)", m_Type);
}
}
public override void OnDoubleClick(Mobile from)
@ -819,24 +917,40 @@ namespace Server.Engines.CannedEvil
public override void OnLocationChange(Point3D oldLoc)
{
if (Deleted)
{
return;
}
if (m_Platform != null)
{
m_Platform.Location = new Point3D(X, Y, Z - 20);
}
if (m_Altar != null)
{
m_Altar.Location = new Point3D(X, Y, Z - 15);
}
if (m_Idol != null)
{
m_Idol.Location = new Point3D(X, Y, Z - 15);
}
if (m_RedSkulls != null)
{
for (var i = 0; i < m_RedSkulls.Count; ++i)
{
m_RedSkulls[i].Location = GetRedSkullLocation(i);
}
}
if (m_WhiteSkulls != null)
{
for (var i = 0; i < m_WhiteSkulls.Count; ++i)
{
m_WhiteSkulls[i].Location = GetWhiteSkullLocation(i);
}
}
m_SpawnArea.X += Location.X - oldLoc.X;
m_SpawnArea.Y += Location.Y - oldLoc.Y;
@ -847,24 +961,40 @@ namespace Server.Engines.CannedEvil
public override void OnMapChange()
{
if (Deleted)
{
return;
}
if (m_Platform != null)
{
m_Platform.Map = Map;
}
if (m_Altar != null)
{
m_Altar.Map = Map;
}
if (m_Idol != null)
{
m_Idol.Map = Map;
}
if (m_RedSkulls != null)
{
for (var i = 0; i < m_RedSkulls.Count; ++i)
{
m_RedSkulls[i].Map = Map;
}
}
if (m_WhiteSkulls != null)
{
for (var i = 0; i < m_WhiteSkulls.Count; ++i)
{
m_WhiteSkulls[i].Map = Map;
}
}
UpdateRegion();
}
@ -882,7 +1012,9 @@ namespace Server.Engines.CannedEvil
if (m_RedSkulls != null)
{
for (var i = 0; i < m_RedSkulls.Count; ++i)
{
m_RedSkulls[i].Delete();
}
m_RedSkulls.Clear();
}
@ -890,7 +1022,9 @@ namespace Server.Engines.CannedEvil
if (m_WhiteSkulls != null)
{
for (var i = 0; i < m_WhiteSkulls.Count; ++i)
{
m_WhiteSkulls[i].Delete();
}
m_WhiteSkulls.Clear();
}
@ -902,14 +1036,18 @@ namespace Server.Engines.CannedEvil
var mob = m_Creatures[i];
if (!mob.Player)
{
mob.Delete();
}
}
m_Creatures.Clear();
}
if (Champion?.Player == false)
{
Champion.Delete();
}
Stop();
@ -919,19 +1057,25 @@ namespace Server.Engines.CannedEvil
public virtual void RegisterDamageTo(Mobile m)
{
if (m == null)
{
return;
}
foreach (var de in m.DamageEntries)
{
if (de.HasExpired)
{
continue;
}
var damager = de.Damager;
var master = damager.GetDamageMaster(m);
if (master != null)
{
damager = master;
}
RegisterDamage(damager, de.DamageGiven);
}
@ -940,7 +1084,9 @@ namespace Server.Engines.CannedEvil
public void RegisterDamage(Mobile from, int amount)
{
if (from?.Player != true)
{
return;
}
m_DamageEntries[from] = amount + (m_DamageEntries.TryGetValue(from, out var value) ? value : 0);
}
@ -948,18 +1094,22 @@ namespace Server.Engines.CannedEvil
public void AwardArtifact(Item artifact)
{
if (artifact == null)
{
return;
}
var totalDamage = 0;
var validEntries = new Dictionary<Mobile, int>();
foreach (var kvp in m_DamageEntries)
{
if (IsEligible(kvp.Key, artifact))
{
validEntries.Add(kvp.Key, kvp.Value);
totalDamage += kvp.Value;
}
}
var randomDamage = Utility.RandomMinMax(1, totalDamage);
@ -982,16 +1132,22 @@ namespace Server.Engines.CannedEvil
public void GiveArtifact(Mobile to, Item artifact)
{
if (to == null || artifact == null)
{
return;
}
var pack = to.Backpack;
if (pack?.TryDropItem(to, artifact, false) != true)
{
artifact.Delete();
}
else
{
to.SendLocalizedMessage(
1062317
); // For your valor in combating the fallen beast, a special artifact has been bestowed on you.
}
}
public bool IsEligible(Mobile m, Item artifact) =>
@ -1037,7 +1193,9 @@ namespace Server.Engines.CannedEvil
writer.Write(m_RestartTimer != null);
if (m_RestartTimer != null)
{
writer.WriteDeltaTime(RestartTime);
}
}
public override void Deserialize(IGenericReader reader)
@ -1064,7 +1222,9 @@ namespace Server.Engines.CannedEvil
var damage = reader.ReadInt();
if (m == null)
{
continue;
}
m_DamageEntries.Add(m, damage);
}
@ -1110,8 +1270,10 @@ namespace Server.Engines.CannedEvil
case 0:
{
if (version < 1)
{
m_SpawnArea =
new Rectangle2D(new Point2D(X - 24, Y - 24), new Point2D(X + 24, Y + 24)); // Default was 24
}
var active = reader.ReadBool();
m_Type = (ChampionSpawnType)reader.ReadInt();
@ -1138,9 +1300,13 @@ namespace Server.Engines.CannedEvil
}
if (m_Platform == null || m_Altar == null || m_Idol == null)
{
Delete();
}
else if (active)
{
Start();
}
break;
}
@ -1222,7 +1388,9 @@ namespace Server.Engines.CannedEvil
Spawn = reader.ReadItem() as ChampionSpawn;
if (Spawn == null)
{
Delete();
}
break;
}

View file

@ -166,7 +166,9 @@ namespace Server.Engines.CannedEvil
var v = (int)type;
if (v < 0 || v >= Table.Length)
{
v = 0;
}
return Table[v];
}

View file

@ -43,14 +43,18 @@ namespace Server.Items
m_Harrower = reader.ReadMobile();
if (m_Harrower == null)
{
Delete();
}
break;
}
}
if (Light != LightType.Circle300)
{
Light = LightType.Circle300;
}
}
}
}

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