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
|
|
@ -26,7 +26,7 @@ namespace Server.Network
|
|||
public const int MobileMovingPacketLength = 17;
|
||||
public const int MobileMovingPacketCacheLength = MobileMovingPacketLength * 8 * 2; // 8 notoriety, 2 client versions
|
||||
|
||||
public static void CreateBondedStatus(ref Span<byte> buffer, Serial serial, bool bonded)
|
||||
public static void CreateBondedStatus(Span<byte> buffer, Serial serial, bool bonded)
|
||||
{
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0xBF); // Packet ID
|
||||
|
|
@ -55,7 +55,7 @@ namespace Server.Network
|
|||
ns.Send(ref buffer, writer.Position);
|
||||
}
|
||||
|
||||
public static void CreateDeathAnimation(ref Span<byte> buffer, Serial killed, Serial corpse)
|
||||
public static void CreateDeathAnimation(Span<byte> buffer, Serial killed, Serial corpse)
|
||||
{
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0xAF); // Packet ID
|
||||
|
|
@ -72,11 +72,11 @@ namespace Server.Network
|
|||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[DeathAnimationPacketLength];
|
||||
CreateDeathAnimation(ref span, killed, corpse);
|
||||
CreateDeathAnimation(span, killed, corpse);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
||||
public static void CreateMobileMoving(ref Span<byte> buffer, Mobile m, int noto, bool stygianAbyss)
|
||||
public static void CreateMobileMoving(Span<byte> buffer, Mobile m, int noto, bool stygianAbyss)
|
||||
{
|
||||
var loc = m.Location;
|
||||
var hue = m.SolidHueOverride >= 0 ? m.SolidHueOverride : m.Hue;
|
||||
|
|
@ -106,7 +106,7 @@ namespace Server.Network
|
|||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[MobileMovingPacketLength];
|
||||
CreateMobileMoving(ref span, target, noto, ns.StygianAbyss);
|
||||
CreateMobileMoving(span, target, noto, ns.StygianAbyss);
|
||||
ns.Send(span);
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ namespace Server.Network
|
|||
// Packet not created yet
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
CreateMobileMoving(ref buffer, target, noto, stygianAbyss);
|
||||
CreateMobileMoving(buffer, target, noto, stygianAbyss);
|
||||
}
|
||||
|
||||
ns.Send(buffer);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue