Skip to content

Commit

Permalink
Update gamespy1.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BattlefieldDuck committed Mar 18, 2023
1 parent 8ac6454 commit 1d8cc6c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions opengsq/protocols/gamespy1.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __parse_as_key_values(self, br: BinaryReader, is_status=False):
return kv

def __parse_as_object(self, br: BinaryReader, is_player=False):
items, keyhashes, filters = [], [], []
items, keyhashes, filters = {}, [], []

while br.length() > 0:
# Get the key, for example player_1, frags_1, ping_1, etc...
Expand Down Expand Up @@ -163,15 +163,15 @@ def __parse_as_object(self, br: BinaryReader, is_player=False):
else:
keyhashes.append(value)

# Append a dict to items if next index appears
if len(items) <= index:
items.append({})
# Create a dict on items if next index appears
if index not in items:
items[index] = {}

# Save
items[index][name] = value

# Filter items by filters
return [item for i, item in enumerate(items) if i not in filters]
return [v for k, v in items.items() if k not in filters]


if __name__ == '__main__':
Expand All @@ -182,6 +182,7 @@ async def main_async():
gs1 = GameSpy1(address='51.81.48.224', query_port=23000, timeout=5.0) # bfield1942
#gs1 = GameSpy1(address='139.162.235.20', query_port=7778, timeout=5.0) # ut
#gs1 = GameSpy1(address='192.223.24.6', query_port=7778, timeout=5.0) # ut
gs1 = GameSpy1(address='141.94.205.35', query_port=12300, timeout=5.0) # mohaa
status = await gs1.get_status()
print(json.dumps(status, indent=None) + '\n')

Expand Down

0 comments on commit 1d8cc6c

Please sign in to comment.