parent
096d39609e
commit
8e9221bb5a
400 changed files with 3688 additions and 5969 deletions
|
|
@ -291,33 +291,21 @@ namespace Server
|
|||
|
||||
if (info != null) return info.SupportedFeatures;
|
||||
|
||||
switch (ex)
|
||||
return ex switch
|
||||
{
|
||||
case Expansion.None:
|
||||
return FeatureFlags.ExpansionNone;
|
||||
case Expansion.T2A:
|
||||
return FeatureFlags.ExpansionT2A;
|
||||
case Expansion.UOR:
|
||||
return FeatureFlags.ExpansionUOR;
|
||||
case Expansion.UOTD:
|
||||
return FeatureFlags.ExpansionUOTD;
|
||||
case Expansion.LBR:
|
||||
return FeatureFlags.ExpansionLBR;
|
||||
case Expansion.AOS:
|
||||
return FeatureFlags.ExpansionAOS;
|
||||
case Expansion.SE:
|
||||
return FeatureFlags.ExpansionSE;
|
||||
case Expansion.ML:
|
||||
return FeatureFlags.ExpansionML;
|
||||
case Expansion.SA:
|
||||
return FeatureFlags.ExpansionSA;
|
||||
case Expansion.HS:
|
||||
return FeatureFlags.ExpansionHS;
|
||||
case Expansion.TOL:
|
||||
return FeatureFlags.ExpansionTOL;
|
||||
}
|
||||
|
||||
return FeatureFlags.ExpansionNone;
|
||||
Expansion.None => FeatureFlags.ExpansionNone,
|
||||
Expansion.T2A => FeatureFlags.ExpansionT2A,
|
||||
Expansion.UOR => FeatureFlags.ExpansionUOR,
|
||||
Expansion.UOTD => FeatureFlags.ExpansionUOTD,
|
||||
Expansion.LBR => FeatureFlags.ExpansionLBR,
|
||||
Expansion.AOS => FeatureFlags.ExpansionAOS,
|
||||
Expansion.SE => FeatureFlags.ExpansionSE,
|
||||
Expansion.ML => FeatureFlags.ExpansionML,
|
||||
Expansion.SA => FeatureFlags.ExpansionSA,
|
||||
Expansion.HS => FeatureFlags.ExpansionHS,
|
||||
Expansion.TOL => FeatureFlags.ExpansionTOL,
|
||||
_ => FeatureFlags.ExpansionNone
|
||||
};
|
||||
}
|
||||
|
||||
public static ExpansionInfo GetInfo(Expansion ex) => GetInfo((int)ex);
|
||||
|
|
|
|||
|
|
@ -160,20 +160,15 @@ namespace Server.Gumps
|
|||
|
||||
public override string Compile(NetState ns)
|
||||
{
|
||||
switch (m_Type)
|
||||
return m_Type switch
|
||||
{
|
||||
case GumpHtmlLocalizedType.Plain:
|
||||
return
|
||||
$"{{ xmfhtmlgump {m_X} {m_Y} {m_Width} {m_Height} {m_Number} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} }}";
|
||||
|
||||
case GumpHtmlLocalizedType.Color:
|
||||
return
|
||||
$"{{ xmfhtmlgumpcolor {m_X} {m_Y} {m_Width} {m_Height} {m_Number} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} {m_Color} }}";
|
||||
|
||||
default: // GumpHtmlLocalizedType.Args
|
||||
return
|
||||
$"{{ xmfhtmltok {m_X} {m_Y} {m_Width} {m_Height} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} {m_Color} {m_Number} @{m_Args}@ }}";
|
||||
}
|
||||
GumpHtmlLocalizedType.Plain =>
|
||||
$"{{ xmfhtmlgump {m_X} {m_Y} {m_Width} {m_Height} {m_Number} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} }}",
|
||||
GumpHtmlLocalizedType.Color =>
|
||||
$"{{ xmfhtmlgumpcolor {m_X} {m_Y} {m_Width} {m_Height} {m_Number} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} {m_Color} }}",
|
||||
_ =>
|
||||
$"{{ xmfhtmltok {m_X} {m_Y} {m_Width} {m_Height} {(m_Background ? 1 : 0)} {(m_Scrollbar ? 1 : 0)} {m_Color} {m_Number} @{m_Args}@ }}"
|
||||
};
|
||||
}
|
||||
|
||||
public override void AppendTo(NetState ns, IGumpWriter disp)
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Mobiles;
|
||||
|
||||
namespace Server.Mobiles
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3060,7 +3060,7 @@ namespace Server
|
|||
|
||||
int bitCount = zEnd - zStart;
|
||||
|
||||
m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart);
|
||||
m_OpenSlots &= ~((1 << bitCount) - 1 << zStart);
|
||||
}
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
|
|
@ -3088,7 +3088,7 @@ namespace Server
|
|||
|
||||
int bitCount = zEnd - zStart;
|
||||
|
||||
m_OpenSlots &= ~(((1 << bitCount) - 1) << zStart);
|
||||
m_OpenSlots &= ~((1 << bitCount) - 1 << zStart);
|
||||
}
|
||||
|
||||
int height = ItemData.Height;
|
||||
|
|
@ -3107,7 +3107,7 @@ namespace Server
|
|||
if (i + height > 20)
|
||||
match >>= 1;
|
||||
|
||||
okay = ((m_OpenSlots >> i) & match) == match;
|
||||
okay = (m_OpenSlots >> i & match) == match;
|
||||
|
||||
if (okay)
|
||||
{
|
||||
|
|
@ -3449,7 +3449,7 @@ namespace Server
|
|||
else
|
||||
{
|
||||
ns.Send(new UnicodeMessage(Serial, m_ItemID, MessageType.Label, 0x3B2, 3, "ENU", "",
|
||||
Name + (m_Amount > 1 ? " : " + m_Amount : "")));
|
||||
Name + (m_Amount > 1 ? $" : {m_Amount}" : "")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3484,7 +3484,7 @@ namespace Server
|
|||
if (ScissorCopyLootType)
|
||||
newItem.LootType = type;
|
||||
|
||||
if (!(thisParent is Container) || !((Container)thisParent).TryDropItem(from, newItem, false))
|
||||
if ((thisParent as Container)?.TryDropItem(from, newItem, false) != true)
|
||||
newItem.MoveToWorld(worldLoc, thisMap);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -381,19 +381,13 @@ namespace Server.Items
|
|||
|
||||
public override int GetTotal(TotalType type)
|
||||
{
|
||||
switch (type)
|
||||
return type switch
|
||||
{
|
||||
case TotalType.Gold:
|
||||
return m_TotalGold;
|
||||
|
||||
case TotalType.Items:
|
||||
return m_TotalItems;
|
||||
|
||||
case TotalType.Weight:
|
||||
return m_TotalWeight;
|
||||
}
|
||||
|
||||
return base.GetTotal(type);
|
||||
TotalType.Gold => m_TotalGold,
|
||||
TotalType.Items => m_TotalItems,
|
||||
TotalType.Weight => m_TotalWeight,
|
||||
_ => base.GetTotal(type)
|
||||
};
|
||||
}
|
||||
|
||||
public override void UpdateTotal(Item sender, TotalType type, int delta)
|
||||
|
|
@ -1562,10 +1556,8 @@ namespace Server.Items
|
|||
Item item = items[i];
|
||||
|
||||
if (item is T typedItem)
|
||||
{
|
||||
if (predicate?.Invoke(typedItem) == true)
|
||||
list.Add(typedItem);
|
||||
}
|
||||
|
||||
if (recurse && item is Container)
|
||||
RecurseFindItemsByType(item, true, list, predicate);
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ namespace Server
|
|||
internal static extern bool SetConsoleCtrlHandler(ConsoleEventHandler callback, bool add);
|
||||
}
|
||||
|
||||
#region Expansions
|
||||
#region Expansions
|
||||
|
||||
public static Expansion Expansion{ get; set; }
|
||||
|
||||
|
|
@ -609,7 +609,7 @@ namespace Server
|
|||
|
||||
public static bool TOL => Expansion >= Expansion.TOL;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class FileLogger : TextWriter
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -90,9 +90,9 @@ namespace Server.Network
|
|||
{
|
||||
if (Core.Unix)
|
||||
Compressor = new UnixCompressor();
|
||||
else
|
||||
else
|
||||
Compressor = new Compressor();
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe void Compress(ReadOnlySpan<byte> input, int offset, int count, Span<byte> output, out int length)
|
||||
{
|
||||
|
|
@ -187,45 +187,45 @@ namespace Server.Network
|
|||
{
|
||||
ulong destLengthLong = (ulong)destLength;
|
||||
fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source))
|
||||
{
|
||||
{
|
||||
ZLibError e = Compressor.Compress(Unsafe.AsRef<int>(dPtr), ref destLengthLong, Unsafe.AsRef<int>(sPtr), (ulong)sourceLength);
|
||||
destLength = (int)destLengthLong;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe ZLibError Pack(Span<byte> dest, ref int destLength, ReadOnlySpan<byte> source, ZLibQuality quality)
|
||||
{
|
||||
ulong destLengthLong = (ulong)destLength;
|
||||
fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source))
|
||||
{
|
||||
{
|
||||
ZLibError e = Compressor.Compress(Unsafe.AsRef<int>(dPtr), ref destLengthLong, Unsafe.AsRef<int>(sPtr), (ulong)source.Length, quality);
|
||||
destLength = (int)destLengthLong;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe ZLibError Pack(Span<byte> dest, ref int destLength, ReadOnlySpan<byte> source, int sourceLength, ZLibQuality quality)
|
||||
{
|
||||
{
|
||||
ulong destLengthLong = (ulong)destLength;
|
||||
fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source))
|
||||
{
|
||||
{
|
||||
ZLibError e = Compressor.Compress(Unsafe.AsRef<int>(dPtr), ref destLengthLong, Unsafe.AsRef<int>(sPtr), (ulong)sourceLength, quality);
|
||||
destLength = (int)destLengthLong;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static unsafe ZLibError Unpack(Span<byte> dest, ref int destLength, ReadOnlySpan<byte> source, int sourceLength)
|
||||
{
|
||||
ulong destLengthLong = (ulong)destLength;
|
||||
fixed (byte* dPtr = &MemoryMarshal.GetReference(dest), sPtr = &MemoryMarshal.GetReference(source))
|
||||
{
|
||||
{
|
||||
ZLibError e = Compressor.Decompress(Unsafe.AsRef<int>(dPtr), ref destLengthLong, Unsafe.AsRef<int>(sPtr), (ulong)sourceLength);
|
||||
destLength = (int)destLengthLong;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ulong MaxPackSize(ulong sourceLength) => Compressor.CompressBound(sourceLength);
|
||||
|
||||
|
|
@ -264,7 +264,7 @@ namespace Server.Network
|
|||
}
|
||||
|
||||
public class Compressor : ICompressor
|
||||
{
|
||||
{
|
||||
public string Version => zlibVersion();
|
||||
|
||||
public ZLibError Compress(in int dest, ref ulong destLength, in int source, ulong sourceLength) =>
|
||||
|
|
@ -286,7 +286,7 @@ namespace Server.Network
|
|||
|
||||
[DllImport("zlib")]
|
||||
private static extern ZLibError compress2(in int dest, ref ulong destLength, in int source, ulong sourceLength,
|
||||
ZLibQuality quality);
|
||||
ZLibQuality quality);
|
||||
|
||||
[DllImport("zlib")]
|
||||
private static extern ZLibError uncompress(in int dest, ref ulong destLength, in int source, ulong sourceLength);
|
||||
|
|
@ -310,20 +310,20 @@ namespace Server.Network
|
|||
|
||||
public ulong CompressBound(ulong sourceLength) => compressBound(sourceLength);
|
||||
|
||||
[DllImport("libz")]
|
||||
[DllImport("libz")]
|
||||
private static extern string zlibVersion();
|
||||
|
||||
[DllImport("libz")]
|
||||
[DllImport("libz")]
|
||||
private static extern ZLibError compress(in int dest, ref ulong destLength, in int source, ulong sourceLength);
|
||||
|
||||
[DllImport("libz")]
|
||||
[DllImport("libz")]
|
||||
private static extern ZLibError compress2(in int dest, ref ulong destLength, in int source, ulong sourceLength,
|
||||
ZLibQuality quality);
|
||||
ZLibQuality quality);
|
||||
|
||||
[DllImport("libz")]
|
||||
private static extern ZLibError uncompress(in int dest, ref ulong destLength, in int source, ulong sourceLength);
|
||||
|
||||
[DllImport("libz")]
|
||||
[DllImport("libz")]
|
||||
private static extern ulong compressBound(ulong sourceLen);
|
||||
}
|
||||
|
||||
|
|
@ -347,4 +347,4 @@ namespace Server.Network
|
|||
Speed = 1,
|
||||
Size = 9
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@ namespace Server.Network
|
|||
public int ReadInt32() => m_Reader.ReadByte() != 0 ? 0 : m_Reader.ReadInt32();
|
||||
|
||||
public Point3D ReadPoint3D() => m_Reader.ReadByte() != 3 ? Point3D.Zero :
|
||||
new Point3D(m_Reader.ReadInt16(), m_Reader.ReadInt16(), m_Reader.ReadByte());
|
||||
new Point3D(m_Reader.ReadInt16(), m_Reader.ReadInt16(), m_Reader.ReadByte());
|
||||
|
||||
public string ReadUnicodeStringSafe() => m_Reader.ReadByte() != 2 ? string.Empty :
|
||||
m_Reader.ReadUnicodeStringSafe(m_Reader.ReadUInt16());
|
||||
m_Reader.ReadUnicodeStringSafe(m_Reader.ReadUInt16());
|
||||
|
||||
public string ReadUnicodeString() => m_Reader.ReadByte() != 2 ? string.Empty :
|
||||
m_Reader.ReadUnicodeString(m_Reader.ReadUInt16());
|
||||
m_Reader.ReadUnicodeString(m_Reader.ReadUInt16());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ namespace Server.Network
|
|||
|
||||
public void Dispose()
|
||||
{
|
||||
Interlocked.Exchange<Socket>(ref m_Socket, null)?.Close();
|
||||
Interlocked.Exchange(ref m_Socket, null)?.Close();
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
|
||||
namespace Server.Network
|
||||
|
|
|
|||
|
|
@ -520,10 +520,9 @@ namespace Server.Network
|
|||
private async Task ProcessSends()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
Packet p = await m_SendQueue?.DequeueAsync() ?? null;
|
||||
Packet p = await m_SendQueue?.DequeueAsync();
|
||||
if (p == null)
|
||||
break;
|
||||
|
||||
|
|
@ -561,7 +560,6 @@ namespace Server.Network
|
|||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandlePackets(MessagePump pump)
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@
|
|||
using Server.Diagnostics;
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ using System;
|
|||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Pipelines;
|
||||
using Server.Accounting;
|
||||
using Server.ContextMenus;
|
||||
using Server.Diagnostics;
|
||||
|
|
@ -30,13 +29,13 @@ using Server.Gumps;
|
|||
using Server.HuePickers;
|
||||
using Server.Items;
|
||||
using Server.Menus;
|
||||
using Server.Mobiles;
|
||||
using Server.Prompts;
|
||||
using Server.Targeting;
|
||||
using CV = Server.ClientVersion;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
[Flags]
|
||||
public enum MessageType
|
||||
{
|
||||
Regular = 0x00,
|
||||
|
|
@ -92,14 +91,6 @@ namespace Server.Network
|
|||
|
||||
public static PlayCharCallback ThirdPartyAuthCallback = null, ThirdPartyHackedCallback = null;
|
||||
|
||||
private static byte[] m_ThirdPartyAuthKey =
|
||||
{
|
||||
0x9, 0x11, 0x83, (byte)'+', 0x4, 0x17, 0x83,
|
||||
0x5, 0x24, 0x85,
|
||||
0x7, 0x17, 0x87,
|
||||
0x6, 0x19, 0x88
|
||||
};
|
||||
|
||||
private static Dictionary<int, AuthIDPersistence> m_AuthIDWindow =
|
||||
new Dictionary<int, AuthIDPersistence>(m_AuthIDWindowSize);
|
||||
|
||||
|
|
@ -320,7 +311,7 @@ namespace Server.Network
|
|||
}
|
||||
else
|
||||
{
|
||||
int seed = (packetId << 24) | (r.ReadByte() << 16) | (r.ReadByte() << 8) | r.ReadByte();
|
||||
int seed = packetId << 24 | r.ReadByte() << 16 | r.ReadByte() << 8 | r.ReadByte();
|
||||
|
||||
if (seed == 0)
|
||||
{
|
||||
|
|
@ -2379,7 +2370,7 @@ namespace Server.Network
|
|||
name, female, hue,
|
||||
str, dex, intl,
|
||||
info[cityIndex],
|
||||
new SkillNameValue[3]
|
||||
new SkillNameValue[]
|
||||
{
|
||||
new SkillNameValue((SkillName)is1, vs1),
|
||||
new SkillNameValue((SkillName)is2, vs2),
|
||||
|
|
@ -2496,7 +2487,7 @@ namespace Server.Network
|
|||
name, female, hue,
|
||||
str, dex, intl,
|
||||
info[cityIndex],
|
||||
new SkillNameValue[4]
|
||||
new SkillNameValue[]
|
||||
{
|
||||
new SkillNameValue((SkillName)is1, vs1),
|
||||
new SkillNameValue((SkillName)is2, vs2),
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
using System.IO.Pipelines;
|
||||
using System.Text;
|
||||
|
||||
namespace Server.Network
|
||||
|
|
|
|||
|
|
@ -21,22 +21,18 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using Server.Accounting;
|
||||
using Server.ContextMenus;
|
||||
using Server.Diagnostics;
|
||||
using Server.Gumps;
|
||||
using Server.HuePickers;
|
||||
using Server.Items;
|
||||
using Server.Menus;
|
||||
using Server.Menus.ItemLists;
|
||||
using Server.Menus.Questions;
|
||||
using Server.Mobiles;
|
||||
using Server.Prompts;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -1745,7 +1741,7 @@ namespace Server.Network
|
|||
m_Stream.Write((short)offset);
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
m_Stream.Write((byte)(content >> (i * 8)));
|
||||
m_Stream.Write((byte)(content >> i * 8));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2713,7 +2709,7 @@ namespace Server.Network
|
|||
|
||||
public sealed class SeasonChange : Packet
|
||||
{
|
||||
private static SeasonChange[][] m_Cache = new SeasonChange[5][]
|
||||
private static SeasonChange[][] m_Cache = new SeasonChange[][]
|
||||
{
|
||||
new SeasonChange[2],
|
||||
new SeasonChange[2],
|
||||
|
|
@ -3802,7 +3798,7 @@ namespace Server.Network
|
|||
[Flags]
|
||||
public enum ThirdPartyFeature : ulong
|
||||
{
|
||||
FilterWeather = 1 << 0,
|
||||
FilterWeather = 1,
|
||||
FilterLight = 1 << 1,
|
||||
|
||||
SmartTarget = 1 << 2,
|
||||
|
|
@ -4009,35 +4005,6 @@ namespace Server.Network
|
|||
CharacterListFlags.OneCharacterSlot; // Limit Characters & One Character
|
||||
|
||||
m_Stream.Write((int)(flags | CharacterList.AdditionalFlags)); // Additional Flags
|
||||
|
||||
/* ThirdPartyFeature disabled = FeatureProtection.DisabledFeatures;
|
||||
|
||||
if (disabled != 0)
|
||||
{
|
||||
if (m_MD5Provider == null)
|
||||
m_MD5Provider = new MD5CryptoServiceProvider();
|
||||
|
||||
m_Stream.UnderlyingStream.Flush();
|
||||
|
||||
byte[] hashCode = m_MD5Provider.ComputeHash(m_Stream.UnderlyingStream.GetBuffer(), 0,
|
||||
(int)m_Stream.UnderlyingStream.Length);
|
||||
byte[] buffer = new byte[28];
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
Utility.RandomBytes(buffer);
|
||||
|
||||
m_Stream.Seek(35 + i * 60, SeekOrigin.Begin);
|
||||
m_Stream.Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
|
||||
m_Stream.Seek(35, SeekOrigin.Begin);
|
||||
m_Stream.Write((int)((long)disabled >> 32));
|
||||
m_Stream.Write((int)disabled);
|
||||
|
||||
m_Stream.Seek(95, SeekOrigin.Begin);
|
||||
m_Stream.Write(hashCode, 0, hashCode.Length);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,10 +27,6 @@ namespace Server.Network
|
|||
{
|
||||
private BlockingCollection<T> m_Queue = new BlockingCollection<T>(new ConcurrentQueue<T>());
|
||||
|
||||
public SendQueue()
|
||||
{
|
||||
}
|
||||
|
||||
public void Enqueue(T t)
|
||||
{
|
||||
m_Queue.Add(t);
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ namespace Server
|
|||
public void AddHash(int val)
|
||||
{
|
||||
m_Hash ^= val & 0x3FFFFFF;
|
||||
m_Hash ^= (val >> 26) & 0x3F;
|
||||
m_Hash ^= val >> 26 & 0x3F;
|
||||
}
|
||||
|
||||
public void Add(int number, string arguments)
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ namespace Server
|
|||
|
||||
return (double)r / 9007199254740992;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CSPRandom : BaseRandom
|
||||
{
|
||||
{
|
||||
private static int BUFFER_SIZE = 0x4000;
|
||||
private static int LARGE_REQUEST = 0x40;
|
||||
private byte[] _Buffer = new byte[BUFFER_SIZE];
|
||||
|
|
@ -134,9 +134,9 @@ namespace Server
|
|||
if (c >= LARGE_REQUEST)
|
||||
{
|
||||
lock (_sync)
|
||||
{
|
||||
{
|
||||
_CSP.GetBytes(b);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -191,15 +191,15 @@ namespace Server
|
|||
CheckSwap(1);
|
||||
return _Working[_Index++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RDRandUnix : BaseRandom, IHardwareRNG
|
||||
{
|
||||
[DllImport("rdrand.so")]
|
||||
internal static extern RDRandError rdrand_32(ref uint rand, bool retry);
|
||||
{
|
||||
[DllImport("rdrand.so")]
|
||||
internal static extern RDRandError rdrand_32(ref uint rand, bool retry);
|
||||
|
||||
[DllImport("rdrand.so")]
|
||||
[DllImport("rdrand.so")]
|
||||
internal static extern unsafe RDRandError rdrand_get_bytes(int n, byte* buffer);
|
||||
|
||||
public bool IsSupported()
|
||||
|
|
@ -217,11 +217,11 @@ namespace Server
|
|||
internal override void GetBytes(byte[] b, int offset, int count)
|
||||
{
|
||||
GetBytes(b.AsSpan().Slice(offset, count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RDRand64 : BaseRandom, IHardwareRNG
|
||||
{
|
||||
{
|
||||
[DllImport("rdrand")]
|
||||
internal static extern RDRandError rdrand_64(ref ulong rand, bool retry);
|
||||
|
||||
|
|
@ -257,4 +257,4 @@ namespace Server
|
|||
|
||||
Success = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace Server
|
|||
|
||||
private static void UpdateCurrency(SecureTradeInfo left, SecureTradeInfo right)
|
||||
{
|
||||
if (left.Mobile.NetState != null && left.Mobile.NetState.NewSecureTrading)
|
||||
if (left.Mobile.NetState?.NewSecureTrading == true)
|
||||
{
|
||||
int plat = left.Mobile.Account.TotalPlat;
|
||||
int gold = left.Mobile.Account.TotalGold;
|
||||
|
|
@ -173,7 +173,7 @@ namespace Server
|
|||
left.Mobile.Send(new UpdateSecureTrade(left.Container, TradeFlag.UpdateLedger, gold, plat));
|
||||
}
|
||||
|
||||
if (right.Mobile.NetState != null && right.Mobile.NetState.NewSecureTrading)
|
||||
if (right.Mobile.NetState?.NewSecureTrading == true)
|
||||
right.Mobile.Send(new UpdateSecureTrade(right.Container, TradeFlag.UpdateGold, left.Gold, left.Plat));
|
||||
}
|
||||
|
||||
|
|
@ -292,28 +292,28 @@ namespace Server
|
|||
int fromPlatSend = 0, fromGoldSend = 0, fromPlatRecv = 0, fromGoldRecv = 0;
|
||||
int toPlatSend = 0, toGoldSend = 0, toPlatRecv = 0, toGoldRecv = 0;
|
||||
|
||||
if ((From.Plat > 0) & From.Mobile.Account.WithdrawPlat(From.Plat))
|
||||
if (From.Plat > 0 & From.Mobile.Account.WithdrawPlat(From.Plat))
|
||||
{
|
||||
fromPlatSend = From.Plat;
|
||||
|
||||
if (To.Mobile.Account.DepositPlat(From.Plat)) toPlatRecv = fromPlatSend;
|
||||
}
|
||||
|
||||
if ((From.Gold > 0) & From.Mobile.Account.WithdrawGold(From.Gold))
|
||||
if (From.Gold > 0 & From.Mobile.Account.WithdrawGold(From.Gold))
|
||||
{
|
||||
fromGoldSend = From.Gold;
|
||||
|
||||
if (To.Mobile.Account.DepositGold(From.Gold)) toGoldRecv = fromGoldSend;
|
||||
}
|
||||
|
||||
if ((To.Plat > 0) & To.Mobile.Account.WithdrawPlat(To.Plat))
|
||||
if (To.Plat > 0 & To.Mobile.Account.WithdrawPlat(To.Plat))
|
||||
{
|
||||
toPlatSend = To.Plat;
|
||||
|
||||
if (From.Mobile.Account.DepositPlat(To.Plat)) fromPlatRecv = toPlatSend;
|
||||
}
|
||||
|
||||
if ((To.Gold > 0) & To.Mobile.Account.WithdrawGold(To.Gold))
|
||||
if (To.Gold > 0 & To.Mobile.Account.WithdrawGold(To.Gold))
|
||||
{
|
||||
toGoldSend = To.Gold;
|
||||
|
||||
|
|
|
|||
|
|
@ -73,15 +73,9 @@ namespace Server
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is Serial serial)
|
||||
{
|
||||
return this == serial;
|
||||
}
|
||||
if (obj is Serial serial) return this == serial;
|
||||
|
||||
if (obj is uint u)
|
||||
{
|
||||
return Value == u;
|
||||
}
|
||||
if (obj is uint u) return Value == u;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ namespace Server
|
|||
m_StaticTiles[x][y] = value;
|
||||
|
||||
if (m_StaticPatches[x] == null)
|
||||
m_StaticPatches[x] = new int[(BlockHeight + 31) >> 5];
|
||||
m_StaticPatches[x] = new int[BlockHeight + 31 >> 5];
|
||||
|
||||
m_StaticPatches[x][y >> 5] |= 1 << (y & 0x1F);
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ namespace Server
|
|||
{
|
||||
int[] theirBits = shared.m_StaticPatches[x];
|
||||
|
||||
if (theirBits != null && (theirBits[y >> 5] & (1 << (y & 0x1F))) != 0)
|
||||
if (theirBits != null && (theirBits[y >> 5] & 1 << (y & 0x1F)) != 0)
|
||||
tiles = null;
|
||||
}
|
||||
}
|
||||
|
|
@ -293,7 +293,7 @@ namespace Server
|
|||
m_LandTiles[x][y] = value;
|
||||
|
||||
if (m_LandPatches[x] == null)
|
||||
m_LandPatches[x] = new int[(BlockHeight + 31) >> 5];
|
||||
m_LandPatches[x] = new int[BlockHeight + 31 >> 5];
|
||||
|
||||
m_LandPatches[x][y >> 5] |= 1 << (y & 0x1F);
|
||||
}
|
||||
|
|
@ -331,7 +331,7 @@ namespace Server
|
|||
{
|
||||
int[] theirBits = shared.m_LandPatches[x];
|
||||
|
||||
if (theirBits != null && (theirBits[y >> 5] & (1 << (y & 0x1F))) != 0)
|
||||
if (theirBits != null && (theirBits[y >> 5] & 1 << (y & 0x1F)) != 0)
|
||||
tiles = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ namespace Server
|
|||
if (callback == null)
|
||||
return "null";
|
||||
|
||||
return $"{callback.Method.DeclaringType.FullName}.{callback.Method.Name}";
|
||||
return $"{callback.Method.DeclaringType?.FullName ?? ""}.{callback.Method.Name}";
|
||||
}
|
||||
|
||||
public static void DumpInfo(TextWriter tw)
|
||||
|
|
@ -183,7 +183,7 @@ namespace Server
|
|||
if (prof != null) prof.Created++;
|
||||
}
|
||||
|
||||
public override string ToString() => GetType().FullName;
|
||||
public override string ToString() => GetType().FullName ?? "";
|
||||
|
||||
public static TimerPriority ComputePriority(TimeSpan ts)
|
||||
{
|
||||
|
|
@ -255,8 +255,7 @@ namespace Server
|
|||
60000
|
||||
};
|
||||
|
||||
private static List<Timer>[] m_Timers = new List<Timer>[8]
|
||||
{
|
||||
private static List<Timer>[] m_Timers = {
|
||||
new List<Timer>(),
|
||||
new List<Timer>(),
|
||||
new List<Timer>(),
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ namespace Server
|
|||
if (cidrLength <= 0 || cidrLength >= 32) //if invalid cidr Length, just compare IPs
|
||||
return cidrPrefixValue == ipValue;
|
||||
|
||||
uint mask = uint.MaxValue << (32 - cidrLength);
|
||||
uint mask = uint.MaxValue << 32 - cidrLength;
|
||||
|
||||
return (cidrPrefixValue & mask) == (ipValue & mask);
|
||||
}
|
||||
|
|
@ -355,14 +355,14 @@ namespace Server
|
|||
if (bytes.Length != 4)
|
||||
return 0;
|
||||
|
||||
return (uint)((bytes[0] << 0x18) | (bytes[1] << 0x10) | (bytes[2] << 8) | bytes[3]) & 0xffffffff;
|
||||
return (uint)(bytes[0] << 0x18 | bytes[1] << 0x10 | bytes[2] << 8 | bytes[3]) & 0xffffffff;
|
||||
}
|
||||
|
||||
private static uint SwapUnsignedInt(uint source) =>
|
||||
((source & 0x000000FF) << 0x18)
|
||||
| ((source & 0x0000FF00) << 8)
|
||||
| ((source & 0x00FF0000) >> 8)
|
||||
| ((source & 0xFF000000) >> 0x18);
|
||||
(source & 0x000000FF) << 0x18
|
||||
| (source & 0x0000FF00) << 8
|
||||
| (source & 0x00FF0000) >> 8
|
||||
| (source & 0xFF000000) >> 0x18;
|
||||
|
||||
public static bool TryConvertIPv6toIPv4(ref IPAddress address)
|
||||
{
|
||||
|
|
@ -495,7 +495,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
int b = (byte)(GetAddressValue(ip) >> (i * 8));
|
||||
int b = (byte)(GetAddressValue(ip) >> i * 8);
|
||||
|
||||
if (b < lowPart || b > highPart)
|
||||
return false;
|
||||
|
|
@ -1040,17 +1040,16 @@ namespace Server
|
|||
/// </summary>
|
||||
public static int RandomNondyedHue()
|
||||
{
|
||||
switch (Random(6))
|
||||
return Random(6) switch
|
||||
{
|
||||
case 0: return RandomPinkHue();
|
||||
case 1: return RandomBlueHue();
|
||||
case 2: return RandomGreenHue();
|
||||
case 3: return RandomOrangeHue();
|
||||
case 4: return RandomRedHue();
|
||||
case 5: return RandomYellowHue();
|
||||
}
|
||||
|
||||
return 0;
|
||||
0 => RandomPinkHue(),
|
||||
1 => RandomBlueHue(),
|
||||
2 => RandomGreenHue(),
|
||||
3 => RandomOrangeHue(),
|
||||
4 => RandomRedHue(),
|
||||
5 => RandomYellowHue(),
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace Server
|
|||
Values = new int[8];
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
if ((mask & (1 << i)) != 0)
|
||||
if ((mask & 1 << i) != 0)
|
||||
Values[i] = reader.ReadInt();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -556,9 +556,8 @@ namespace Server
|
|||
|
||||
private static void AppendSafetyLog(string action, IEntity entity)
|
||||
{
|
||||
string message = $"Warning: Attempted to {action} {entity} during world save." +
|
||||
$"{Environment.NewLine}This action could cause inconsistent state." +
|
||||
$"{Environment.NewLine}It is strongly advised that the offending scripts be corrected.";
|
||||
string message =
|
||||
$"Warning: Attempted to {action} {entity} during world save.{Environment.NewLine}This action could cause inconsistent state.{Environment.NewLine}It is strongly advised that the offending scripts be corrected.";
|
||||
|
||||
Console.WriteLine(message);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue