diff --git a/opengsq/protocols/source.py b/opengsq/protocols/source.py index d6994ed..f96370c 100644 --- a/opengsq/protocols/source.py +++ b/opengsq/protocols/source.py @@ -89,8 +89,8 @@ def __parse_from_info_src(self, br: BinaryReader) -> SourceInfo: info["players"] = br.read_byte() info["max_players"] = br.read_byte() info["bots"] = br.read_byte() - info["server_type"] = ServerType(br.read_byte()) - info["environment"] = Environment(br.read_byte()) + info["server_type"] = ServerType.parse(br.read_byte()) + info["environment"] = Environment.parse(br.read_byte()) info["visibility"] = Visibility(br.read_byte()) info["vac"] = VAC(br.read_byte()) @@ -138,8 +138,8 @@ def __parse_from_info_detailed(self, br: BinaryReader) -> GoldSourceInfo: info["players"] = br.read_byte() info["max_players"] = br.read_byte() info["protocol"] = br.read_byte() - info["server_type"] = ServerType(ord(chr(br.read_byte()).lower())) - info["environment"] = Environment(ord(chr(br.read_byte()).lower())) + info["server_type"] = ServerType.parse(br.read_byte()) + info["environment"] = Environment.parse(br.read_byte()) info["visibility"] = Visibility(br.read_byte()) info["mod"] = br.read_byte() diff --git a/opengsq/responses/source/environment.py b/opengsq/responses/source/environment.py index 8464e7e..78fc6c2 100644 --- a/opengsq/responses/source/environment.py +++ b/opengsq/responses/source/environment.py @@ -14,3 +14,7 @@ class Environment(IntEnum): Mac = 0x6D """Mac""" + + @staticmethod + def parse(byte: int): + return Environment(ord(chr(byte).lower())) diff --git a/opengsq/responses/source/server_type.py b/opengsq/responses/source/server_type.py index 4eee416..115a17b 100644 --- a/opengsq/responses/source/server_type.py +++ b/opengsq/responses/source/server_type.py @@ -14,3 +14,7 @@ class ServerType(IntEnum): Proxy = 0x70 """SourceTV relay (proxy)""" + + @staticmethod + def parse(byte: int): + return ServerType(ord(chr(byte).lower()))