def is_rocket_league_running(self, port) -> bool: """ Returns whether Rocket League is running with the right port. """ try: is_rocket_league_running, proc = process_configuration.is_process_running( ROCKET_LEAGUE_PROCESS_INFO.PROGRAM, ROCKET_LEAGUE_PROCESS_INFO.PROGRAM_NAME, ROCKET_LEAGUE_PROCESS_INFO.REQUIRED_ARGS) if proc is not None: # Check for correct port. rocket_league_port = self._read_port_from_rocket_league_args( proc.cmdline()) if rocket_league_port is not None and rocket_league_port != port: raise Exception( f"Rocket League is already running with port {rocket_league_port} but we wanted " f"{port}! Please close Rocket League and let us start it for you instead!" ) except WrongProcessArgs: raise Exception( f"Rocket League is not running with {ROCKET_LEAGUE_PROCESS_INFO.REQUIRED_ARGS}!\n" "Please close Rocket League and let us start it for you instead!" ) return is_rocket_league_running
def connect_to_game(self): """ Ensures the game is running and connects to it by initializing self.game_interface. """ version.print_current_release_notes() self.ensure_rlbot_gateway_started() if self.has_started: return try: is_rocket_league_running = process_configuration.is_process_running( ROCKET_LEAGUE_PROCESS_INFO.PROGRAM, ROCKET_LEAGUE_PROCESS_INFO.PROGRAM_NAME, ROCKET_LEAGUE_PROCESS_INFO.REQUIRED_ARGS) except WrongProcessArgs: raise Exception( f"Rocket League is not running with {ROCKET_LEAGUE_PROCESS_INFO.REQUIRED_ARGS}! " f"Please close Rocket League and let us start it for you instead!" ) if not is_rocket_league_running: self.launch_rocket_league() try: self.game_interface.load_interface() except Exception as e: self.logger.error("Terminating rlbot gateway and raising:") self.rlbot_gateway_process.terminate() raise e self.agent_metadata_queue = mp.Queue() self.has_started = True
def launch_with_epic_login_trick(ideal_args: List[str]) -> bool: try: logger = get_logger(DEFAULT_LOGGER) # launch using shortcut technique webbrowser.open( 'com.epicgames.launcher://apps/Sugar?action=launch&silent=true') process = None for i in range(10): sleep(1) rl_running, process = is_process_running('RocketLeague.exe', 'RocketLeague.exe', set()) if rl_running: break if process is None: return False # get the args from the process all_args = process.cmdline() process.kill() all_args[1:1] = ideal_args logger.info(f"Killed old rocket league, reopening with {all_args}") subprocess.Popen(all_args, shell=True) return True except: return False
def startup(self): if self.has_started: return version.print_current_release_notes() if not process_configuration.is_process_running( ROCKET_LEAGUE_PROCESS_INFO['program'], ROCKET_LEAGUE_PROCESS_INFO['program_name']): try: webbrowser.open('steam://rungameid/{}'.format( ROCKET_LEAGUE_PROCESS_INFO['gameid'])) except webbrowser.Error: self.logger.info( "Unable to launch Rocket League automatically. Please launch Rocket League manually to continue." ) self.game_interface.inject_dll() self.game_interface.load_interface() self.agent_metadata_queue = mp.Queue() self.has_started = True