|
@@ 118-146 (lines=29) @@
|
| 115 |
|
ingame=bool(int(slots.popleft().decode('utf-8'))) |
| 116 |
|
)) |
| 117 |
|
|
| 118 |
|
@staticmethod |
| 119 |
|
def parse_64_legacy_response(slots: deque, server: GameServer) -> None: |
| 120 |
|
"""Parse the 64 slot legacy response |
| 121 |
|
|
| 122 |
|
:type slots: deque |
| 123 |
|
:type server: GameServer |
| 124 |
|
:return: |
| 125 |
|
""" |
| 126 |
|
server.server_type = '64_legacy' |
| 127 |
|
server.version = slots.popleft().decode('utf-8') |
| 128 |
|
server.name = slots.popleft().decode('utf-8') |
| 129 |
|
server.map_name = slots.popleft().decode('utf-8') |
| 130 |
|
server.game_type = slots.popleft().decode('utf-8') |
| 131 |
|
server.flags = int(slots.popleft().decode('utf-8')) |
| 132 |
|
server.num_players = int(slots.popleft().decode('utf-8')) |
| 133 |
|
server.max_players = int(slots.popleft().decode('utf-8')) |
| 134 |
|
server.num_clients = int(slots.popleft().decode('utf-8')) |
| 135 |
|
server.max_clients = int(slots.popleft().decode('utf-8')) |
| 136 |
|
|
| 137 |
|
# contains sometimes control bytes or \x00 bytes, not sure what it is |
| 138 |
|
slots.popleft() |
| 139 |
|
|
| 140 |
|
while len(slots) >= 5: |
| 141 |
|
server.append_player(Player( |
| 142 |
|
name=slots.popleft().decode('utf-8'), |
| 143 |
|
clan=slots.popleft().decode('utf-8'), |
| 144 |
|
country=int(slots.popleft().decode('utf-8')), |
| 145 |
|
score=int(slots.popleft().decode('utf-8')), |
| 146 |
|
ingame=bool(int(slots.popleft().decode('utf-8'))) |
| 147 |
|
)) |
| 148 |
|
|
| 149 |
|
@staticmethod |
|
@@ 90-115 (lines=26) @@
|
| 87 |
|
# extended response (iex+) packet |
| 88 |
|
self.parse_extended_more_response(slots, server) |
| 89 |
|
|
| 90 |
|
@staticmethod |
| 91 |
|
def parse_vanilla_response(slots: deque, server: GameServer) -> None: |
| 92 |
|
"""Parse the default response of the vanilla client |
| 93 |
|
|
| 94 |
|
:type slots: deque |
| 95 |
|
:type server: GameServer |
| 96 |
|
:return: |
| 97 |
|
""" |
| 98 |
|
server.server_type = 'vanilla' |
| 99 |
|
server.version = slots.popleft().decode('utf-8') |
| 100 |
|
server.name = slots.popleft().decode('utf-8') |
| 101 |
|
server.map_name = slots.popleft().decode('utf-8') |
| 102 |
|
server.game_type = slots.popleft().decode('utf-8') |
| 103 |
|
server.flags = int(slots.popleft().decode('utf-8')) |
| 104 |
|
server.num_players = int(slots.popleft().decode('utf-8')) |
| 105 |
|
server.max_players = int(slots.popleft().decode('utf-8')) |
| 106 |
|
server.num_clients = int(slots.popleft().decode('utf-8')) |
| 107 |
|
server.max_clients = int(slots.popleft().decode('utf-8')) |
| 108 |
|
|
| 109 |
|
while len(slots) >= 5: |
| 110 |
|
server.append_player(Player( |
| 111 |
|
name=slots.popleft().decode('utf-8'), |
| 112 |
|
clan=slots.popleft().decode('utf-8'), |
| 113 |
|
country=int(slots.popleft().decode('utf-8')), |
| 114 |
|
score=int(slots.popleft().decode('utf-8')), |
| 115 |
|
ingame=bool(int(slots.popleft().decode('utf-8'))) |
| 116 |
|
)) |
| 117 |
|
|
| 118 |
|
@staticmethod |