Cleanup & Fixes for .NET 5 (#309)
- [X] Fixes several bugs - [X] Updates more ordinal issues - [X] Cleans up the code a bit - [X] Turns classes static that should have been - [X] Changes TcpServer.Instances to a HashSet Bumps release version
This commit is contained in:
parent
4ad8811df2
commit
525cda5413
266 changed files with 1348 additions and 1800 deletions
|
|
@ -100,7 +100,7 @@ namespace System.Buffers
|
|||
{
|
||||
if (bytes.Length < Length)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(bytes.Length));
|
||||
throw new ArgumentOutOfRangeException(nameof(bytes));
|
||||
}
|
||||
|
||||
if (_first.Length > 0)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ using Server;
|
|||
|
||||
namespace System.Buffers
|
||||
{
|
||||
ref struct SpanReader
|
||||
public ref struct SpanReader
|
||||
{
|
||||
private readonly ReadOnlySpan<byte> _buffer;
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Server
|
|||
|
||||
try
|
||||
{
|
||||
var br1 = fmt.IndexOf('.');
|
||||
var br1 = fmt.IndexOf('.', StringComparison.Ordinal);
|
||||
var br2 = fmt.IndexOf('.', br1 + 1);
|
||||
|
||||
var br3 = br2 + 1;
|
||||
|
|
@ -60,12 +60,15 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
if (fmt.IndexOf("god", StringComparison.Ordinal) >= 0 || fmt.IndexOf("gq", StringComparison.Ordinal) >= 0)
|
||||
if (fmt.Contains("god", StringComparison.Ordinal) || fmt.Contains("gq", StringComparison.Ordinal))
|
||||
{
|
||||
Type = ClientType.God;
|
||||
}
|
||||
else if (fmt.IndexOf("third dawn", StringComparison.Ordinal) >= 0 || fmt.IndexOf("uo:td", StringComparison.Ordinal) >= 0 || fmt.IndexOf("uotd", StringComparison.Ordinal) >= 0 ||
|
||||
fmt.IndexOf("uo3d", StringComparison.Ordinal) >= 0 || fmt.IndexOf("uo:3d", StringComparison.Ordinal) >= 0)
|
||||
else if (fmt.Contains("third dawn", StringComparison.Ordinal) ||
|
||||
fmt.Contains("uo:td", StringComparison.Ordinal) ||
|
||||
fmt.Contains("uotd", StringComparison.Ordinal) ||
|
||||
fmt.Contains("uo3d", StringComparison.Ordinal) ||
|
||||
fmt.Contains("uo:3d", StringComparison.Ordinal))
|
||||
{
|
||||
Type = ClientType.UOTD;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ namespace Server
|
|||
|
||||
public static bool Handle(Mobile from, string text, MessageType type = MessageType.Regular)
|
||||
{
|
||||
if (!text.StartsWith(Prefix) && type != MessageType.Command)
|
||||
if (!text.StartsWith(Prefix, StringComparison.Ordinal) && type != MessageType.Command)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ namespace Server
|
|||
text = text.Substring(Prefix.Length);
|
||||
}
|
||||
|
||||
var indexOf = text.IndexOf(' ');
|
||||
var indexOf = text.IndexOf(' ', StringComparison.Ordinal);
|
||||
|
||||
string command;
|
||||
string[] args;
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ namespace Server
|
|||
break;
|
||||
}
|
||||
|
||||
if (ipStr.IndexOf(':') == -1)
|
||||
if (!ipStr.Contains(':', StringComparison.Ordinal))
|
||||
{
|
||||
ipStr += ":2593";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace Server
|
|||
|
||||
public static Point2D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var start = value.IndexOf('(', StringComparison.Ordinal);
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ namespace Server
|
|||
|
||||
public static Point3D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var start = value.IndexOf('(', StringComparison.Ordinal);
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server
|
||||
{
|
||||
[NoSort]
|
||||
[Parsable]
|
||||
[PropertyObject]
|
||||
[NoSort, Parsable, PropertyObject]
|
||||
public struct Rectangle2D
|
||||
{
|
||||
private Point2D m_Start;
|
||||
|
|
@ -43,7 +43,7 @@ namespace Server
|
|||
|
||||
public static Rectangle2D Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var start = value.IndexOf('(', StringComparison.Ordinal);
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
|
|
|||
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
namespace Server
|
||||
{
|
||||
[NoSort]
|
||||
[PropertyObject]
|
||||
[NoSort, PropertyObject]
|
||||
public struct Rectangle3D
|
||||
{
|
||||
private Point3D m_Start;
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ namespace Server
|
|||
|
||||
public static WorldLocation Parse(string value)
|
||||
{
|
||||
var start = value.IndexOf('(');
|
||||
var start = value.IndexOf('(', StringComparison.Ordinal);
|
||||
var end = value.IndexOf(',', start + 1);
|
||||
|
||||
Utility.ToInt32(value.Substring(start + 1, end - (start + 1)).Trim(), out var x);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace Server.Gumps
|
|||
|
||||
public bool Closable { get; set; } = true;
|
||||
|
||||
public static int GetTypeID(Type type) => type?.FullName?.GetHashCode() ?? -1;
|
||||
public static int GetTypeID(Type type) => type?.FullName?.GetHashCode(StringComparison.Ordinal) ?? -1;
|
||||
|
||||
public void AddPage(int page)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace Server.Accounting
|
|||
/// By default, when 1,000,000,000 Gold is accumulated, it will transform
|
||||
/// into 1 Platinum.
|
||||
/// !!! WARNING !!!
|
||||
/// The client is designed to perceive the currency threashold at 1,000,000,000
|
||||
/// The client is designed to perceive the currency threshold at 1,000,000,000
|
||||
/// if you change this, it may cause unexpected results when using secure trading.
|
||||
/// </summary>
|
||||
public static int CurrencyThreshold = 1000000000;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,6 @@ namespace Server
|
|||
a != null && b != null && a.Length >= b.Length && Comparer.Compare(a.Substring(a.Length - b.Length), b) == 0;
|
||||
|
||||
public static bool Contains(string a, string b) =>
|
||||
a != null && b != null && a.Length >= b.Length && a.IndexOf(b, StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
a != null && b != null && a.Length >= b.Length && a.Contains(b, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1847,7 +1847,7 @@ namespace Server.Items
|
|||
{
|
||||
line = line.Trim();
|
||||
|
||||
if (line.Length == 0 || line.StartsWith("#"))
|
||||
if (line.Length == 0 || line.StartsWith("#", StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -524,8 +524,7 @@ namespace Server
|
|||
[CommandProperty(AccessLevel.Counselor, AccessLevel.GameMaster)]
|
||||
public int PileWeight => (int)Math.Ceiling(Weight * Amount);
|
||||
|
||||
[Hue]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
[Hue, CommandProperty(AccessLevel.GameMaster)]
|
||||
public virtual int Hue
|
||||
{
|
||||
get => m_Hue;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@ namespace System.Text.Json.Serialization
|
|||
}
|
||||
|
||||
var structType = typeToConvert.GenericTypeArguments[0];
|
||||
return !structType.IsPrimitive && structType.Namespace?.StartsWith(nameof(System)) != true && !structType.IsEnum;
|
||||
return !structType.IsPrimitive &&
|
||||
structType.Namespace?.StartsWith(nameof(System), StringComparison.Ordinal) != true &&
|
||||
!structType.IsEnum;
|
||||
}
|
||||
|
||||
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
|
||||
|
|
|
|||
|
|
@ -61,7 +61,9 @@ namespace Server
|
|||
public static bool IsRunningFromXUnit =>
|
||||
m_IsRunningFromXUnit ??= AppDomain.CurrentDomain.GetAssemblies()
|
||||
.Any(
|
||||
a => a.FullName?.ToLowerInvariant().StartsWith("xunit") ?? false
|
||||
a => a.FullName?
|
||||
.ToUpperInvariant()
|
||||
.StartsWith("XUNIT", StringComparison.Ordinal) ?? false
|
||||
);
|
||||
|
||||
public static bool Profiling
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace Server
|
|||
|
||||
while ((line = ip.ReadLine()) != null)
|
||||
{
|
||||
if (line.Length == 0 || line.StartsWith("#"))
|
||||
if (line.Length == 0 || line.StartsWith("#", StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -293,8 +293,7 @@ namespace Server
|
|||
Locked
|
||||
}
|
||||
|
||||
[CustomEnum(new[] { "North", "Right", "East", "Down", "South", "Left", "West", "Up" })]
|
||||
[Flags]
|
||||
[CustomEnum(new[] { "North", "Right", "East", "Down", "South", "Left", "West", "Up" }), Flags]
|
||||
public enum Direction : byte
|
||||
{
|
||||
North = 0x0,
|
||||
|
|
@ -1340,8 +1339,7 @@ namespace Server
|
|||
|
||||
public virtual int Luck => 0;
|
||||
|
||||
[Hue]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
[Hue, CommandProperty(AccessLevel.GameMaster)]
|
||||
public int HueMod
|
||||
{
|
||||
get => m_HueMod;
|
||||
|
|
@ -1356,8 +1354,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
[Hue]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
[Hue, CommandProperty(AccessLevel.GameMaster)]
|
||||
public virtual int Hue
|
||||
{
|
||||
get
|
||||
|
|
@ -1778,8 +1775,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
[Body]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
[Body, CommandProperty(AccessLevel.GameMaster)]
|
||||
public Body Body
|
||||
{
|
||||
get
|
||||
|
|
@ -1805,8 +1801,7 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
[Body]
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
[Body, CommandProperty(AccessLevel.GameMaster)]
|
||||
public int BodyValue
|
||||
{
|
||||
get => Body.BodyID;
|
||||
|
|
@ -2481,8 +2476,6 @@ namespace Server
|
|||
get => m_Poison;
|
||||
set
|
||||
{
|
||||
/*if (m_Poison != value && (m_Poison == null || value == null || m_Poison.Level < value.Level))
|
||||
{*/
|
||||
m_Poison = value;
|
||||
Delta(MobileDelta.HealthbarPoison);
|
||||
|
||||
|
|
@ -2500,7 +2493,6 @@ namespace Server
|
|||
}
|
||||
|
||||
CheckStatTimers();
|
||||
/*}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -9171,7 +9163,7 @@ namespace Server
|
|||
CheckStatTimers();
|
||||
}
|
||||
|
||||
private MobileDelta GetStatDelta(StatType type)
|
||||
private static MobileDelta GetStatDelta(StatType type)
|
||||
{
|
||||
MobileDelta delta = 0;
|
||||
|
||||
|
|
@ -9540,7 +9532,7 @@ namespace Server
|
|||
Effects.SendTargetEffect(this, itemID, speed, duration, hue, renderMode);
|
||||
|
||||
public void FixedEffect(int itemID, int speed, int duration) =>
|
||||
Effects.SendTargetEffect(this, itemID, speed, duration, 0, 0);
|
||||
Effects.SendTargetEffect(this, itemID, speed, duration);
|
||||
|
||||
public void FixedParticles(
|
||||
int itemID, int speed, int duration, int effect, int hue, int renderMode, EffectLayer layer, int unknown
|
||||
|
|
@ -9550,13 +9542,13 @@ namespace Server
|
|||
public void FixedParticles(
|
||||
int itemID, int speed, int duration, int effect, int hue, int renderMode, EffectLayer layer
|
||||
) =>
|
||||
Effects.SendTargetParticles(this, itemID, speed, duration, hue, renderMode, effect, layer, 0);
|
||||
Effects.SendTargetParticles(this, itemID, speed, duration, hue, renderMode, effect, layer);
|
||||
|
||||
public void FixedParticles(int itemID, int speed, int duration, int effect, EffectLayer layer, int unknown) =>
|
||||
Effects.SendTargetParticles(this, itemID, speed, duration, 0, 0, effect, layer, unknown);
|
||||
|
||||
public void FixedParticles(int itemID, int speed, int duration, int effect, EffectLayer layer) =>
|
||||
Effects.SendTargetParticles(this, itemID, speed, duration, 0, 0, effect, layer, 0);
|
||||
Effects.SendTargetParticles(this, itemID, speed, duration, 0, 0, effect, layer);
|
||||
|
||||
public void BoltEffect(int hue) => Effects.SendBoltEffect(this, true, hue);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ namespace Server.Mobiles
|
|||
public class MovementRecord
|
||||
{
|
||||
private static readonly Queue<MovementRecord> m_InstancePool = new Queue<MovementRecord>();
|
||||
public long m_End;
|
||||
private long m_End;
|
||||
|
||||
private MovementRecord(long end) => m_End = end;
|
||||
|
||||
|
|
|
|||
|
|
@ -513,7 +513,7 @@ namespace Server.Network
|
|||
continue;
|
||||
}
|
||||
|
||||
var bytesWritten = await Connection.SendAsync(result.Buffer, SocketFlags.None);
|
||||
var bytesWritten = await Connection.SendAsync(result.Buffer, SocketFlags.None).ConfigureAwait(false);
|
||||
|
||||
if (bytesWritten > 0)
|
||||
{
|
||||
|
|
@ -567,7 +567,7 @@ namespace Server.Network
|
|||
continue;
|
||||
}
|
||||
|
||||
var bytesWritten = await socket.ReceiveAsync(result.Buffer, SocketFlags.None);
|
||||
var bytesWritten = await socket.ReceiveAsync(result.Buffer, SocketFlags.None).ConfigureAwait(false);
|
||||
if (bytesWritten <= 0)
|
||||
{
|
||||
break;
|
||||
|
|
@ -596,11 +596,9 @@ namespace Server.Network
|
|||
|
||||
public static void HandleAllReceives()
|
||||
{
|
||||
var clients = TcpServer.Instances;
|
||||
|
||||
for (int i = 0; i < clients.Count; ++i)
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
clients[i].HandleReceive();
|
||||
ns.HandleReceive();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -662,11 +660,9 @@ namespace Server.Network
|
|||
|
||||
public static void FlushAll()
|
||||
{
|
||||
var clients = TcpServer.Instances;
|
||||
|
||||
for (int i = 0; i < clients.Count; ++i)
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
clients[i].Flush();
|
||||
ns.Flush();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -685,11 +681,9 @@ namespace Server.Network
|
|||
{
|
||||
long curTicks = Core.TickCount;
|
||||
|
||||
var clients = TcpServer.Instances;
|
||||
|
||||
for (int i = 0; i < clients.Count; ++i)
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
clients[i].CheckAlive(curTicks);
|
||||
ns.CheckAlive(curTicks);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ namespace Server.Network
|
|||
{
|
||||
private const int CompressorBufferSize = 0x10000;
|
||||
|
||||
private const int BufferSize = 4096;
|
||||
private readonly int m_Length;
|
||||
|
||||
private byte[] m_CompiledBuffer;
|
||||
|
|
@ -120,9 +119,11 @@ namespace Server.Network
|
|||
}
|
||||
}
|
||||
|
||||
private readonly object _object = new object();
|
||||
|
||||
public byte[] Compile(bool compress, out int length)
|
||||
{
|
||||
lock (this)
|
||||
lock (_object)
|
||||
{
|
||||
if (m_CompiledBuffer == null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Server.Accounting;
|
||||
using System.Buffers;
|
||||
using Server.Accounting;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Server.Network
|
|||
|
||||
public static IPEndPoint[] ListeningAddresses { get; private set; }
|
||||
public static TcpListener[] Listeners { get; private set; }
|
||||
public static List<NetState> Instances { get; } = new List<NetState>(128);
|
||||
public static HashSet<NetState> Instances { get; } = new HashSet<NetState>(128);
|
||||
|
||||
public static ConcurrentQueue<NetState> m_ConnectedQueue = new ConcurrentQueue<NetState>();
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ namespace Server.Network
|
|||
|
||||
try
|
||||
{
|
||||
socket = await listener.AcceptSocketAsync();
|
||||
socket = await listener.AcceptSocketAsync().ConfigureAwait(false);
|
||||
if (Instances.Count >= MaxConnections)
|
||||
{
|
||||
socket.Send(socketRejected, SocketFlags.None);
|
||||
|
|
@ -205,8 +205,10 @@ namespace Server.Network
|
|||
|
||||
if (_nextMaximumSocketsReachedMessage <= ticks)
|
||||
{
|
||||
var ipep = (IPEndPoint)socket!.RemoteEndPoint;
|
||||
Console.WriteLine("Listener {0}:{1}: Failed (Maximum connections reached)", ipep.Address, ipep.Port);
|
||||
if (socket?.RemoteEndPoint is IPEndPoint ipep)
|
||||
{
|
||||
Console.WriteLine("Listener {0}:{1}: Failed (Maximum connections reached)", ipep.Address, ipep.Port);
|
||||
}
|
||||
_nextMaximumSocketsReachedMessage = ticks + _listenerErrorMessageDelay;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Server.Network;
|
||||
|
|
@ -99,7 +100,7 @@ namespace Server
|
|||
}
|
||||
|
||||
AddHash(number);
|
||||
AddHash(arguments.GetHashCode());
|
||||
AddHash(arguments.GetHashCode(StringComparison.Ordinal));
|
||||
|
||||
Stream.Write(number);
|
||||
|
||||
|
|
|
|||
|
|
@ -31,25 +31,25 @@ namespace Server
|
|||
m_Position = m_File.Position;
|
||||
}
|
||||
|
||||
public override long Position => m_Position + m_Index;
|
||||
public override long Position => m_Position + Index;
|
||||
|
||||
|
||||
protected override int BufferSize => 512;
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
if (m_Index > 0)
|
||||
if (Index > 0)
|
||||
{
|
||||
m_Position += m_Index;
|
||||
m_Position += Index;
|
||||
|
||||
m_File.Write(m_Buffer, 0, (int)m_Index);
|
||||
m_Index = 0;
|
||||
m_File.Write(Buffer, 0, (int)Index);
|
||||
Index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
if (m_Index > 0)
|
||||
if (Index > 0)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ namespace Server
|
|||
private readonly Encoding m_Encoding;
|
||||
private readonly bool m_PrefixStrings;
|
||||
|
||||
protected byte[] m_Buffer;
|
||||
protected long m_Index;
|
||||
protected long Index { get; set; }
|
||||
|
||||
private readonly char[] m_SingleCharBuffer = new char[1];
|
||||
|
||||
|
|
@ -43,21 +42,21 @@ namespace Server
|
|||
{
|
||||
m_PrefixStrings = prefixStr;
|
||||
m_Encoding = Utility.UTF8;
|
||||
m_Buffer = buffer;
|
||||
Buffer = buffer;
|
||||
}
|
||||
|
||||
public BufferWriter(bool prefixStr)
|
||||
{
|
||||
m_PrefixStrings = prefixStr;
|
||||
m_Encoding = Utility.UTF8;
|
||||
m_Buffer = new byte[BufferSize];
|
||||
Buffer = new byte[BufferSize];
|
||||
}
|
||||
|
||||
public virtual long Position => m_Index;
|
||||
public virtual long Position => Index;
|
||||
|
||||
protected virtual int BufferSize => 256;
|
||||
|
||||
public byte[] Data => m_Buffer;
|
||||
public byte[] Buffer { get; protected set; }
|
||||
|
||||
public virtual void Close()
|
||||
{
|
||||
|
|
@ -68,28 +67,28 @@ namespace Server
|
|||
public void Resize(int size)
|
||||
{
|
||||
var copy = new byte[size];
|
||||
Buffer.BlockCopy(m_Buffer, 0, copy, 0, Math.Min(size, m_Buffer.Length));
|
||||
m_Buffer = copy;
|
||||
System.Buffer.BlockCopy(Buffer, 0, copy, 0, Math.Min(size, Buffer.Length));
|
||||
Buffer = copy;
|
||||
}
|
||||
|
||||
public virtual void Flush()
|
||||
{
|
||||
Resize(m_Buffer.Length * 2);
|
||||
Resize(Buffer.Length * 2);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_Index = 0;
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
public virtual long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return origin switch
|
||||
{
|
||||
SeekOrigin.Begin => m_Index = offset,
|
||||
SeekOrigin.Current => m_Index += offset,
|
||||
SeekOrigin.End => m_Index = BufferSize - offset,
|
||||
_ => m_Index
|
||||
SeekOrigin.Begin => Index = offset,
|
||||
SeekOrigin.Current => Index += offset,
|
||||
SeekOrigin.End => Index = BufferSize - offset,
|
||||
_ => Index
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -99,21 +98,21 @@ namespace Server
|
|||
|
||||
while (v >= 0x80)
|
||||
{
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
if (Index + 1 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index++] = (byte)(v | 0x80);
|
||||
Buffer[Index++] = (byte)(v | 0x80);
|
||||
v >>= 7;
|
||||
}
|
||||
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
if (Index + 1 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index++] = (byte)v;
|
||||
Buffer[Index++] = (byte)v;
|
||||
}
|
||||
|
||||
public void Write(string value)
|
||||
|
|
@ -122,21 +121,21 @@ namespace Server
|
|||
{
|
||||
if (value == null)
|
||||
{
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
if (Index + 1 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index++] = 0;
|
||||
Buffer[Index++] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
if (Index + 1 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index++] = 1;
|
||||
Buffer[Index++] = 1;
|
||||
|
||||
InternalWriteString(value);
|
||||
}
|
||||
|
|
@ -199,143 +198,143 @@ namespace Server
|
|||
|
||||
public void Write(long value)
|
||||
{
|
||||
if (m_Index + 8 > m_Buffer.Length)
|
||||
if (Index + 8 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index] = (byte)value;
|
||||
m_Buffer[m_Index + 1] = (byte)(value >> 8);
|
||||
m_Buffer[m_Index + 2] = (byte)(value >> 16);
|
||||
m_Buffer[m_Index + 3] = (byte)(value >> 24);
|
||||
m_Buffer[m_Index + 4] = (byte)(value >> 32);
|
||||
m_Buffer[m_Index + 5] = (byte)(value >> 40);
|
||||
m_Buffer[m_Index + 6] = (byte)(value >> 48);
|
||||
m_Buffer[m_Index + 7] = (byte)(value >> 56);
|
||||
m_Index += 8;
|
||||
Buffer[Index] = (byte)value;
|
||||
Buffer[Index + 1] = (byte)(value >> 8);
|
||||
Buffer[Index + 2] = (byte)(value >> 16);
|
||||
Buffer[Index + 3] = (byte)(value >> 24);
|
||||
Buffer[Index + 4] = (byte)(value >> 32);
|
||||
Buffer[Index + 5] = (byte)(value >> 40);
|
||||
Buffer[Index + 6] = (byte)(value >> 48);
|
||||
Buffer[Index + 7] = (byte)(value >> 56);
|
||||
Index += 8;
|
||||
}
|
||||
|
||||
public void Write(ulong value)
|
||||
{
|
||||
if (m_Index + 8 > m_Buffer.Length)
|
||||
if (Index + 8 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index] = (byte)value;
|
||||
m_Buffer[m_Index + 1] = (byte)(value >> 8);
|
||||
m_Buffer[m_Index + 2] = (byte)(value >> 16);
|
||||
m_Buffer[m_Index + 3] = (byte)(value >> 24);
|
||||
m_Buffer[m_Index + 4] = (byte)(value >> 32);
|
||||
m_Buffer[m_Index + 5] = (byte)(value >> 40);
|
||||
m_Buffer[m_Index + 6] = (byte)(value >> 48);
|
||||
m_Buffer[m_Index + 7] = (byte)(value >> 56);
|
||||
m_Index += 8;
|
||||
Buffer[Index] = (byte)value;
|
||||
Buffer[Index + 1] = (byte)(value >> 8);
|
||||
Buffer[Index + 2] = (byte)(value >> 16);
|
||||
Buffer[Index + 3] = (byte)(value >> 24);
|
||||
Buffer[Index + 4] = (byte)(value >> 32);
|
||||
Buffer[Index + 5] = (byte)(value >> 40);
|
||||
Buffer[Index + 6] = (byte)(value >> 48);
|
||||
Buffer[Index + 7] = (byte)(value >> 56);
|
||||
Index += 8;
|
||||
}
|
||||
|
||||
public void Write(int value)
|
||||
{
|
||||
if (m_Index + 4 > m_Buffer.Length)
|
||||
if (Index + 4 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index] = (byte)value;
|
||||
m_Buffer[m_Index + 1] = (byte)(value >> 8);
|
||||
m_Buffer[m_Index + 2] = (byte)(value >> 16);
|
||||
m_Buffer[m_Index + 3] = (byte)(value >> 24);
|
||||
m_Index += 4;
|
||||
Buffer[Index] = (byte)value;
|
||||
Buffer[Index + 1] = (byte)(value >> 8);
|
||||
Buffer[Index + 2] = (byte)(value >> 16);
|
||||
Buffer[Index + 3] = (byte)(value >> 24);
|
||||
Index += 4;
|
||||
}
|
||||
|
||||
public void Write(uint value)
|
||||
{
|
||||
if (m_Index + 4 > m_Buffer.Length)
|
||||
if (Index + 4 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index] = (byte)value;
|
||||
m_Buffer[m_Index + 1] = (byte)(value >> 8);
|
||||
m_Buffer[m_Index + 2] = (byte)(value >> 16);
|
||||
m_Buffer[m_Index + 3] = (byte)(value >> 24);
|
||||
m_Index += 4;
|
||||
Buffer[Index] = (byte)value;
|
||||
Buffer[Index + 1] = (byte)(value >> 8);
|
||||
Buffer[Index + 2] = (byte)(value >> 16);
|
||||
Buffer[Index + 3] = (byte)(value >> 24);
|
||||
Index += 4;
|
||||
}
|
||||
|
||||
public void Write(short value)
|
||||
{
|
||||
if (m_Index + 2 > m_Buffer.Length)
|
||||
if (Index + 2 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index] = (byte)value;
|
||||
m_Buffer[m_Index + 1] = (byte)(value >> 8);
|
||||
m_Index += 2;
|
||||
Buffer[Index] = (byte)value;
|
||||
Buffer[Index + 1] = (byte)(value >> 8);
|
||||
Index += 2;
|
||||
}
|
||||
|
||||
public void Write(ushort value)
|
||||
{
|
||||
if (m_Index + 2 > m_Buffer.Length)
|
||||
if (Index + 2 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index] = (byte)value;
|
||||
m_Buffer[m_Index + 1] = (byte)(value >> 8);
|
||||
m_Index += 2;
|
||||
Buffer[Index] = (byte)value;
|
||||
Buffer[Index + 1] = (byte)(value >> 8);
|
||||
Index += 2;
|
||||
}
|
||||
|
||||
public unsafe void Write(double value)
|
||||
{
|
||||
if (m_Index + 8 > m_Buffer.Length)
|
||||
if (Index + 8 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
fixed (byte* pBuffer = m_Buffer)
|
||||
fixed (byte* pBuffer = Buffer)
|
||||
{
|
||||
*(double*)(pBuffer + m_Index) = value;
|
||||
*(double*)(pBuffer + Index) = value;
|
||||
}
|
||||
|
||||
m_Index += 8;
|
||||
Index += 8;
|
||||
}
|
||||
|
||||
public unsafe void Write(float value)
|
||||
{
|
||||
if (m_Index + 4 > m_Buffer.Length)
|
||||
if (Index + 4 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
fixed (byte* pBuffer = m_Buffer)
|
||||
fixed (byte* pBuffer = Buffer)
|
||||
{
|
||||
*(float*)(pBuffer + m_Index) = value;
|
||||
*(float*)(pBuffer + Index) = value;
|
||||
}
|
||||
|
||||
m_Index += 4;
|
||||
Index += 4;
|
||||
}
|
||||
|
||||
public void Write(char value)
|
||||
{
|
||||
if (m_Index + 8 > m_Buffer.Length)
|
||||
if (Index + 8 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_SingleCharBuffer[0] = value;
|
||||
|
||||
var byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, m_Buffer, (int)m_Index);
|
||||
m_Index += byteCount;
|
||||
var byteCount = m_Encoding.GetBytes(m_SingleCharBuffer, 0, 1, Buffer, (int)Index);
|
||||
Index += byteCount;
|
||||
}
|
||||
|
||||
public void Write(byte value)
|
||||
{
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
if (Index + 1 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index++] = value;
|
||||
Buffer[Index++] = value;
|
||||
}
|
||||
|
||||
public void Write(byte[] value, int length)
|
||||
|
|
@ -345,15 +344,15 @@ namespace Server
|
|||
|
||||
while (remaining > 0)
|
||||
{
|
||||
int size = Math.Min(m_Buffer.Length - (int)m_Index, remaining);
|
||||
Buffer.BlockCopy(value, idx, m_Buffer, (int)m_Index, size);
|
||||
int size = Math.Min(Buffer.Length - (int)Index, remaining);
|
||||
System.Buffer.BlockCopy(value, idx, Buffer, (int)Index, size);
|
||||
// value.Slice(idx).CopyTo(m_Buffer.AsSpan(m_Index, size));
|
||||
|
||||
remaining -= size;
|
||||
m_Index += size;
|
||||
Index += size;
|
||||
idx += size;
|
||||
|
||||
if (m_Index == m_Buffer.Length)
|
||||
if (Index == Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
|
@ -362,22 +361,22 @@ namespace Server
|
|||
|
||||
public void Write(sbyte value)
|
||||
{
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
if (Index + 1 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index++] = (byte)value;
|
||||
Buffer[Index++] = (byte)value;
|
||||
}
|
||||
|
||||
public void Write(bool value)
|
||||
{
|
||||
if (m_Index + 1 > m_Buffer.Length)
|
||||
if (Index + 1 > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
m_Buffer[m_Index++] = (byte)(value ? 1 : 0);
|
||||
Buffer[Index++] = (byte)(value ? 1 : 0);
|
||||
}
|
||||
|
||||
public void Write(Point3D value)
|
||||
|
|
@ -773,13 +772,13 @@ namespace Server
|
|||
var charCount = charsLeft > m_MaxBufferChars ? m_MaxBufferChars : charsLeft;
|
||||
var byteLength = m_Encoding.GetBytes(value, current, charCount, m_CharacterBuffer, 0);
|
||||
|
||||
if (m_Index + byteLength > m_Buffer.Length)
|
||||
if (Index + byteLength > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
Buffer.BlockCopy(m_CharacterBuffer, 0, m_Buffer, (int)m_Index, byteLength);
|
||||
m_Index += byteLength;
|
||||
System.Buffer.BlockCopy(m_CharacterBuffer, 0, Buffer, (int)Index, byteLength);
|
||||
Index += byteLength;
|
||||
|
||||
current += charCount;
|
||||
charsLeft -= charCount;
|
||||
|
|
@ -789,13 +788,13 @@ namespace Server
|
|||
{
|
||||
var byteLength = m_Encoding.GetBytes(value, 0, value.Length, m_CharacterBuffer, 0);
|
||||
|
||||
if (m_Index + byteLength > m_Buffer.Length)
|
||||
if (Index + byteLength > Buffer.Length)
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
|
||||
Buffer.BlockCopy(m_CharacterBuffer, 0, m_Buffer, (int)m_Index, byteLength);
|
||||
m_Index += byteLength;
|
||||
System.Buffer.BlockCopy(m_CharacterBuffer, 0, Buffer, (int)Index, byteLength);
|
||||
Index += byteLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@
|
|||
</PackageReference>
|
||||
<PackageReference Include="Zlib.Bindings" Version="1.4.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Configuration)'=='Analyze'">
|
||||
<AdditionalFiles Include="..\..\stylecop.json" />
|
||||
<AdditionalFiles Include="..\..\Rules.ruleset" />
|
||||
</ItemGroup>
|
||||
<!-- <ItemGroup Condition="'$(Configuration)'=='Analyze'">-->
|
||||
<!-- <AdditionalFiles Include="..\..\stylecop.json" />-->
|
||||
<!-- <AdditionalFiles Include="..\..\Rules.ruleset" />-->
|
||||
<!-- </ItemGroup>-->
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -5,9 +5,6 @@ namespace Server
|
|||
{
|
||||
public class TileMatrixPatch
|
||||
{
|
||||
private readonly int m_LandBlocks;
|
||||
private readonly int m_StaticBlocks;
|
||||
|
||||
private StaticTile[] m_TileBuffer = new StaticTile[128];
|
||||
|
||||
public TileMatrixPatch(TileMatrix matrix, int index)
|
||||
|
|
@ -22,7 +19,7 @@ namespace Server
|
|||
|
||||
if (File.Exists(mapDataPath) && File.Exists(mapIndexPath))
|
||||
{
|
||||
m_LandBlocks = PatchLand(matrix, mapDataPath, mapIndexPath);
|
||||
LandBlocks = PatchLand(matrix, mapDataPath, mapIndexPath);
|
||||
}
|
||||
|
||||
var staDataPath = Core.FindDataFile($"stadif{index}.mul", false);
|
||||
|
|
@ -31,33 +28,16 @@ namespace Server
|
|||
|
||||
if (File.Exists(staDataPath) && File.Exists(staIndexPath) && File.Exists(staLookupPath))
|
||||
{
|
||||
m_StaticBlocks = PatchStatics(matrix, staDataPath, staIndexPath, staLookupPath);
|
||||
StaticBlocks = PatchStatics(matrix, staDataPath, staIndexPath, staLookupPath);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use configuration
|
||||
public static bool Enabled { get; set; } = true;
|
||||
|
||||
public int LandBlocks
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
return m_LandBlocks;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int LandBlocks { get; }
|
||||
|
||||
public int StaticBlocks
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
return m_StaticBlocks;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int StaticBlocks { get; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
private unsafe int PatchLand(TileMatrix matrix, string dataPath, string indexPath)
|
||||
|
|
|
|||
|
|
@ -215,9 +215,9 @@ namespace Server
|
|||
return "";
|
||||
}
|
||||
|
||||
var hasOpen = str.IndexOf('<') >= 0;
|
||||
var hasClose = str.IndexOf('>') >= 0;
|
||||
var hasPound = str.IndexOf('#') >= 0;
|
||||
var hasOpen = str.Contains('<', StringComparison.Ordinal);
|
||||
var hasClose = str.Contains('>', StringComparison.Ordinal);
|
||||
var hasPound = str.Contains('#', StringComparison.Ordinal);
|
||||
|
||||
if (!hasOpen && !hasClose && !hasPound)
|
||||
{
|
||||
|
|
@ -891,23 +891,42 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
public static List<TOutput> CastListContravariant<TInput, TOutput>(List<TInput> list) where TInput : TOutput =>
|
||||
list.ConvertAll(value => (TOutput)value);
|
||||
|
||||
public static List<TOutput> CastListCovariant<TInput, TOutput>(List<TInput> list) where TOutput : TInput =>
|
||||
list.ConvertAll(value => (TOutput)value);
|
||||
|
||||
public static List<TOutput> SafeConvertList<TInput, TOutput>(List<TInput> list) where TOutput : class
|
||||
public static List<TOutput> CastListContravariant<TInput, TOutput>(this IReadOnlyCollection<TInput> coll)
|
||||
where TInput : TOutput
|
||||
{
|
||||
if ((list?.Capacity ?? 0) == 0)
|
||||
var outputList = new List<TOutput>();
|
||||
foreach (var entry in coll)
|
||||
{
|
||||
return new List<TOutput>();
|
||||
outputList.Add(entry);
|
||||
}
|
||||
|
||||
var output = new List<TOutput>(list.Capacity);
|
||||
output.AddRange(list.OfType<TOutput>());
|
||||
return outputList;
|
||||
}
|
||||
|
||||
return output;
|
||||
public static List<TOutput> CastListCovariant<TInput, TOutput>(this IReadOnlyCollection<TInput> coll)
|
||||
where TOutput : TInput
|
||||
{
|
||||
var outputList = new List<TOutput>();
|
||||
foreach (var entry in coll)
|
||||
{
|
||||
outputList.Add((TOutput)entry);
|
||||
}
|
||||
|
||||
return outputList;
|
||||
}
|
||||
|
||||
public static List<TOutput> SafeConvertList<TInput, TOutput>(this IReadOnlyCollection<TInput> coll) where TOutput : class
|
||||
{
|
||||
var outputList = new List<TOutput>();
|
||||
foreach (var entry in coll)
|
||||
{
|
||||
if (entry is TOutput outEntry)
|
||||
{
|
||||
outputList.Add(outEntry);
|
||||
}
|
||||
}
|
||||
|
||||
return outputList;
|
||||
}
|
||||
|
||||
public static bool ToBoolean(string value)
|
||||
|
|
@ -942,7 +961,7 @@ namespace Server
|
|||
int i;
|
||||
|
||||
#pragma warning disable CA1806 // Do not ignore method results
|
||||
if (value.StartsWith("0x"))
|
||||
if (value.StartsWith("0x", StringComparison.Ordinal))
|
||||
{
|
||||
int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i);
|
||||
}
|
||||
|
|
@ -960,7 +979,7 @@ namespace Server
|
|||
uint i;
|
||||
|
||||
#pragma warning disable CA1806 // Do not ignore method results
|
||||
if (value.StartsWith("0x"))
|
||||
if (value.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
uint.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i);
|
||||
}
|
||||
|
|
@ -974,12 +993,12 @@ namespace Server
|
|||
}
|
||||
|
||||
public static bool ToInt32(string value, out int i) =>
|
||||
value.StartsWith("0x")
|
||||
value.StartsWith("0x", StringComparison.OrdinalIgnoreCase)
|
||||
? int.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i)
|
||||
: int.TryParse(value, out i);
|
||||
|
||||
public static bool ToUInt32(string value, out uint i) =>
|
||||
value.StartsWith("0x")
|
||||
value.StartsWith("0x", StringComparison.OrdinalIgnoreCase)
|
||||
? uint.TryParse(value.Substring(2), NumberStyles.HexNumber, null, out i)
|
||||
: uint.TryParse(value, out i);
|
||||
|
||||
|
|
@ -1034,7 +1053,7 @@ namespace Server
|
|||
public static string GetAttribute(XmlElement node, string attributeName, string defaultValue = null) =>
|
||||
node?.Attributes[attributeName]?.Value ?? defaultValue;
|
||||
|
||||
public static string GetText(XmlElement node, string defaultValue) => node == null ? defaultValue : node.InnerText;
|
||||
public static string GetText(XmlElement node, string defaultValue) => node?.InnerText ?? defaultValue;
|
||||
|
||||
public static int GetAddressValue(IPAddress address) => BitConverter.ToInt32(address.GetAddressBytes(), 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,8 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
throw new Exception("No serials left to allocate for mobiles");
|
||||
OutOfMemory("No serials left to allocate for mobiles");
|
||||
return Serial.MinusOne;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +99,8 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
throw new Exception("No serials left to allocate for items");
|
||||
OutOfMemory("No serials left to allocate for items");
|
||||
return Serial.MinusOne;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,6 +116,8 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
private static void OutOfMemory(string message) => throw new OutOfMemoryException(message);
|
||||
|
||||
internal static int _Saves;
|
||||
internal static List<Type> ItemTypes { get; } = new List<Type>();
|
||||
internal static List<Type> MobileTypes { get; } = new List<Type>();
|
||||
|
|
@ -157,15 +161,13 @@ namespace Server
|
|||
p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
|
||||
}
|
||||
|
||||
var list = TcpServer.Instances;
|
||||
|
||||
p.Acquire();
|
||||
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
if (list[i].Mobile != null)
|
||||
if (ns.Mobile != null)
|
||||
{
|
||||
list[i].Send(p);
|
||||
ns.Send(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -338,7 +340,7 @@ namespace Server
|
|||
reader.Seek(entry.Position, SeekOrigin.Begin);
|
||||
|
||||
t.SaveBuffer = new BufferWriter(new byte[entry.Length], true);
|
||||
reader.Read(t.SaveBuffer.Data);
|
||||
reader.Read(t.SaveBuffer.Buffer);
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
|
|
@ -737,7 +739,7 @@ namespace Server
|
|||
public static void SerializeTo(this ISerializable entity, IGenericWriter writer)
|
||||
{
|
||||
var saveBuffer = entity.SaveBuffer;
|
||||
writer.Write(saveBuffer.Data, (int)saveBuffer.Position);
|
||||
writer.Write(saveBuffer.Buffer, (int)saveBuffer.Position);
|
||||
|
||||
// Resize to exact buffer size
|
||||
entity.SaveBuffer.Resize((int)entity.SaveBuffer.Position);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue