ChillerDragon / teeworlds-protocol

Documenting the teeworlds network protocol
8 stars 3 forks source link

Start working on msg id layout (WRONG FOR NOW) #15

Closed ChillerDragon closed 1 year ago

ChillerDragon commented 1 year ago

irb(main):008:0> "01".to_i(16).to_s(2).rjust(8, '0') => "00000001" irb(main):009:0> "80".to_i(16).to_s(2).rjust(8, '0') => "10000000"

image

ChillerDragon commented 1 year ago

Why is it two bytes? Is it always two bytes? Is the sys flag in the middle? But at the end when int unpacked?

ChillerDragon commented 1 year ago

Most of them seem 1 byte. This is the first two byter i noticed

ChillerDragon commented 1 year ago

Okay I think I got it. Call vote is actually the first message that overflows into two bytes. Why? Well because its int packed and mixed with the sys flag. So the int packer eats up 2 bits (extended bit and sign bit) and the sys flag one more. Meaning we take one byte (8 bits) and remove 3 fields then we are left with the maximum number

ES11 111S
  11 111 => 31

So everything from here on wards will be 2 bytes https://chillerdragon.github.io/teeworlds-protocol/07/game_messages.html#NETMSGTYPE_CL_CALLVOTE