From c7748aa1de31663d44f2cd410473e2e2f2f236c5 Mon Sep 17 00:00:00 2001 From: VirxEC Date: Thu, 16 Jul 2026 19:22:55 -0500 Subject: [PATCH 1/6] Fix MatchManager shutdown after executable_name removal --- rlbot/managers/match.py | 24 ++++++++++++++---------- rlbot/version.py | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/rlbot/managers/match.py b/rlbot/managers/match.py index de05208..b862a88 100644 --- a/rlbot/managers/match.py +++ b/rlbot/managers/match.py @@ -43,6 +43,14 @@ def __enter__(self) -> "MatchManager": def __exit__(self, exc_type, exc_val, exc_tb) -> None: self.disconnect() + @property + def _rlbot_server_name(self) -> str: + return ( + self.rlbot_server_path.stem + if self.rlbot_server_path is not None and self.rlbot_server_path.is_file() + else RLBOT_SERVER_NAME + ) + def ensure_server_started(self): """ Ensures that RLBotServer is running, starting it if it is not. @@ -51,11 +59,7 @@ def ensure_server_started(self): otherwise the global installed RLBotServer will be used, if any. """ - exe_name = ( - self.rlbot_server_path.stem - if self.rlbot_server_path is not None and self.rlbot_server_path.is_file() - else RLBOT_SERVER_NAME - ) + exe_name = self._rlbot_server_name self.rlbot_server_process, self.rlbot_server_port = gateway.find_server_process( exe_name ) @@ -259,7 +263,7 @@ def shut_down(self, use_force_if_necessary: bool = True): # In theory this is all we need for the server to cleanly shut itself down self.rlbot_interface.stop_match(shutdown_server=True) except BrokenPipeError: - match gateway.find_server_process(self.main_executable_name)[0]: + match gateway.find_server_process(self._rlbot_server_name)[0]: case psutil.Process() as proc: self.logger.warning( "Can't communicate with RLBotServer, ensuring shutdown." @@ -281,12 +285,12 @@ def shut_down(self, use_force_if_necessary: bool = True): sleep(1) self.rlbot_server_process, _ = gateway.find_server_process( - self.main_executable_name + self._rlbot_server_name ) if self.rlbot_server_process is not None: self.logger.info( - "Waiting for %s to shut down...", self.main_executable_name + "Waiting for %s to shut down...", self._rlbot_server_name ) if use_force_if_necessary: @@ -295,13 +299,13 @@ def shut_down(self, use_force_if_necessary: bool = True): elif sleeps == 4 or sleeps == 7: self.logger.warning( "%s is not responding to terminate requests.", - self.main_executable_name, + self._rlbot_server_name, ) self.rlbot_server_process.terminate() elif sleeps >= 10 and sleeps % 3 == 1: self.logger.error( "%s is not responding, forcefully killing.", - self.main_executable_name, + self._rlbot_server_name, ) self.rlbot_server_process.kill() diff --git a/rlbot/version.py b/rlbot/version.py index a7dae53..3570b5b 100644 --- a/rlbot/version.py +++ b/rlbot/version.py @@ -1 +1 @@ -__version__ = "2.0.0-beta.52" +__version__ = "2.0.0-beta.53" From 0ed55af9d76c25852f264f8211ab3b7e223c9bb1 Mon Sep 17 00:00:00 2001 From: VirxEC Date: Sun, 2 Aug 2026 19:17:36 -0500 Subject: [PATCH 2/6] Clear packet on stop_match to prevent stale data --- rlbot/managers/match.py | 1 + rlbot/version.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rlbot/managers/match.py b/rlbot/managers/match.py index b862a88..fd10978 100644 --- a/rlbot/managers/match.py +++ b/rlbot/managers/match.py @@ -234,6 +234,7 @@ def disconnect(self): self.rlbot_interface.disconnect() def stop_match(self): + self.packet = None self.rlbot_interface.stop_match() def set_game_state( diff --git a/rlbot/version.py b/rlbot/version.py index 3570b5b..3cd9953 100644 --- a/rlbot/version.py +++ b/rlbot/version.py @@ -1 +1 @@ -__version__ = "2.0.0-beta.53" +__version__ = "2.0.0-beta.54" From cc246eda75e9894022320d842acb8ec4966ea599 Mon Sep 17 00:00:00 2001 From: Virx Date: Mon, 24 Aug 2026 17:32:41 -0400 Subject: [PATCH 3/6] Update flatbuffers to 0.19.0 and remove commands parameter --- pyproject.toml | 37 +++++++++++++++++++------------------ rlbot/utils/__init__.py | 2 -- rlbot/version.py | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2cfdce7..0ffdf1d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,34 +1,35 @@ -[build-system] -requires = ["setuptools >= 61.0"] -build-backend = "setuptools.build_meta" - [project] name = "rlbot" description = "A high performance Python interface for communicating with RLBot v5." -dynamic = ["version"] +readme = "README.md" requires-python = ">= 3.11" +license = "MIT" +authors = [{ name = "RLBot Community", email = "rlbotofficial@gmail.com" }] +keywords = ["rocket-league"] dependencies = [ - "rlbot_flatbuffers~=0.18.2", - "psutil==7.*", + "psutil==7.*", + "rlbot_flatbuffers~=0.19.0", ] -readme = "README.md" -license = {text = "MIT"} -authors = [ - {name = "RLBot Community", email = "rlbotofficial@gmail.com" } -] -keywords = ["rocket-league"] +dynamic = ["version"] [project.urls] Repository = "https://github.com/RLBot/python-interface" -[tool.setuptools.dynamic] -version = {attr = "rlbot.version.__version__"} - [dependency-groups] dev = [ - "ruff>=0.13.0", - "toml>=0.10.2", + "ruff>=0.16.0", + "toml>=0.10.2", ] +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" + +[tool.basedpyright] +typeCheckingMode = "standard" + [tool.ruff.format] docstring-code-format = true + +[tool.setuptools.dynamic] +version = { attr = "rlbot.version.__version__" } diff --git a/rlbot/utils/__init__.py b/rlbot/utils/__init__.py index 86e683e..21aaf55 100644 --- a/rlbot/utils/__init__.py +++ b/rlbot/utils/__init__.py @@ -5,7 +5,6 @@ def fill_desired_game_state( balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ) -> flat.DesiredGameState: """ Converts the dictionaries to a DesiredGameState by @@ -14,7 +13,6 @@ def fill_desired_game_state( game_state = flat.DesiredGameState( match_info=match_info, - console_commands=[flat.ConsoleCommand(cmd) for cmd in commands], ) if balls: diff --git a/rlbot/version.py b/rlbot/version.py index 3cd9953..b6da448 100644 --- a/rlbot/version.py +++ b/rlbot/version.py @@ -1 +1 @@ -__version__ = "2.0.0-beta.54" +__version__ = "2.0.0-beta.55" From f00e9fcee5cee6d3f665c89c6c56b605b2200092 Mon Sep 17 00:00:00 2001 From: Geneustace Wicaksono <83039642+SentientPlatypus@users.noreply.github.com> Date: Fri, 2 Oct 2026 14:11:00 -0400 Subject: [PATCH 4/6] Fix stream desync when a non-blocking read hits a partial message handle_incoming_messages(blocking=False) treated a BlockingIOError raised part-way through read_message() as "no messages", discarding the header and payload bytes already consumed. The next read then parsed bytes from the middle of a message as a length header, which surfaces as "Error while unpacking message (0 bytes) ... Invalid offset" and terminates the bot/hivemind/script. Only the first recv of a message is now non-blocking; once any byte has been consumed the rest of the message is read blocking. --- rlbot/interface.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/rlbot/interface.py b/rlbot/interface.py index a4d0d3d..42fcc04 100644 --- a/rlbot/interface.py +++ b/rlbot/interface.py @@ -70,9 +70,6 @@ def __del__(self): def _int_to_bytes(val: int) -> bytes: return val.to_bytes(2, byteorder="big") - def _read_int(self) -> int: - return int.from_bytes(self._read_exact(2), "big") - def _read_exact(self, n: int) -> bytes: assert self.socket is not None, "Socket has not been established" @@ -88,7 +85,19 @@ def _read_exact(self, n: int) -> bytes: return bytes(buff) def read_message(self) -> bytes: - size = self._read_int() + assert self.socket is not None, "Socket has not been established" + + # Only this first recv may raise BlockingIOError when the socket is non-blocking. + # Once any byte of a message has been consumed, the rest must be read blocking, + # otherwise the consumed bytes are lost and the stream loses its framing. + header = self.socket.recv(2) + if len(header) == 0: + raise EOFError + self.socket.setblocking(True) + + if len(header) == 1: + header += self._read_exact(1) + size = int.from_bytes(header, "big") return self._read_exact(size) def send_bytes(self, data: bytes): From f25807c472a0f5582b7a8f550cb4fa71cd26dc39 Mon Sep 17 00:00:00 2001 From: Geneustace Wicaksono <83039642+SentientPlatypus@users.noreply.github.com> Date: Fri, 2 Oct 2026 15:24:55 -0400 Subject: [PATCH 5/6] Bump version to beta56 --- rlbot/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rlbot/version.py b/rlbot/version.py index b6da448..fa3337d 100644 --- a/rlbot/version.py +++ b/rlbot/version.py @@ -1 +1 @@ -__version__ = "2.0.0-beta.55" +__version__ = "2.0.0-beta.56" From 99c1e1d6dc4d4d649beda1c78a4bb32a0d65d22a Mon Sep 17 00:00:00 2001 From: NicEastvillage Date: Mon, 16 Nov 2026 22:12:48 +0100 Subject: [PATCH 6/6] Update set_game_state() API and add send_console_command() --- rlbot/interface.py | 1 + rlbot/managers/bot.py | 14 ++++++++++---- rlbot/managers/hivemind.py | 14 ++++++++++---- rlbot/managers/match.py | 14 ++++++++++---- rlbot/managers/script.py | 14 ++++++++++---- rlbot/version.py | 2 +- tests/atba/atba.py | 2 +- tests/many_match.py | 2 +- tests/run_forever.py | 2 +- 9 files changed, 45 insertions(+), 20 deletions(-) diff --git a/rlbot/interface.py b/rlbot/interface.py index 42fcc04..0ed4a9b 100644 --- a/rlbot/interface.py +++ b/rlbot/interface.py @@ -120,6 +120,7 @@ def send_msg( | flat.MatchConfiguration | flat.PlayerInput | flat.DesiredGameState + | flat.ConsoleCommand | flat.RenderGroup | flat.RemoveRenderGroup | flat.MatchComm diff --git a/rlbot/managers/bot.py b/rlbot/managers/bot.py index 935eb04..13d9f5f 100644 --- a/rlbot/managers/bot.py +++ b/rlbot/managers/bot.py @@ -274,20 +274,26 @@ def send_match_comm( ) ) - def set_game_state( + def send_console_command(self, cmd: str | flat.ConsoleCommand): + cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd) + self._game_interface.send_msg(cmd) + + def set_game_state(self, game_state: flat.DesiredGameState): + self._game_interface.send_msg(game_state) + + def set_game_state_parts( self, balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ): """ Sets the game to the desired state. Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more. - See wiki for a full break down and examples. + See wiki for a full breakdown and examples. """ - game_state = fill_desired_game_state(balls, cars, match_info, commands) + game_state = fill_desired_game_state(balls, cars, match_info) self._game_interface.send_msg(game_state) def set_loadout(self, loadout: flat.PlayerLoadout, index: int | None = None): diff --git a/rlbot/managers/hivemind.py b/rlbot/managers/hivemind.py index 53ca25c..6b11b63 100644 --- a/rlbot/managers/hivemind.py +++ b/rlbot/managers/hivemind.py @@ -290,20 +290,26 @@ def send_match_comm( ) ) - def set_game_state( + def send_console_command(self, cmd: str | flat.ConsoleCommand): + cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd) + self._game_interface.send_msg(cmd) + + def set_game_state(self, game_state: flat.DesiredGameState): + self._game_interface.send_msg(game_state) + + def set_game_state_parts( self, balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ): """ Sets the game to the desired state. Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more. - See wiki for a full break down and examples. + See wiki for a full breakdown and examples. """ - game_state = fill_desired_game_state(balls, cars, match_info, commands) + game_state = fill_desired_game_state(balls, cars, match_info) self._game_interface.send_msg(game_state) def set_loadout(self, loadout: flat.PlayerLoadout, index: int): diff --git a/rlbot/managers/match.py b/rlbot/managers/match.py index fd10978..0fa0a68 100644 --- a/rlbot/managers/match.py +++ b/rlbot/managers/match.py @@ -237,20 +237,26 @@ def stop_match(self): self.packet = None self.rlbot_interface.stop_match() - def set_game_state( + def send_console_command(self, cmd: str | flat.ConsoleCommand): + cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd) + self.rlbot_interface.send_msg(cmd) + + def set_game_state(self, game_state: flat.DesiredGameState): + self.rlbot_interface.send_msg(game_state) + + def set_game_state_parts( self, balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ): """ Sets the game to the desired state. Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more. - See wiki for a full break down and examples. + See wiki for a full breakdown and examples. """ - game_state = fill_desired_game_state(balls, cars, match_info, commands) + game_state = fill_desired_game_state(balls, cars, match_info) self.rlbot_interface.send_msg(game_state) def shut_down(self, use_force_if_necessary: bool = True): diff --git a/rlbot/managers/script.py b/rlbot/managers/script.py index afb9944..ae4c925 100644 --- a/rlbot/managers/script.py +++ b/rlbot/managers/script.py @@ -234,20 +234,26 @@ def send_match_comm( ) ) - def set_game_state( + def send_console_command(self, cmd: str | flat.ConsoleCommand): + cmd = cmd if isinstance(cmd, flat.ConsoleCommand) else flat.ConsoleCommand(cmd) + self._game_interface.send_msg(cmd) + + def set_game_state(self, game_state: flat.DesiredGameState): + self._game_interface.send_msg(game_state) + + def set_game_state_parts( self, balls: dict[int, flat.DesiredBallState] = {}, cars: dict[int, flat.DesiredCarState] = {}, match_info: flat.DesiredMatchInfo | None = None, - commands: list[str] = [], ): """ Sets the game to the desired state. Through this it is possible to manipulate the position, velocity, and rotations of cars and balls, and more. - See wiki for a full break down and examples. + See wiki for a full breakdown and examples. """ - game_state = fill_desired_game_state(balls, cars, match_info, commands) + game_state = fill_desired_game_state(balls, cars, match_info) self._game_interface.send_msg(game_state) def set_loadout(self, loadout: flat.PlayerLoadout, index: int): diff --git a/rlbot/version.py b/rlbot/version.py index fa3337d..6e93f11 100644 --- a/rlbot/version.py +++ b/rlbot/version.py @@ -1 +1 @@ -__version__ = "2.0.0-beta.56" +__version__ = "2.0.0-beta.57" diff --git a/tests/atba/atba.py b/tests/atba/atba.py index 4d5cc3c..6d94374 100644 --- a/tests/atba/atba.py +++ b/tests/atba/atba.py @@ -122,7 +122,7 @@ def get_output(self, packet: flat.GamePacket) -> flat.ControllerState: def test_state_setting(self, packet: flat.GamePacket): if packet.match_info.seconds_elapsed > self.next_teleport: self.next_teleport = packet.match_info.seconds_elapsed + 10 - self.set_game_state( + self.set_game_state_parts( { 0: flat.DesiredBallState( flat.DesiredPhysics( diff --git a/tests/many_match.py b/tests/many_match.py index 4942ada..a641549 100644 --- a/tests/many_match.py +++ b/tests/many_match.py @@ -80,7 +80,7 @@ def handle_match_comm(comm: flat.MatchComm): match_manager.packet.match_info.match_phase == flat.MatchPhase.Active and match_manager.packet.match_info.game_time_remaining < 60 * 4 + 55 ): - match_manager.set_game_state(commands=["Pause"]) + match_manager.send_console_command("Pause") paused = True break sleep(1) diff --git a/tests/run_forever.py b/tests/run_forever.py index 8efe3b1..f785c16 100644 --- a/tests/run_forever.py +++ b/tests/run_forever.py @@ -56,7 +56,7 @@ while match_manager.packet.match_info.match_phase != flat.MatchPhase.Ended: if match_manager.packet.match_info.match_phase == flat.MatchPhase.Countdown: - match_manager.set_game_state( + match_manager.set_game_state_parts( match_info=flat.DesiredMatchInfo(game_speed=2) )