-
Notifications
You must be signed in to change notification settings - Fork 1
Gunz Packet Structure
Packet ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ / =========================== \ / | -- Header -- | \ / | [uint16_t] version | \ / | *[uint16_t] fullSize | \ / | [uint16_t] checksum | \ / --------------------------- \ / | -- Payload -- | \ / | *[uint16_t] dataSize | \ / | *[uint16_t] commandID | \ / | *[uint8_t ] packetID | \ / | *[ Buffer ] parameters | \ / =========================== \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If a member has a *
beside it, it will be encrypted when version == 0x65
. These must be passed off to the decrypt() function in the crypto module for processing.
version: The version is 0x64
for unencrypted packets, and 0x65
for encrypted packets. There is an extra decryption step when a packet with a version of 0x65
is encountered.
fullSize: The full size of the packet, including the header.
checksum: This value is set to zero during packet construction, then, once everything else is filled in and the packet is encrypted if necessary, the checksum algorithm in cockpit/src/packet/crypto.cpp
is used to update this parameter.
dataSize: The size of the packet’s payload. This can be expressed as sizeof(packet) - sizeof(header)
. My guess is that this is provided to potentially expand the header’s data structure; but that’s just a guess.
commandID: Each packet has a registered commandID
. This is shipped off to the appropriate packet::Registry
’s dispatch method for processing.
packetID: A counter, incrementing by one every time a packet is sent out to the client. Since it’s only 8 bits wide, an overflow wraps the counter back around to zero. No biggie. It starts out at 1, but I have a feeling the starting number is totally arbitrary.
parameters: All the packet’s parameters, serialized and concatenated in left-to-right order.