45 lines
1.8 KiB
Markdown
45 lines
1.8 KiB
Markdown
# General packet
|
|
## Client to server spesific
|
|
* Encode (encrypt) data
|
|
* use first byte as checksum
|
|
* every byte ^ 0xAA added together
|
|
* xor
|
|
* Server port ^ 0xCCCC
|
|
* Every other byte
|
|
* Lookup table (use byte as indexing value)
|
|
|
|
|
|
## Shared
|
|
* Can be internal packet
|
|
* If packet is smaller then 3 bytes; forward to plugin handlers (*)before handling them (len(data) <= 2)
|
|
|
|
## Order of operations
|
|
1. Check if banned (if true, cancel rest and handle) [^1]
|
|
2. If first byte in data is (0x19, 0x1d, 0x1f, 0x24 or 0x18) custom code flow required [^2]
|
|
3. HandleSocketReceiveFromConnectedPlayer (cancel rest if handled)
|
|
4. Check if cheat (modified) packet (unexpected at this time, there are some packets we can expect) [^3]
|
|
|
|
[^1]: this could be changed in custom implementation (dont allow inital connection instead)
|
|
[^2]: if (0x18 and length == 2) or (0x19 and length <= 2):
|
|
handle packet and return
|
|
elif (0x1d or 0x1f or 0x24) and length <= 2:
|
|
handle packet, but continue
|
|
[^3]: if ((0x18 or 0x1a) and length <= 3) or ((0x19 or 0x1d) and length <= 2) or
|
|
((0x08 or 0x07 or 0x27) and length >= 5) or (0x37 and length < 400):
|
|
We expect this packet, everything is ok?
|
|
else:
|
|
This is a cheat (modified / injected) packet that should not arrive at this time
|
|
Send a packet to client that you received a modified packet (0x26)
|
|
|
|
# Internal packet
|
|
|condition|name|bit length|type|notes|
|
|
|---|---|---|---|---|
|
|
||messageNumber|0x10|ushort||
|
|
||reliability|0x04|uchar|Has to be over 5 (value > 5)|
|
|
|reliability in (7, 10, 9)|orderingChannel|0x05|||
|
|
|reliability in (7, 10, 9)|orderingIndex|0x10|ushort||
|
|
||isSplitPacket|0x01|bool|Drop packet as we no longer support split packet?|
|
|
|isSplitPacket == 0|dataBitLength|0x10|ushort||
|
|
|isSplitPacket == 0|data|dataBitLength|uchar*||
|
|
|