Client message format
From ioquake3 wiki
At its basic level, a client message consists of the server ID, the sequence number of the last server netchan message received, the ID of the last server command received, a list of client commands, and optional movement data. Since there can be a variable number of client commands and the movement data is optional, these operations start with an 8-bit identifier code to disambiguate between them. The end of the list is identified with a special EOF code.
Contents |
Structures
top-level format
| 32 bits | server ID |
| 32 bits | sequence number of last server netchan message received |
| 32 bits | ID of last server command received |
| <client-command>* | |
| (<move> | <move-no-delta>)? | |
| 8 bits | 0x05 EOF indicator |
client-command
| 8 bits | 0x04 client-command indicator |
| 32 bits | command ID |
| string | command |
move
| 8 bits | 0x02 move indicator |
| <user-commands> |
move-no-delta
| 8 bits | 0x03 move-no-delta indicator |
| <user-commands> |
user-commands
| 8 bits | num user commands | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| loop {num user commands} times: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
User command values are doubly-encoded with a key that is different than the
key used to encode the entire netchan message. Also, unlike the netchan message encoding, the values are encoded before they are compressed. This second key is generated by xor'ing the netchan message key with the time value. See MSG_WriteDeltaUsercmdKey() and CL_WritePacket() for details.
comments
One interesting effect of encoding the user command values is that because they are encoded before they are compressed, it potentially degrades the compressibility of the values. If, however, the values are effectively random numbers to begin with, then they aren't very compressible anyway, so encoding them wouldn't hurt much.
One suspects that user command encoding is a remnant of legacy code. It seems as if user commands alone were encoded in earlier versions of the code. Later versions may have then encoded the entire message after compression, but left this existing code in place.