Skip to content

Commit

Permalink
fix: Fixes network issue with incoming packet length (#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamronbatman authored Dec 20, 2023
1 parent 61e9dd2 commit 1e73802
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Projects/Server/Network/NetState/NetState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -844,16 +844,17 @@ private unsafe ParserState HandlePacket(SpanReader packetReader, byte packetId,

UpdatePacketCount(packetId);

var packetBuffer = packetReader.Buffer[..packetLength];

if (PacketLogging)
{
LogPacket(packetBuffer, true);
LogPacket(packetReader.Buffer[..packetLength], true);
}

// 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));
var start = packetReader.Position;
var remainingLength = packetLength - packetReader.Position;

handler.OnReceive(this, new SpanReader(packetReader.Buffer.Slice(start, remainingLength)));

prof?.Finish(packetLength);

Expand Down

0 comments on commit 1e73802

Please sign in to comment.