@@ 122-151 (lines=30) @@ | ||
119 | 'ingame': int(slots.popleft().decode('utf-8')) |
|
120 | }) |
|
121 | ||
122 | @staticmethod |
|
123 | def parse_64_legacy_response(slots: deque, server: GameServer) -> None: |
|
124 | """Parse the 64 slot legacy response |
|
125 | ||
126 | :type slots: deque |
|
127 | :type server: GameServer |
|
128 | :return: |
|
129 | """ |
|
130 | server.server_type = '64_legacy' |
|
131 | server.version = slots.popleft().decode('utf-8') |
|
132 | server.name = slots.popleft().decode('utf-8') |
|
133 | server.map_name = slots.popleft().decode('utf-8') |
|
134 | server.game_type = slots.popleft().decode('utf-8') |
|
135 | server.flags = int(slots.popleft().decode('utf-8')) |
|
136 | server.num_players = int(slots.popleft().decode('utf-8')) |
|
137 | server.max_players = int(slots.popleft().decode('utf-8')) |
|
138 | server.num_clients = int(slots.popleft().decode('utf-8')) |
|
139 | server.max_clients = int(slots.popleft().decode('utf-8')) |
|
140 | ||
141 | if slots[0] == b'': |
|
142 | # no idea what this is, always empty |
|
143 | slots.popleft() |
|
144 | ||
145 | while len(slots) >= 5: |
|
146 | server.append_player({ |
|
147 | 'name': slots.popleft(), |
|
148 | 'clan': slots.popleft(), |
|
149 | 'country': int(slots.popleft().decode('utf-8')), |
|
150 | 'score': int(slots.popleft().decode('utf-8')), |
|
151 | 'ingame': int(slots.popleft().decode('utf-8')) |
|
152 | }) |
|
153 | ||
154 | @staticmethod |
|
@@ 93-119 (lines=27) @@ | ||
90 | elif data[6:6 + 8] == Network.PACKETS['SERVERBROWSE_INFO_EXTENDED_MORE']: |
|
91 | self.parse_extended_more_response(slots, server) |
|
92 | ||
93 | @staticmethod |
|
94 | def parse_vanilla_response(slots: deque, server: GameServer) -> None: |
|
95 | """Parse the default response of the vanilla client |
|
96 | ||
97 | :type slots: deque |
|
98 | :type server: GameServer |
|
99 | :return: |
|
100 | """ |
|
101 | server.server_type = 'vanilla' |
|
102 | server.version = slots.popleft().decode('utf-8') |
|
103 | server.name = slots.popleft().decode('utf-8') |
|
104 | server.map_name = slots.popleft().decode('utf-8') |
|
105 | server.game_type = slots.popleft().decode('utf-8') |
|
106 | server.flags = int(slots.popleft().decode('utf-8')) |
|
107 | server.num_players = int(slots.popleft().decode('utf-8')) |
|
108 | server.max_players = int(slots.popleft().decode('utf-8')) |
|
109 | server.num_clients = int(slots.popleft().decode('utf-8')) |
|
110 | server.max_clients = int(slots.popleft().decode('utf-8')) |
|
111 | ||
112 | while len(slots) >= 5: |
|
113 | # no idea what this is, always empty |
|
114 | server.append_player({ |
|
115 | 'name': slots.popleft(), |
|
116 | 'clan': slots.popleft(), |
|
117 | 'country': int(slots.popleft().decode('utf-8')), |
|
118 | 'score': int(slots.popleft().decode('utf-8')), |
|
119 | 'ingame': int(slots.popleft().decode('utf-8')) |
|
120 | }) |
|
121 | ||
122 | @staticmethod |