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
|
|
@ -417,12 +417,17 @@ namespace Server.Commands
|
|||
);
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingEffectPackets.SoundPacketLength];
|
||||
OutgoingEffectPackets.CreateSoundEffect(ref buffer, index, m);
|
||||
buffer.InitializePacket();
|
||||
|
||||
foreach (var state in m.GetClientsInRange(12))
|
||||
{
|
||||
if (toAll || state.Mobile.CanSee(m))
|
||||
{
|
||||
if (buffer[0] == 0)
|
||||
{
|
||||
OutgoingEffectPackets.CreateSoundEffect(buffer, index, m);
|
||||
}
|
||||
|
||||
state.Send(buffer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace Server.Commands
|
|||
if (list.Count > 0)
|
||||
{
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
OutgoingEntityPackets.CreateRemoveEntity(ref removeEntity, pm.Serial);
|
||||
removeEntity.InitializePacket();
|
||||
|
||||
for (var i = 0; i < list.Count; ++i)
|
||||
{
|
||||
|
|
@ -78,6 +78,11 @@ namespace Server.Commands
|
|||
|
||||
if (!m.CanSee(pm) && Utility.InUpdateRange(m, pm))
|
||||
{
|
||||
if (removeEntity[0] == 0)
|
||||
{
|
||||
OutgoingEntityPackets.CreateRemoveEntity(removeEntity, pm.Serial);
|
||||
}
|
||||
|
||||
m.NetState?.Send(removeEntity);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue