Skip to content

Commit 002f1f3

Browse files
committed
Optimize ball prediction deserialization via unpack_with
1 parent 12c587b commit 002f1f3

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

rlbot/interface.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class SocketRelay:
6666
is_connected = False
6767
_running = False
6868
"""Indicates whether a messages are being handled by the `run` loop (potentially in a background thread)"""
69+
_ball_pred = flat.BallPrediction()
6970

7071
on_connect_handlers: list[Callable[[], None]] = []
7172
packet_handlers: list[Callable[[flat.GamePacket], None]] = []
@@ -341,7 +342,7 @@ def handle_incoming_message(
341342
handler(match_comm)
342343
case SocketDataType.BALL_PREDICTION:
343344
if len(self.ball_prediction_handlers) > 0:
344-
ball_prediction = flat.BallPrediction.unpack(incoming_message.data)
345+
ball_prediction = self._ball_pred.unpack_with(incoming_message.data)
345346
for handler in self.ball_prediction_handlers:
346347
handler(ball_prediction)
347348
case SocketDataType.CONTROLLABLE_TEAM_INFO:

rlbot/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.0.0-beta.27"
1+
__version__ = "2.0.0-beta.28"

tests/necto/bot.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -220,5 +220,6 @@ def update_controls(self, action: np.ndarray):
220220

221221

222222
if __name__ == "__main__":
223-
Necto("rlgym/necto").run(wants_match_communications=False, wants_ball_predictions=False)
224-
# Necto("rlgym/necto").run(wants_match_communications=False)
223+
Necto("rlgym/necto").run(
224+
wants_match_communications=False, wants_ball_predictions=False
225+
)

0 commit comments

Comments
 (0)