Skip to content

Commit

Permalink
Merge pull request #317 from PyPlanet/bugfix/276
Browse files Browse the repository at this point in the history
[BUGFIX] Prevent double messages from dedimania after switching modes.
  • Loading branch information
tomvlk committed May 30, 2017
2 parents ad67857 + 587b4b3 commit 321dc0b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pyplanet/apps/contrib/dedimania/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def __init__(self, *args, **kwargs):
self.ghost_replay = None

self.server_max_rank = None
self.map_status = False
self.map_status = None
self.map_uid = None
self.ready = False

self.setting_server_login = Setting(
Expand Down Expand Up @@ -187,6 +188,9 @@ async def map_start(self, map, restarted, **kwargs):
# TODO: Activate after fix in dedicated:
# await self.podium_start()

# Clear the current map.
self.map_uid = None

await self.map_end(map)
await self.map_begin(map)

Expand All @@ -200,6 +204,12 @@ async def map_begin(self, map, **kwargs):

self.api.retries = 0

# If the map uid already has been filled and the same we are starting double. Return immediately.
# This is because of issue #276.
if self.map_uid == self.instance.map_manager.current_map.uid:
return
self.map_uid = self.instance.map_manager.current_map.uid

# Set map status.
self.map_status = map.time_author > 6200 and map.num_checkpoints > 1
if not self.map_status:
Expand Down Expand Up @@ -260,6 +270,9 @@ async def map_end(self, map):
logger.warning('Don\'t send dedi records, map not supported or we are offline!')
return

# Clear the current map status.
self.map_status = None

if not self.v_replay:
return

Expand Down

0 comments on commit 321dc0b

Please sign in to comment.