Skip to content

Commit

Permalink
Make sure PyPlanet can function without ladder information from the d…
Browse files Browse the repository at this point in the history
…edicated server. (#1159)
  • Loading branch information
tomvlk committed Mar 30, 2022
1 parent 6836333 commit 2f1d962
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ docs/_build/
# virtualenv
env/
env*/
venv/

### Editors / IDE
# IntelliJ project files
Expand Down
2 changes: 1 addition & 1 deletion pyplanet/apps/contrib/info/templates/serverinfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<quad pos="0 -6.5" z-index="0" size="35 6" bgcolor="00000060"/>
<quad pos="0 -6.5" z-index="0" size="6.5 6" bgcolor="00000060"/>
<label pos="3.25 -9.5" z-index="1" size="6.5 6" text="&#xf145;" textsize="1.8" halign="center" valign="center2"/>
<label pos="21.5 -9.5" z-index="1" size="28 6" text="{{ ladder_min }} - {{ ladder_max }}k" textsize="1.6" valign="center2" halign="center" textfont="RajdhaniMono" textemboss="1"/>
<label pos="21.5 -9.5" z-index="1" size="28 6" text="{% if ladder_min != None and ladder_max != None %}{{ ladder_min }} - {{ ladder_max }}k{% else %}-{% endif %}" textsize="1.6" valign="center2" halign="center" textfont="RajdhaniMono" textemboss="1"/>

<quad pos="0 -13" z-index="0" size="35 6" bgcolor="00000060"/>
<quad pos="0 -13" z-index="0" size="6.5 6" bgcolor="00000060"/>
Expand Down
17 changes: 10 additions & 7 deletions pyplanet/apps/contrib/info/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,16 @@ def __init__(self, app):
async def get_context_data(self):
context = await super().get_context_data()

ladder_min = int(self.app.instance.game.ladder_min)
ladder_max = int(self.app.instance.game.ladder_max)

if ladder_min > 1000:
ladder_min = int(ladder_min / 1000)
if ladder_max > 1000:
ladder_max = int(ladder_max / 1000)
ladder_min = None
if self.app.instance.game.ladder_min:
ladder_min = int(self.app.instance.game.ladder_min)
if ladder_min > 1000:
ladder_min = int(ladder_min / 1000)
ladder_max = None
if self.app.instance.game.ladder_max:
ladder_max = int(self.app.instance.game.ladder_max)
if ladder_max > 1000:
ladder_max = int(ladder_max / 1000)

context.update({
'version': version,
Expand Down
5 changes: 3 additions & 2 deletions pyplanet/core/gbx/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,9 @@ async def refresh_info(self):
self.game.server_next_max_specs = res[9]['NextValue']
self.game.server_is_private = res[10]

self.game.ladder_min = res[11]['LadderServerLimitMin']
self.game.ladder_max = res[11]['LadderServerLimitMax']
if not isinstance(res[11], bool):
self.game.ladder_min = res[11]['LadderServerLimitMin']
self.game.ladder_max = res[11]['LadderServerLimitMax']

# Detailed server player infos.
server_player_info = await self('GetDetailedPlayerInfo', self.game.server_player_login)
Expand Down

0 comments on commit 2f1d962

Please sign in to comment.