Quote:
Originally Posted by Zeroxelli
I wouldn't recommend trying to go above level 255, as the Client does (or should) read the level as a byte from the packet. Going over 255 would likely cause a whole load of errors in the client; crash the client; or corrupt the heap inside the client's memory space. It is not a good idea.
|
He would only have one issue, incorrect packets.
Let's say you have a packet like this:
Code:
byte
ushort (2 bytes)
ushort (2 bytes)
He's only supposed to give the byte a value.
However he gives it an ushort value.
The new packet is:
Code:
ushort (2 bytes)
^- sharing an offset -v
ushort (2 bytes)
ushort (2 bytes)
Notice: The last byte in the new packet is not the byte storing the value. It's the remaining byte from the packet. (Will make sense later.)
Now what if we give the last 2 ushorts values as well.
Let's look into the bits.
A byte consist of 8 bits.
An ushort is 2 bytes, so that's 16 bits shared between the 2 bytes is stored at.
So right now it's:
Code:
0 ushort 1[1 - 8]
1 ushort 1[9 - 16]
2 0
3 0
4 0
Then if we add a value to the next ushort, which starts at offset 1, this will happen:
Code:
0 ushort 1[1 - 8]
1 ushort 2[1 - 8]
2 ushort 2[9 - 16]
3 0
4 0
And let's add the last values:
Code:
0 ushort 1[1 - 8]
1 ushort 2[1 - 8]
2 ushort 2[9 - 16]
3 ushort 3[1 - 8]
4 ushort 3[9 - 16]
Conclusion the last 8 bits of the first ushort is overwritten by the bits of the ushort starting at its offsets.
So here is what will happen:
- Client will crash, because of invalid packet.
OR
- He'll get a completely invalid value.