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

@ -503,28 +503,27 @@ namespace Server.Engines.Doom
/* I cant find any better way to send "speech" using fonts other than default */
public static void POHMessage(Mobile from, int index)
{
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(Msgs[index])];
buffer.InitializePacket();
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(Msgs[index])].InitializePacket();
var eable = from.Map.GetClientsInRange(from.Location);
foreach (var state in eable)
{
if (buffer[0] == 0)
{
var length = OutgoingMessagePackets.CreateMessage(
buffer,
from.Serial,
from.Body,
MessageType.Regular,
MsgParams[index][0],
MsgParams[index][1],
true,
null,
from.Name,
Msgs[index]
);
var length = OutgoingMessagePackets.CreateMessage(
buffer,
from.Serial,
from.Body,
MessageType.Regular,
MsgParams[index][0],
MsgParams[index][1],
true,
null,
from.Name,
Msgs[index]
);
if (length != buffer.Length)
{
buffer = buffer.Slice(0, length); // Adjust to the actual size
}