rendered paste body set pkt_type [string index $packet 9]
switch $pkt_type {
"\x14" { # Binary packet
set pkt_counttype [string index $packet 19]
set player_count 0
set build 0
switch $pkt_counttype {
"\x04" {
binary scan [string range $packet 20 21] s1 player_count
set player_count [expr { $player_count & 0xffff }]
}
"\x05" { # "short" player count
binary scan [string range $packet 20 21] s1 player_count
}
"\x06" { # "byte" player count
binary scan [string index $packet 20] c1 player_count
}
"\x01" -
"\x09" -
"\x08" { # no player count, infer as 0 players
set player_count 0
}
default { # "unknown type" player count
set player_count -1
}
}