From 705a3a2ab7328d92a9a5c2fe6deb2941df598f25 Mon Sep 17 00:00:00 2001 From: Rossen Georgiev Date: Sat, 27 Jan 2018 19:57:35 +0000 Subject: [PATCH] a2s: fix typos; remove return None; fix CSGO Related to #140 --- steam/game_servers.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/steam/game_servers.py b/steam/game_servers.py index 3d1782c..f37866d 100644 --- a/steam/game_servers.py +++ b/steam/game_servers.py @@ -121,7 +121,7 @@ from re import match as _re_match from struct import pack as _pack, unpack_from as _unpack_from from time import time as _time from enum import IntEnum -from steam.util.binary import StructReader +from steam.util.binary import StructReader as _StructReader __all__ = ['query_master', 'a2s_info', 'a2s_players', 'a2s_rules', 'a2s_ping'] @@ -130,7 +130,7 @@ def _u(data): return data.decode('utf-8', 'replace') -class StructReader(StructReader): +class StructReader(_StructReader): def read_cstring(self): return _u(super(StructReader, self).read_cstring()) @@ -225,7 +225,7 @@ def _handle_a2s_response(sock): sock.settimeout(0.3) return _handle_a2s_multi_packet_response(sock, packet) else: - raise RuntimeError("Invalid reponse header") + raise RuntimeError("Invalid reponse header - %d" % header) def _handle_a2s_multi_packet_response(sock, packet): @@ -450,29 +450,35 @@ def a2s_players(server_addr, timeout=2, challenge=0): ss.settimeout(timeout) # request challenge number + header = None + if challenge in (-1, 0): ss.send(_pack('