Hey guys,
I haven't posted anything useful in a while (this thread is probably useless too) but I thought I'd answer a question that a lot of people might not already know!
Take the following example packet:
Code:
out.write(opcode)
out.write(0)
out.write(player.x)
out.write(player.y)
out.write(0)
out.write(0)
out.write(someclass.var)
Notice the random 0's in that packet? In the client, these can sometimes be random values that we think make no sense. That's because they do not make sense and are called Reserved Data (my theory anyway, I've seen it done before).
Reserved data are like placeholders. It allows the client developers to send additional data without having to modify the structure of the packet and for easy coding on the server end.
We have seen this already, just try comparing an old client with a newer one, you might see that what was a random var suddenly has a meaningful value to it! (a good example is the login protocol, I think...)
Now on the server side, we can stop identifying unknown packets as:
Code:
int idfkwhatthis = in.read();
And instead, give it a more meaningful name such as:
Code:
int clientReservedPacketData = in.read();
Another thing about packets and their data that people don't know about is endians and reading data using bitshifts etc.
For those who don't know what an endian is, read: https://en.wikipedia.org/wiki/Endianness - it will explain it better than I will
Also on that topic, you might see packets that look like this:
Code:
out.write(opcode)
out.write(player.x >> 8 | y) // or some bs like this
This is used for compression over a network. Instead of sending 2 bytes/ints/whatever you can just send the 1 type which is quicker and uses less data (meaning a much faster upload/download!).
Hope this made sense to you guys