diff options
-rw-r--r-- | south_browser/rpc.py | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/south_browser/rpc.py b/south_browser/rpc.py index fe76829..db87d35 100644 --- a/south_browser/rpc.py +++ b/south_browser/rpc.py @@ -49,21 +49,19 @@ def NSGetServerCount(repeat: bool = True): def NSGetGameServers(): # work around Squirrel closure bullshit server_count = NSGetServerCount() + if not server_count: + return [] - for i in range(server_count): + primret = [] + for c in range(server_count): + primret.append(f"[s[{c}].index, s[{c}].id, s[{c}].name, s[{c}].description, s[{c}].map, s[{c}].playlist, s[{c}].playerCount, s[{c}].maxPlayerCount, s[{c}].requiresPassword, s[{c}].region]") - primret = [] + ret = "[" + ",".join(primret) + "]" - for c in range(server_count): - primret.append(f"[s[{c}].index, s[{c}].id, s[{c}].name, s[{c}].description, s[{c}].map, s[{c}].playlist, s[{c}].playerCount, s[{c}].maxPlayerCount, s[{c}].requiresPassword, s[{c}].region]") - - ret = "[" + ",".join(primret) + "]" - - return cmd("execute_squirrel", { - "code": f"array<ServerInfo> s = NSGetGameServers()\nreturn {ret}" - })["result"] + return cmd("execute_squirrel", { + "code": f"array<ServerInfo> s = NSGetGameServers()\nreturn {ret}" + })["result"] - return [] def NSTryAuthWithServer(index: int, password: str = None): if password is None: |