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
|
|
@ -23,7 +23,7 @@ namespace Server.Network
|
|||
{
|
||||
public const int MaxWorldItemPacketLength = 26;
|
||||
|
||||
public static int CreateWorldItem(ref Span<byte> buffer, Item item)
|
||||
public static int CreateWorldItem(Span<byte> buffer, Item item)
|
||||
{
|
||||
var itemID = item is BaseMulti ? item.ItemID | 0x4000 : item.ItemID & 0x3FFF;
|
||||
var hasAmount = item.Amount != 0;
|
||||
|
|
@ -87,13 +87,13 @@ namespace Server.Network
|
|||
Span<byte> buffer = stackalloc byte[MaxWorldItemPacketLength];
|
||||
|
||||
var length = ns.StygianAbyss ?
|
||||
CreateWorldItemNew(ref buffer, item, ns.HighSeas) :
|
||||
CreateWorldItem(ref buffer, item);
|
||||
CreateWorldItemNew(buffer, item, ns.HighSeas) :
|
||||
CreateWorldItem(buffer, item);
|
||||
|
||||
ns.Send(buffer.Slice(0, length));
|
||||
}
|
||||
|
||||
public static int CreateWorldItemNew(ref Span<byte> buffer, Item item, bool isHS)
|
||||
public static int CreateWorldItemNew(Span<byte> buffer, Item item, bool isHS)
|
||||
{
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0xF3); // Packet ID
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue