Formatting FIxes (#58)
This commit is contained in:
parent
57fb9fb525
commit
096d39609e
1318 changed files with 11633 additions and 22129 deletions
|
|
@ -24,10 +24,7 @@ namespace Server.Network
|
|||
{
|
||||
private PacketReader m_Reader;
|
||||
|
||||
public EncodedReader(PacketReader reader)
|
||||
{
|
||||
m_Reader = reader;
|
||||
}
|
||||
public EncodedReader(PacketReader reader) => m_Reader = reader;
|
||||
|
||||
public void Trace(NetState state)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -86,10 +86,7 @@ namespace Server.Network
|
|||
public class AsyncState
|
||||
{
|
||||
public bool Paused { get; set; }
|
||||
public AsyncState(bool paused)
|
||||
{
|
||||
Paused = paused;
|
||||
}
|
||||
public AsyncState(bool paused) => Paused = paused;
|
||||
}
|
||||
|
||||
public class NetState : IComparable<NetState>
|
||||
|
|
@ -402,10 +399,7 @@ namespace Server.Network
|
|||
|
||||
public IAccount Account { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return m_ToString;
|
||||
}
|
||||
public override string ToString() => m_ToString;
|
||||
|
||||
public static List<NetState> Instances { get; } = new List<NetState>();
|
||||
|
||||
|
|
@ -595,11 +589,9 @@ namespace Server.Network
|
|||
pr.Complete();
|
||||
}
|
||||
|
||||
public PacketHandler GetHandler(int packetID)
|
||||
{
|
||||
return ContainerGridLines ? PacketHandlers.Get6017Handler(packetID) :
|
||||
public PacketHandler GetHandler(int packetID) =>
|
||||
ContainerGridLines ? PacketHandlers.Get6017Handler(packetID) :
|
||||
PacketHandlers.GetHandler(packetID);
|
||||
}
|
||||
|
||||
private long m_NextCheckActivity;
|
||||
|
||||
|
|
@ -619,15 +611,13 @@ namespace Server.Network
|
|||
|
||||
try
|
||||
{
|
||||
using (StreamWriter op = new StreamWriter("network-errors.log", true))
|
||||
{
|
||||
op.WriteLine("# {0}", DateTime.UtcNow);
|
||||
using StreamWriter op = new StreamWriter("network-errors.log", true);
|
||||
op.WriteLine("# {0}", DateTime.UtcNow);
|
||||
|
||||
op.WriteLine(ex);
|
||||
op.WriteLine(ex);
|
||||
|
||||
op.WriteLine();
|
||||
op.WriteLine();
|
||||
}
|
||||
op.WriteLine();
|
||||
op.WriteLine();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -639,7 +629,9 @@ namespace Server.Network
|
|||
|
||||
private int m_Disposing;
|
||||
|
||||
public bool IsDisposing { get { return m_Disposing != 0; } private set { m_Disposing = value ? 1 : 0; } }
|
||||
public bool IsDisposing { get => m_Disposing != 0;
|
||||
private set => m_Disposing = value ? 1 : 0;
|
||||
}
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
|
|
@ -751,14 +743,8 @@ namespace Server.Network
|
|||
return info.RequiredClient != null ? Version >= info.RequiredClient : (Flags & info.ClientFlags) != 0;
|
||||
}
|
||||
|
||||
public bool SupportsExpansion(Expansion ex, bool checkCoreExpansion = true)
|
||||
{
|
||||
return SupportsExpansion(ExpansionInfo.GetInfo(ex), checkCoreExpansion);
|
||||
}
|
||||
public bool SupportsExpansion(Expansion ex, bool checkCoreExpansion = true) => SupportsExpansion(ExpansionInfo.GetInfo(ex), checkCoreExpansion);
|
||||
|
||||
public int CompareTo(NetState other)
|
||||
{
|
||||
return other == null ? 1 : m_ToString.CompareTo(other.m_ToString);
|
||||
}
|
||||
public int CompareTo(NetState other) => other == null ? 1 : m_ToString.CompareTo(other.m_ToString);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,11 +156,9 @@ namespace Server.Network
|
|||
|
||||
try
|
||||
{
|
||||
using (StreamWriter op = new StreamWriter("net_opt.log", true))
|
||||
{
|
||||
op.WriteLine("Redundant compile for packet {0}, use Acquire() and Release()", GetType());
|
||||
op.WriteLine(new StackTrace());
|
||||
}
|
||||
using StreamWriter op = new StreamWriter("net_opt.log", true);
|
||||
op.WriteLine("Redundant compile for packet {0}, use Acquire() and Release()", GetType());
|
||||
op.WriteLine(new StackTrace());
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -215,12 +213,10 @@ namespace Server.Network
|
|||
{
|
||||
Console.WriteLine("Warning: Compression buffer overflowed on packet 0x{0:X2} ('{1}') (length={2})",
|
||||
PacketID, GetType().Name, length);
|
||||
using (StreamWriter op = new StreamWriter("compression_overflow.log", true))
|
||||
{
|
||||
op.WriteLine("{0} Warning: Compression buffer overflowed on packet 0x{1:X2} ('{2}') (length={3})",
|
||||
DateTime.UtcNow, PacketID, GetType().Name, length);
|
||||
op.WriteLine(new StackTrace());
|
||||
}
|
||||
using StreamWriter op = new StreamWriter("compression_overflow.log", true);
|
||||
op.WriteLine("{0} Warning: Compression buffer overflowed on packet 0x{1:X2} ('{2}') (length={3})",
|
||||
DateTime.UtcNow, PacketID, GetType().Name, length);
|
||||
op.WriteLine(new StackTrace());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -228,20 +228,14 @@ namespace Server.Network
|
|||
m_6017Handlers[packetID] = new PacketHandler(packetID, length, ingame, onReceive);
|
||||
}
|
||||
|
||||
public static PacketHandler GetHandler(int packetID)
|
||||
{
|
||||
return Handlers[packetID];
|
||||
}
|
||||
public static PacketHandler GetHandler(int packetID) => Handlers[packetID];
|
||||
|
||||
public static void Register6017(int packetID, int length, bool ingame, OnPacketReceive onReceive)
|
||||
{
|
||||
m_6017Handlers[packetID] = new PacketHandler(packetID, length, ingame, onReceive);
|
||||
}
|
||||
|
||||
public static PacketHandler Get6017Handler(int packetID)
|
||||
{
|
||||
return m_6017Handlers[packetID];
|
||||
}
|
||||
public static PacketHandler Get6017Handler(int packetID) => m_6017Handlers[packetID];
|
||||
|
||||
public static void RegisterExtended(int packetID, bool ingame, OnPacketReceive onReceive)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,10 +35,7 @@ namespace Server.Network
|
|||
public long Consumed => m_Reader.Consumed;
|
||||
public long Remaining => m_Reader.Remaining;
|
||||
|
||||
public PacketReader(ReadOnlySequence<byte> seq)
|
||||
{
|
||||
m_Reader = new SequenceReader<byte>(seq);
|
||||
}
|
||||
public PacketReader(ReadOnlySequence<byte> seq) => m_Reader = new SequenceReader<byte>(seq);
|
||||
|
||||
public byte Peek() => m_Reader.TryPeek(out byte value) ? value : (byte)0;
|
||||
|
||||
|
|
@ -46,21 +43,19 @@ namespace Server.Network
|
|||
{
|
||||
try
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter("Packets.log", true))
|
||||
using StreamWriter sw = new StreamWriter("Packets.log", true);
|
||||
byte[] buffer = m_Reader.Sequence.ToArray();
|
||||
|
||||
if (buffer.Length > 0)
|
||||
sw.WriteLine("Client: {0}: Unhandled packet 0x{1:X2}", state, buffer[0]);
|
||||
|
||||
using (MemoryStream ms = new MemoryStream(buffer))
|
||||
{
|
||||
byte[] buffer = m_Reader.Sequence.ToArray();
|
||||
|
||||
if (buffer.Length > 0)
|
||||
sw.WriteLine("Client: {0}: Unhandled packet 0x{1:X2}", state, buffer[0]);
|
||||
|
||||
using (MemoryStream ms = new MemoryStream(buffer))
|
||||
{
|
||||
Utility.FormatBuffer(sw, ms, buffer.Length);
|
||||
}
|
||||
|
||||
sw.WriteLine();
|
||||
sw.WriteLine();
|
||||
Utility.FormatBuffer(sw, ms, buffer.Length);
|
||||
}
|
||||
|
||||
sw.WriteLine();
|
||||
sw.WriteLine();
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -181,10 +176,7 @@ namespace Server.Network
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
public bool IsSafeChar(int c)
|
||||
{
|
||||
return c >= 0x20 && c < 0xFFFE;
|
||||
}
|
||||
public bool IsSafeChar(int c) => c >= 0x20 && c < 0xFFFE;
|
||||
|
||||
public string ReadUTF8StringSafe(int fixedLength)
|
||||
{
|
||||
|
|
@ -229,13 +221,11 @@ namespace Server.Network
|
|||
return sb.ToString();
|
||||
}
|
||||
|
||||
public string ReadUTF8String()
|
||||
{
|
||||
return Utility.UTF8.GetString(
|
||||
public string ReadUTF8String() =>
|
||||
Utility.UTF8.GetString(
|
||||
m_Reader.TryReadTo(out ReadOnlySpan<byte> span, (byte)'\0', true) ? span :
|
||||
m_Reader.Sequence.Slice(m_Reader.Position, m_Reader.Remaining).ToArray()
|
||||
m_Reader.Sequence.Slice(m_Reader.Position, m_Reader.Remaining).ToArray()
|
||||
);
|
||||
}
|
||||
|
||||
public string ReadString()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -665,10 +665,7 @@ namespace Server.Network
|
|||
m_Stream.Write((byte)(dead ? 0 : 2));
|
||||
}
|
||||
|
||||
public static Packet Instantiate(bool dead)
|
||||
{
|
||||
return dead ? Dead : Alive;
|
||||
}
|
||||
public static Packet Instantiate(bool dead) => dead ? Dead : Alive;
|
||||
}
|
||||
|
||||
public sealed class SpeedControl : Packet
|
||||
|
|
@ -1988,10 +1985,7 @@ namespace Server.Network
|
|||
//m_Stream.Fill();
|
||||
}
|
||||
|
||||
public static Packet Instantiate(bool mode)
|
||||
{
|
||||
return mode ? InWarMode : InPeaceMode;
|
||||
}
|
||||
public static Packet Instantiate(bool mode) => mode ? InWarMode : InPeaceMode;
|
||||
}
|
||||
|
||||
public sealed class Swing : Packet
|
||||
|
|
@ -2352,10 +2346,7 @@ namespace Server.Network
|
|||
private int m_StringCount;
|
||||
private PacketWriter m_Strings;
|
||||
|
||||
static DisplayGumpPacked()
|
||||
{
|
||||
m_Buffer[0] = (byte)' ';
|
||||
}
|
||||
static DisplayGumpPacked() => m_Buffer[0] = (byte)' ';
|
||||
|
||||
public DisplayGumpPacked(Gump gump)
|
||||
: base(0xDD)
|
||||
|
|
@ -2737,10 +2728,7 @@ namespace Server.Network
|
|||
m_Stream.Write(playSound);
|
||||
}
|
||||
|
||||
public static SeasonChange Instantiate(int season)
|
||||
{
|
||||
return Instantiate(season, true);
|
||||
}
|
||||
public static SeasonChange Instantiate(int season) => Instantiate(season, true);
|
||||
|
||||
public static SeasonChange Instantiate(int season, bool playSound)
|
||||
{
|
||||
|
|
@ -2790,10 +2778,7 @@ namespace Server.Network
|
|||
|
||||
public static FeatureFlags Value{ get; set; }
|
||||
|
||||
public static SupportedFeatures Instantiate(NetState ns)
|
||||
{
|
||||
return new SupportedFeatures(ns);
|
||||
}
|
||||
public static SupportedFeatures Instantiate(NetState ns) => new SupportedFeatures(ns);
|
||||
}
|
||||
|
||||
public static class AttributeNormalizer
|
||||
|
|
|
|||
|
|
@ -43,9 +43,6 @@ namespace Server.Network
|
|||
return taskCompletion.Task;
|
||||
}
|
||||
|
||||
public T Dequeue()
|
||||
{
|
||||
return m_Queue.Take();
|
||||
}
|
||||
public T Dequeue() => m_Queue.Take();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,15 +28,9 @@ namespace Server.Network
|
|||
{
|
||||
public static class SocketExtensions
|
||||
{
|
||||
public static Task<int> ReceiveAsync(this Socket socket, Memory<byte> memory, SocketFlags socketFlags)
|
||||
{
|
||||
return SocketTaskExtensions.ReceiveAsync(socket, GetArray(memory), socketFlags);
|
||||
}
|
||||
public static Task<int> ReceiveAsync(this Socket socket, Memory<byte> memory, SocketFlags socketFlags) => SocketTaskExtensions.ReceiveAsync(socket, GetArray(memory), socketFlags);
|
||||
|
||||
public static ArraySegment<byte> GetArray(this Memory<byte> memory)
|
||||
{
|
||||
return ((ReadOnlyMemory<byte>)memory).GetArray();
|
||||
}
|
||||
public static ArraySegment<byte> GetArray(this Memory<byte> memory) => ((ReadOnlyMemory<byte>)memory).GetArray();
|
||||
|
||||
public static ArraySegment<byte> GetArray(this ReadOnlyMemory<byte> memory)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue