fix(network): Converts House Design Detailed Packet (#538)
- [X] Converts design state detailed packet - [X] Removes `Packet` class - [X] Removes `Send(Packet)` function signatures - [X] Removes `PacketWriter` class - [X] Updates dependencies.
This commit is contained in:
parent
0a435644eb
commit
ec1cc10821
24 changed files with 538 additions and 463 deletions
|
|
@ -511,78 +511,6 @@ namespace Server.Network
|
|||
}
|
||||
}
|
||||
|
||||
public virtual void Send(Packet p)
|
||||
{
|
||||
if (Connection == null || BlockAllPackets)
|
||||
{
|
||||
p.OnSend();
|
||||
return;
|
||||
}
|
||||
|
||||
var writer = SendPipe.Writer;
|
||||
|
||||
try
|
||||
{
|
||||
byte[] buffer = p.Compile(CompressionEnabled, out var length);
|
||||
|
||||
if (buffer == null)
|
||||
{
|
||||
WriteConsole("null buffer send, disconnecting...", this);
|
||||
using (StreamWriter op = new StreamWriter("null_send.log", true))
|
||||
{
|
||||
op.WriteLine("{0} Client: {1}: null buffer send, disconnecting...", DateTime.UtcNow, this);
|
||||
op.WriteLine(new System.Diagnostics.StackTrace());
|
||||
}
|
||||
|
||||
Disconnect("Attempted to send null packet buffer.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer.Length <= 0 || length <= 0)
|
||||
{
|
||||
p.OnSend();
|
||||
return;
|
||||
}
|
||||
|
||||
PacketSendProfile prof = null;
|
||||
|
||||
if (Core.Profiling)
|
||||
{
|
||||
prof = PacketSendProfile.Acquire(p.PacketID);
|
||||
prof.Start();
|
||||
}
|
||||
|
||||
var result = writer.TryGetMemory();
|
||||
|
||||
if (result.Length >= length)
|
||||
{
|
||||
result.CopyFrom(buffer.AsSpan(0, length));
|
||||
writer.Advance((uint)length);
|
||||
|
||||
if (!_flushQueued)
|
||||
{
|
||||
FlushPending.Enqueue(this);
|
||||
_flushQueued = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteConsole("Too much data pending, disconnecting...");
|
||||
Disconnect("Too much data pending.");
|
||||
}
|
||||
|
||||
prof?.Finish(length);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine(ex);
|
||||
#endif
|
||||
TraceException(ex);
|
||||
Disconnect("Exception while sending.");
|
||||
}
|
||||
}
|
||||
|
||||
internal void Start()
|
||||
{
|
||||
if (Interlocked.CompareExchange(ref _running, 1, 0) == 1 || Connection == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue