async def handle_waypoint(source, signal, **kwargs): player = await Controller.instance.player_manager.get_player(login=source['login']) flow = player.flow if not source['isendlap'] and not source['isendrace']: return dict( player=player, race_time=source['racetime'], flow=flow, raw=source ) elif source['isendlap'] or source['isendrace']: # Check if the time is not zero or bellow, if it is, ignore. See #282. if source['racetime'] <= 0 or source['laptime'] <= 0: raise SignalGlueStop() # End flow and call the other signal. flow.reset_run() if source['isendlap'] and not source['isendrace']: flow.start_run() await finish.send_robust(source=dict( player=player, race_time=source['racetime'], lap_time=source['laptime'], cps=source['curlapcheckpoints'], lap_cps=source['curlapcheckpoints'], race_cps=source['curracecheckpoints'], flow=flow, is_end_race=source['isendrace'], is_end_lap=source['isendlap'], raw=source, ), raw=True) else: logging.warning('Not isendlap!') raise SignalGlueStop()
async def handle_player_chat(source, signal, **kwargs): player_uid, player_login, text, cmd = source if Controller.instance.game.server_player_login == player_login and Controller.instance.game.server_is_dedicated: # Inform our server_chat signal. asyncio.ensure_future(server_chat.send_robust(dict(text=text, cmd=cmd))) raise SignalGlueStop( 'We won\'t inform anything about the chat we send ourself!') try: player = await Controller.instance.player_manager.get_player( login=player_login, lock=True) except: raise SignalGlueStop() return dict(player=player, text=text, cmd=cmd)
async def handle_start_line(source, signal, **kwargs): player = await Controller.instance.player_manager.get_player( login=source['login']) if not player: raise SignalGlueStop() flow = player.flow flow.start_run() return dict(player=player, time=source['time'], flow=flow)
async def handle_player_connect(source, signal, **kwargs): player_login, is_spectator = source player = await Controller.instance.player_manager.handle_connect( login=player_login) if not player: raise SignalGlueStop() return dict( player=player, is_spectator=is_spectator, source=source, signal=signal, )
async def handle_player_disconnect(source, signal, **kwargs): player_login, reason = source player = await Controller.instance.player_manager.handle_disconnect( login=player_login) if not player: raise SignalGlueStop() return dict( player=player, reason=reason, source=source, signal=signal, )
async def handle_start_line(source, signal, **kwargs): player = await Controller.instance.player_manager.get_player( login=source['login']) if not player: raise SignalGlueStop() royal_mode = await Controller.instance.mode_manager.get_current_script( ) == 'Trackmania/TM_RoyalTimeAttack_Online' flow = player.flow flow.start_run() # TM 2020 Royal Mode. if royal_mode: flow.handle_start_line_royal(source['time']) return dict(player=player, time=source['time'], flow=flow)
async def handle_waypoint(source, signal, **kwargs): player = await Controller.instance.player_manager.get_player( login=source['login']) flow = player.flow royal_mode = await Controller.instance.mode_manager.get_current_script( ) == 'Trackmania/TM_RoyalTimeAttack_Online' # Custom waypoint handling for TM 2020 Royal Mode. if royal_mode and source['isendlap'] and source['isendrace']: handled = flow.handle_waypoint_royal(source['racetime'], source['time'], source['blockid']) if handled and not len(flow.royal_block_ids) == 5: source['isendlap'] = source['isendrace'] = False await finish_royal_section.send_robust(source=dict( player=player, section_time=flow.royal_section_time, section_nr=len(flow.royal_block_ids), block_id=source['blockid'], flow=flow), raw=True) elif handled and len(flow.royal_block_ids) == 5: source['racetime'] = source['laptime'] = flow.royal_total_time source['curlapcheckpoints'] = source[ 'curracecheckpoints'] = flow.royal_times if not source['isendlap'] and not source['isendrace']: return dict(player=player, race_time=source['racetime'], flow=flow, raw=source) elif source['isendlap'] or source['isendrace']: # Check if the time is not zero or bellow, if it is, ignore. See #282. if source['racetime'] <= 0 or source['laptime'] <= 0: raise SignalGlueStop() # End flow and call the other signal. flow.reset_run() if source['isendlap'] and not source['isendrace']: flow.start_run() await finish.send_robust(source=dict( player=player, race_time=source['racetime'], lap_time=source['laptime'], cps=source['curlapcheckpoints'], lap_cps=source['curlapcheckpoints'], race_cps=source['curracecheckpoints'], flow=flow, is_end_race=source['isendrace'], is_end_lap=source['isendlap'], raw=source, ), raw=True) # Reset royal when driven 5 finishes. if royal_mode and len(flow.royal_block_ids) == 5: flow.reset_royal(source['time']) else: logging.warning('Not isendlap!') raise SignalGlueStop()