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
|
|
@ -88,10 +88,15 @@ namespace Server.Items
|
|||
else
|
||||
{
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength];
|
||||
OutgoingEffectPackets.CreateSoundEffect(ref buffer, 0x127, GetWorldLocation());
|
||||
buffer.InitializePacket();
|
||||
|
||||
foreach (var state in GetClientsInRange(2))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, 0x127, GetWorldLocation());
|
||||
}
|
||||
|
||||
state.Send(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,12 +50,12 @@ namespace Server.Items
|
|||
|
||||
if (ns.StygianAbyss)
|
||||
{
|
||||
length = OutgoingItemPackets.CreateWorldItemNew(ref buffer, this, ns.HighSeas);
|
||||
length = OutgoingItemPackets.CreateWorldItemNew(buffer, this, ns.HighSeas);
|
||||
BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(8, 2), GMItemId);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = OutgoingItemPackets.CreateWorldItem(ref buffer, this);
|
||||
length = OutgoingItemPackets.CreateWorldItem(buffer, this);
|
||||
BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(7, 2), GMItemId);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,12 +56,12 @@ namespace Server.Items
|
|||
|
||||
if (ns.StygianAbyss)
|
||||
{
|
||||
length = OutgoingItemPackets.CreateWorldItemNew(ref buffer, this, ns.HighSeas);
|
||||
length = OutgoingItemPackets.CreateWorldItemNew(buffer, this, ns.HighSeas);
|
||||
BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(8, 2), GMItemId);
|
||||
}
|
||||
else
|
||||
{
|
||||
length = OutgoingItemPackets.CreateWorldItem(ref buffer, this);
|
||||
length = OutgoingItemPackets.CreateWorldItem(buffer, this);
|
||||
BinaryPrimitives.WriteUInt16BigEndian(buffer.Slice(7, 2), GMItemId);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue