fix(core): Adds SkipLocalsInitAttribute support, optimizes broadcasted packets (#363)
- [X] Adds support for `SkipLocalsInitAttribute`. SkipLocalsInitAttribute skips initializing stack variables including `stackalloc`. I don't think it is wired/working yet but should be implemented soon. - [X] Optimizes broadcasted packets by checking if the first byte (packet ID) is non-zero. If it is already set, it reuses the buffer. - [X] Removes unnecessary refs to Spans. I don't think the Span struct itself is mutable, so a ref is not helpful.
This commit is contained in:
parent
9c9591b098
commit
03d0a4664e
25 changed files with 478 additions and 285 deletions
|
|
@ -96,7 +96,7 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLocalizedLength("")];
|
||||
var packetCreated = false;
|
||||
buffer.InitializePacket();
|
||||
|
||||
foreach (var state in GetClientsInRange(12))
|
||||
{
|
||||
|
|
@ -104,14 +104,14 @@ namespace Server.Engines.MLQuests.Mobiles
|
|||
|
||||
if (m.CanSee(this) && m.InLOS(this) && m.CanBeginAction(this))
|
||||
{
|
||||
if (!packetCreated)
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
// Double Click On Me For Help!
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
ref buffer,
|
||||
Serial, Body, MessageType.Regular, 946, 3, 1078099, Name
|
||||
buffer, Serial, Body, MessageType.Regular, 946, 3, 1078099, Name
|
||||
);
|
||||
packetCreated = true;
|
||||
|
||||
buffer = buffer.Slice(0, length);
|
||||
}
|
||||
|
||||
state.Send(buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue