Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetDataEventArgs Length is greater by one than it should be. #181

Open
AnzhelikaO opened this issue Jul 14, 2020 · 3 comments
Open

GetDataEventArgs Length is greater by one than it should be. #181

AnzhelikaO opened this issue Jul 14, 2020 · 3 comments

Comments

@AnzhelikaO
Copy link

AnzhelikaO commented Jul 14, 2020

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.

@kevzhao2
Copy link
Member

GetDataEventArgs includes the packet ID in the length.

@AnzhelikaO
Copy link
Author

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.

@AnzhelikaO
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants