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:
Kamron Batman 2021-01-09 14:10:29 -08:00 • committed by GitHub
parent 0b9fb9c071
commit 8763be8a21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 417 additions and 529 deletions

View file

@ -95,8 +95,7 @@ namespace Server.Engines.MLQuests.Mobiles
return;
}
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength("")];
buffer.InitializePacket();
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength("")].InitializePacket();
foreach (var state in GetClientsInRange(12))
{
@ -104,13 +103,13 @@ namespace Server.Engines.MLQuests.Mobiles
if (m.CanSee(this) && m.InLOS(this) && m.CanBeginAction(this))
{
if (buffer[0] == 0)
{
// Double Click On Me For Help!
var length = OutgoingMessagePackets.CreateMessageLocalized(
buffer, Serial, Body, MessageType.Regular, 946, 3, 1078099, Name
);
// Double Click On Me For Help!
var length = OutgoingMessagePackets.CreateMessageLocalized(
buffer, Serial, Body, MessageType.Regular, 946, 3, 1078099, Name
);
if (length != buffer.Length)
{
buffer = buffer.Slice(0, length);
}