fix: Fixes thread guard and cleans up incoming packet reader (#1641)
### Summary * Fixes syntax compile error when THREADGUARD is enabled. * Removes `int packetLength` from incoming packet handles since they aren't needed. ### Developer Notes Incoming packet handler `SpanReader` is now properly scoped to that packet by length.
This commit is contained in:
parent
25a75fdf24
commit
7d9bc9ff0a
31 changed files with 190 additions and 157 deletions
|
|
@ -469,7 +469,9 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
|
|||
Console.WriteLine("Attempting to get pipe buffer from wrong thread!");
|
||||
Console.WriteLine(new StackTrace());
|
||||
Utility.PopColor();
|
||||
return;
|
||||
|
||||
buffer = Array.Empty<byte>();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
buffer = SendPipe.Writer.AvailableToWrite();
|
||||
|
|
@ -842,12 +844,16 @@ public partial class NetState : IComparable<NetState>, IValueLinkListNode<NetSta
|
|||
|
||||
UpdatePacketCount(packetId);
|
||||
|
||||
var packetBuffer = packetReader.Buffer[..packetLength];
|
||||
|
||||
if (PacketLogging)
|
||||
{
|
||||
LogPacket(packetReader.Buffer[..packetLength], true);
|
||||
LogPacket(packetBuffer, true);
|
||||
}
|
||||
|
||||
handler.OnReceive(this, packetReader, packetLength);
|
||||
// Make a new SpanReader that is limited to the length of the packet.
|
||||
// This allows us to use reader.Remaining for VendorBuyReply packet
|
||||
handler.OnReceive(this, new SpanReader(packetBuffer));
|
||||
|
||||
prof?.Finish(packetLength);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue