diff --git a/steam/game_servers.py b/steam/game_servers.py index 9c86550..3d1782c 100644 --- a/steam/game_servers.py +++ b/steam/game_servers.py @@ -123,6 +123,17 @@ from time import time as _time from enum import IntEnum from steam.util.binary import StructReader +__all__ = ['query_master', 'a2s_info', 'a2s_players', 'a2s_rules', 'a2s_ping'] + + +def _u(data): + return data.decode('utf-8', 'replace') + + +class StructReader(StructReader): + def read_cstring(self): + return _u(super(StructReader, self).read_cstring()) + class MSRegion(IntEnum): US_East = 0x00 @@ -338,11 +349,11 @@ def a2s_info(server_addr, timeout=2, force_goldsrc=False): info = { '_ping': ping, '_type': b'goldsrc', - 'address': data.read_cstring().decode('utf-8', 'replace'), - 'name': data.read_cstring().decode('utf-8', 'replace'), - 'map': data.read_cstring().decode('utf-8', 'replace'), - 'folder': data.read_cstring().decode('utf-8', 'replace'), - 'game': data.read_cstring().decode('utf-8', 'replace'), + 'address': data.read_cstring(), + 'name': data.read_cstring(), + 'map': data.read_cstring(), + 'folder': data.read_cstring(), + 'game': data.read_cstring(), } (info['players'], @@ -354,9 +365,12 @@ def a2s_info(server_addr, timeout=2, force_goldsrc=False): info['mod'], ) = data.unpack('