fix(core): Cleans up uninitialized packets (#397)
- [X] Encapsulates/abstracts buffer cache checking - [X] Changes mobile moving cache to use Span2D
This commit is contained in:
parent
0b9fb9c071
commit
8763be8a21
18 changed files with 417 additions and 529 deletions
|
|
@ -152,19 +152,25 @@ namespace Server
|
|||
{
|
||||
var length = OutgoingMessagePackets.GetMaxMessageLength(text);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[length];
|
||||
length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial.MinusOne, -1, MessageType.Regular, hue, 3, ascii, "ENU", "System", text
|
||||
);
|
||||
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
Span<byte> buffer = stackalloc byte[length].InitializePacket();
|
||||
|
||||
foreach (var ns in TcpServer.Instances)
|
||||
{
|
||||
if (ns.Mobile != null)
|
||||
if (ns.Mobile == null)
|
||||
{
|
||||
ns.Send(buffer);
|
||||
continue;
|
||||
}
|
||||
|
||||
length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial.MinusOne, -1, MessageType.Regular, hue, 3, ascii, "ENU", "System", text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
{
|
||||
buffer = buffer.Slice(0, length); // Adjust to the actual size
|
||||
}
|
||||
|
||||
ns.Send(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue