GetDataEventArgs Length is greater by one than it should be.
AnzhelikaO opened this issue · 3 comments
Console.WriteLine((PacketTypes.PlayerSpawn, args.Length, 10));
writes (PlayerSpawn, 11, 10)
where 10 is the actual packet size (https://tshock.readme.io/docs/multiplayer-packet-structure#spawn-player-12). Same for other packets.
GetDataEventArgs
includes the packet ID in the length.
But why? args.Index
is the start of the packet data, not packet type byte. I think it's logical that args.Msg.readBuffer.Skip(args.Index).Take(args.Length)
returns packet data. But instead it's packet data plus next packet's length and we have to take args.Length - 1
for some reason.
Also if i need to seek data at the end of the packet i instinctively use args.Msg.readBuffer[args.Index + args.Length - 1]
, which will return incorrect byte.