Skip to content

Commit 201bec6

Browse files
committed
Update rlbot_flatbuffers to v0.18
1 parent 3d368e8 commit 201bec6

File tree

10 files changed

+38
-73
lines changed

10 files changed

+38
-73
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ description = "A high performance Python interface for communicating with RLBot
88
dynamic = ["version"]
99
requires-python = ">= 3.11"
1010
dependencies = [
11-
"rlbot_flatbuffers~=0.17.0",
11+
"rlbot_flatbuffers~=0.18.2",
1212
"psutil==7.*",
1313
]
1414
readme = "README.md"
@@ -26,7 +26,7 @@ version = {attr = "rlbot.version.__version__"}
2626

2727
[dependency-groups]
2828
dev = [
29-
"ruff>=0.12.5",
29+
"ruff>=0.13.0",
3030
"toml>=0.10.2",
3131
]
3232

rlbot/interface.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from pathlib import Path
66
from socket import IPPROTO_TCP, TCP_NODELAY, socket
77
from threading import Thread
8-
from typing import Optional
98

109
from rlbot import flat
1110
from rlbot.utils.logging import get_logger
@@ -46,13 +45,13 @@ class SocketRelay:
4645
Callable[[flat.ControllableTeamInfo], None]
4746
] = []
4847
rendering_status_handlers: list[Callable[[flat.RenderingStatus], None]] = []
49-
raw_handlers: list[Callable[[flat.CoreMessage], None]] = []
48+
raw_handlers: list[Callable[[flat.CorePacket], None]] = []
5049

5150
def __init__(
5251
self,
5352
agent_id: str,
5453
connection_timeout: float = 120,
55-
logger: Optional[logging.Logger] = None,
54+
logger: logging.Logger | None = None,
5655
):
5756
self.agent_id = agent_id
5857
self.connection_timeout = connection_timeout
@@ -272,12 +271,12 @@ def handle_incoming_message(self, incoming_message: bytes) -> MsgHandlingResult:
272271
Returns True if the message was NOT a shutdown request
273272
"""
274273

275-
flatbuffer = flat.CorePacket.unpack(incoming_message).message
274+
flatbuffer = flat.CorePacket.unpack(incoming_message)
276275

277276
for raw_handler in self.raw_handlers:
278277
raw_handler(flatbuffer)
279278

280-
match flatbuffer.item:
279+
match flatbuffer.message:
281280
case flat.DisconnectSignal():
282281
return MsgHandlingResult.TERMINATED
283282
case flat.GamePacket() as packet:

rlbot/managers/bot.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
from traceback import print_exc
3-
from typing import Optional
43

54
from rlbot import flat
65
from rlbot.interface import (
@@ -13,8 +12,6 @@
1312
from rlbot.utils import fill_desired_game_state
1413
from rlbot.utils.logging import DEFAULT_LOGGER, get_logger
1514

16-
WARNED_SPAWN_ID_DEPRECATED = False
17-
1815

1916
class Bot:
2017
"""
@@ -32,17 +29,6 @@ class Bot:
3229
name: str = ""
3330
player_id: int = 0
3431

35-
@property
36-
def spawn_id(self) -> int:
37-
global WARNED_SPAWN_ID_DEPRECATED
38-
if not WARNED_SPAWN_ID_DEPRECATED:
39-
WARNED_SPAWN_ID_DEPRECATED = True
40-
self.logger.warning(
41-
"'spawn_id' getter accessed, which is deprecated in favor of 'player_id'."
42-
)
43-
44-
return self.player_id
45-
4632
match_config = flat.MatchConfiguration()
4733
"""
4834
Contains info about what map you're on, game mode, mutators, etc.
@@ -63,10 +49,10 @@ def spawn_id(self) -> int:
6349
_has_field_info = False
6450
_has_player_mapping = False
6551

66-
_latest_packet: Optional[flat.GamePacket] = None
52+
_latest_packet: flat.GamePacket | None = None
6753
_latest_prediction = flat.BallPrediction()
6854

69-
def __init__(self, default_agent_id: Optional[str] = None):
55+
def __init__(self, default_agent_id: str | None = None):
7056
agent_id = os.environ.get("RLBOT_AGENT_ID") or default_agent_id
7157

7258
if agent_id is None:
@@ -107,7 +93,7 @@ def _try_initialize(self):
10793
return
10894

10995
for player in self.match_config.player_configurations:
110-
match player.variety.item:
96+
match player.variety:
11197
case flat.CustomBot(name):
11298
if player.player_id == self.player_id:
11399
self.name = name
@@ -253,7 +239,7 @@ def rendering_status_update(self, update: flat.RenderingStatus):
253239
def update_rendering_status(
254240
self,
255241
status: bool,
256-
index: Optional[int] = None,
242+
index: int | None = None,
257243
is_bot: bool = True,
258244
):
259245
"""
@@ -274,7 +260,7 @@ def handle_match_comm(
274260
index: int,
275261
team: int,
276262
content: bytes,
277-
display: Optional[str],
263+
display: str | None,
278264
team_only: bool,
279265
):
280266
"""
@@ -284,7 +270,7 @@ def handle_match_comm(
284270
"""
285271

286272
def send_match_comm(
287-
self, content: bytes, display: Optional[str] = None, team_only: bool = False
273+
self, content: bytes, display: str | None = None, team_only: bool = False
288274
):
289275
"""
290276
Emits a match communication message to other bots and scripts.
@@ -307,7 +293,7 @@ def set_game_state(
307293
self,
308294
balls: dict[int, flat.DesiredBallState] = {},
309295
cars: dict[int, flat.DesiredCarState] = {},
310-
match_info: Optional[flat.DesiredMatchInfo] = None,
296+
match_info: flat.DesiredMatchInfo | None = None,
311297
commands: list[str] = [],
312298
):
313299
"""
@@ -319,7 +305,7 @@ def set_game_state(
319305
game_state = fill_desired_game_state(balls, cars, match_info, commands)
320306
self._game_interface.send_msg(game_state)
321307

322-
def set_loadout(self, loadout: flat.PlayerLoadout, index: Optional[int] = None):
308+
def set_loadout(self, loadout: flat.PlayerLoadout, index: int | None = None):
323309
"""
324310
Sets the loadout of a bot.
325311
Can be used to select or generate a loadout for the match when called inside `initialize`.

rlbot/managers/hivemind.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
from logging import Logger
33
from traceback import print_exc
4-
from typing import Optional
54

65
from rlbot import flat
76
from rlbot.interface import (
@@ -14,8 +13,6 @@
1413
from rlbot.utils import fill_desired_game_state
1514
from rlbot.utils.logging import DEFAULT_LOGGER, get_logger
1615

17-
WARNED_SPAWN_ID_DEPRECATED = False
18-
1916

2017
class Hivemind:
2118
"""
@@ -34,17 +31,6 @@ class Hivemind:
3431
names: list[str] = []
3532
player_ids: list[int] = []
3633

37-
@property
38-
def spawn_ids(self) -> list[int]:
39-
global WARNED_SPAWN_ID_DEPRECATED
40-
if not WARNED_SPAWN_ID_DEPRECATED:
41-
WARNED_SPAWN_ID_DEPRECATED = True
42-
self._logger.warning(
43-
"'spawn_id' getter accessed, which is deprecated in favor of 'player_id'."
44-
)
45-
46-
return self.player_ids
47-
4834
match_config = flat.MatchConfiguration()
4935
"""
5036
Contains info about what map you're on, game mode, mutators, etc.
@@ -65,10 +51,10 @@ def spawn_ids(self) -> list[int]:
6551
_has_field_info = False
6652
_has_player_mapping = False
6753

68-
_latest_packet: Optional[flat.GamePacket] = None
54+
_latest_packet: flat.GamePacket | None = None
6955
_latest_prediction = flat.BallPrediction()
7056

71-
def __init__(self, default_agent_id: Optional[str] = None):
57+
def __init__(self, default_agent_id: str | None = None):
7258
agent_id = os.environ.get("RLBOT_AGENT_ID") or default_agent_id
7359

7460
if agent_id is None:
@@ -110,7 +96,7 @@ def _try_initialize(self):
11096
# Search match configuration for our spawn ids
11197
for player_id in self.player_ids:
11298
for player in self.match_config.player_configurations:
113-
match player.variety.item:
99+
match player.variety:
114100
case flat.CustomBot(name):
115101
if player.player_id == player_id:
116102
self.names.append(name)
@@ -251,7 +237,7 @@ def rendering_status_update(self, update: flat.RenderingStatus):
251237
def update_rendering_status(
252238
self,
253239
status: bool,
254-
index: Optional[int] = None,
240+
index: int | None = None,
255241
is_bot: bool = True,
256242
):
257243
"""
@@ -283,7 +269,7 @@ def handle_match_comm(
283269
index: int,
284270
team: int,
285271
content: bytes,
286-
display: Optional[str],
272+
display: str | None,
287273
team_only: bool,
288274
):
289275
"""
@@ -296,7 +282,7 @@ def send_match_comm(
296282
self,
297283
index: int,
298284
content: bytes,
299-
display: Optional[str] = None,
285+
display: str | None = None,
300286
team_only: bool = False,
301287
):
302288
"""
@@ -320,7 +306,7 @@ def set_game_state(
320306
self,
321307
balls: dict[int, flat.DesiredBallState] = {},
322308
cars: dict[int, flat.DesiredCarState] = {},
323-
match_info: Optional[flat.DesiredMatchInfo] = None,
309+
match_info: flat.DesiredMatchInfo | None = None,
324310
commands: list[str] = [],
325311
):
326312
"""

rlbot/managers/match.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
22
from time import sleep
3-
from typing import Optional
43

54
import psutil
65

@@ -17,14 +16,14 @@ class MatchManager:
1716
"""
1817

1918
logger = DEFAULT_LOGGER
20-
packet: Optional[flat.GamePacket] = None
21-
rlbot_server_process: Optional[psutil.Process] = None
19+
packet: flat.GamePacket | None = None
20+
rlbot_server_process: psutil.Process | None = None
2221
rlbot_server_port = RLBOT_SERVER_PORT
2322
initialized = False
2423

2524
def __init__(
2625
self,
27-
main_executable_path: Optional[Path] = None,
26+
main_executable_path: Path | None = None,
2827
main_executable_name: str = MAIN_EXECUTABLE_NAME,
2928
):
3029
self.main_executable_path = main_executable_path
@@ -76,7 +75,7 @@ def connect(
7675
wants_ball_predictions: bool,
7776
close_between_matches: bool = True,
7877
rlbot_server_ip: str = RLBOT_SERVER_IP,
79-
rlbot_server_port: Optional[int] = None,
78+
rlbot_server_port: int | None = None,
8079
):
8180
"""
8281
Connects to the RLBot server specifying the given settings.
@@ -109,7 +108,7 @@ def connect_and_run(
109108
wants_ball_predictions: bool,
110109
close_between_matches: bool = True,
111110
rlbot_server_ip: str = RLBOT_SERVER_IP,
112-
rlbot_server_port: Optional[int] = None,
111+
rlbot_server_port: int | None = None,
113112
background_thread: bool = False,
114113
):
115114
"""
@@ -184,7 +183,7 @@ def set_game_state(
184183
self,
185184
balls: dict[int, flat.DesiredBallState] = {},
186185
cars: dict[int, flat.DesiredCarState] = {},
187-
match_info: Optional[flat.DesiredMatchInfo] = None,
186+
match_info: flat.DesiredMatchInfo | None = None,
188187
commands: list[str] = [],
189188
):
190189
"""

rlbot/managers/rendering.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import math
22
from collections.abc import Callable, Sequence
33
from contextlib import contextmanager
4-
from typing import Optional
54

65
from rlbot import flat
76
from rlbot.interface import SocketRelay
@@ -51,7 +50,7 @@ class Renderer:
5150
_logger = get_logger("renderer")
5251

5352
_used_group_ids: set[int] = set()
54-
_group_id: Optional[int] = None
53+
_group_id: int | None = None
5554
_current_renders: list[flat.RenderMessage] = []
5655

5756
_default_color = white

rlbot/managers/script.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22
from traceback import print_exc
3-
from typing import Optional
43

54
from rlbot import flat
65
from rlbot.interface import (
@@ -35,10 +34,10 @@ class Script:
3534
_has_match_settings = False
3635
_has_field_info = False
3736

38-
_latest_packet: Optional[flat.GamePacket] = None
37+
_latest_packet: flat.GamePacket | None = None
3938
_latest_prediction = flat.BallPrediction()
4039

41-
def __init__(self, default_agent_id: Optional[str] = None):
40+
def __init__(self, default_agent_id: str | None = None):
4241
agent_id = os.environ.get("RLBOT_AGENT_ID") or default_agent_id
4342

4443
if agent_id is None:
@@ -200,7 +199,7 @@ def rendering_status_update(self, update: flat.RenderingStatus):
200199
def update_rendering_status(
201200
self,
202201
status: bool,
203-
index: Optional[int] = None,
202+
index: int | None = None,
204203
is_bot: bool = False,
205204
):
206205
"""
@@ -221,7 +220,7 @@ def handle_match_comm(
221220
index: int,
222221
team: int,
223222
content: bytes,
224-
display: Optional[str],
223+
display: str | None,
225224
team_only: bool,
226225
):
227226
"""
@@ -231,7 +230,7 @@ def handle_match_comm(
231230
"""
232231

233232
def send_match_comm(
234-
self, content: bytes, display: Optional[str] = None, team_only: bool = False
233+
self, content: bytes, display: str | None = None, team_only: bool = False
235234
):
236235
"""
237236
Emits a match communication message to other bots and scripts.
@@ -254,7 +253,7 @@ def set_game_state(
254253
self,
255254
balls: dict[int, flat.DesiredBallState] = {},
256255
cars: dict[int, flat.DesiredCarState] = {},
257-
match_info: Optional[flat.DesiredMatchInfo] = None,
256+
match_info: flat.DesiredMatchInfo | None = None,
258257
commands: list[str] = [],
259258
):
260259
"""

rlbot/utils/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
from typing import Optional
2-
31
from rlbot import flat
42

53

64
def fill_desired_game_state(
75
balls: dict[int, flat.DesiredBallState] = {},
86
cars: dict[int, flat.DesiredCarState] = {},
9-
match_info: Optional[flat.DesiredMatchInfo] = None,
7+
match_info: flat.DesiredMatchInfo | None = None,
108
commands: list[str] = [],
119
) -> flat.DesiredGameState:
1210
"""

0 commit comments

Comments
 (0)