Skip to content

Commit 4847f12

Browse files
committed
Update to latest flatbuffers spec
1 parent f2b8437 commit 4847f12

File tree

5 files changed

+33
-51
lines changed

5 files changed

+33
-51
lines changed

codegen/main.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub enum PythonBindType {
2525

2626
impl PythonBindType {
2727
pub const BASE_TYPES: [&'static str; 6] = ["bool", "i32", "u32", "f32", "String", "u8"];
28-
pub const FROZEN_TYPES: [&'static str; 24] = [
28+
pub const FROZEN_TYPES: [&'static str; 18] = [
2929
"FieldInfo",
3030
"BoostPad",
3131
"GoalInfo",
@@ -44,28 +44,9 @@ impl PythonBindType {
4444
"BallPrediction",
4545
"PredictionSlice",
4646
"Physics",
47-
"MessagePacket",
48-
"GameMessageWrapper",
49-
"GameMessage",
50-
"PlayerInputChange",
51-
"PlayerSpectate",
52-
"PlayerStatEvent",
53-
];
54-
pub const FROZEN_NEEDS_PY: [&'static str; 6] = [
55-
"GameTickPacket",
56-
"BallInfo",
57-
"CollisionShape",
58-
"MessagePacket",
59-
"GameMessageWrapper",
60-
"GameMessage",
61-
];
62-
pub const UNIONS: [&'static str; 5] = [
63-
"PlayerClass",
64-
"GameMessage",
65-
"CollisionShape",
66-
"RelativeAnchor",
67-
"RenderType",
6847
];
48+
pub const FROZEN_NEEDS_PY: [&'static str; 3] = ["GameTickPacket", "BallInfo", "CollisionShape"];
49+
pub const UNIONS: [&'static str; 4] = ["PlayerClass", "CollisionShape", "RelativeAnchor", "RenderType"];
6950

7051
fn new(path: &Path) -> Option<Self> {
7152
// get the filename without the extension
@@ -82,7 +63,6 @@ impl PythonBindType {
8263
struct_name.push_str(&c[1..]);
8364
}
8465
struct_name = struct_name
85-
.replace("Ranchor", "RAnchor")
8666
.replace("Rlbot", "RLBot")
8767
.replace("Halign", "HAlign")
8868
.replace("Valign", "VAlign");
@@ -165,7 +145,6 @@ fn mod_rs_generator(type_data: &[PythonBindType]) -> io::Result<()> {
165145

166146
fn run_flatc() -> io::Result<()> {
167147
println!("cargo:rerun-if-changed=flatbuffers-schema/comms.fbs");
168-
println!("cargo:rerun-if-changed=flatbuffers-schema/event.fbs");
169148
println!("cargo:rerun-if-changed=flatbuffers-schema/gamestate.fbs");
170149
println!("cargo:rerun-if-changed=flatbuffers-schema/matchstart.fbs");
171150
println!("cargo:rerun-if-changed=flatbuffers-schema/rendering.fbs");

pybench.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ def test_gtp():
77
times = []
88

99
gtp = flat.GameTickPacket(
10-
ball=flat.BallInfo(
11-
shape=flat.SphereShape(),
12-
),
10+
balls=[flat.BallInfo(shape=flat.SphereShape()) for _ in range(32)],
1311
players=[flat.PlayerInfo() for _ in range(128)],
1412
boost_pad_states=[flat.BoostPadState() for _ in range(128)],
1513
teams=[flat.TeamInfo() for _ in range(2)],
@@ -32,13 +30,13 @@ def test_gtp():
3230
def test_ballpred():
3331
times = []
3432

35-
ballPred = flat.BallPrediction([flat.PredictionSlice() for _ in range(720)])
33+
ballPred = flat.BallPrediction([flat.PredictionSlice(1) for _ in range(960)])
3634

3735
for _ in range(10_000):
3836
start = time_ns()
3937

40-
ballpred_bytes = ballPred.pack()
41-
flat.BallPrediction.unpack(ballpred_bytes)
38+
packed = ballPred.pack()
39+
flat.BallPrediction.unpack(packed)
4240

4341
times.append(time_ns() - start)
4442

pytest.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,11 @@ def random_script_config():
3939
vec2 = Vector3(4, 5, 6)
4040
print(vec1 + vec2)
4141

42-
ready_message = ReadyMessage(True, wants_game_messages=True)
42+
player_info = PlayerInfo(accolades=["MVP", "Hat Trick"])
43+
eval(repr(player_info))
44+
45+
ready_message = ReadyMessage(True, close_after_match=True)
4346
print(hash(ready_message))
44-
print(repr(ready_message))
4547
print(ready_message)
4648
eval(repr(ready_message))
4749
print()
@@ -63,10 +65,9 @@ def random_script_config():
6365
assert False
6466

6567
dgs.console_commands = [ConsoleCommand("dump_items")]
66-
dgs.ball_state = DesiredBallState()
68+
dgs.ball_states = [DesiredBallState()]
6769

6870
print(hash(dgs))
69-
print(repr(dgs))
7071
print(dgs)
7172
eval(repr(dgs))
7273
print()
@@ -86,14 +87,12 @@ def random_script_config():
8687
raise ValueError("Expected Line3D")
8788

8889
print(hash(render_type))
89-
print(repr(render_type))
9090
print(render_type)
9191
eval(repr(render_type))
9292
print()
9393

9494
comm = MatchComm(3, 1, False, "Ready!", b"Hello, world!")
9595
print(hash(comm))
96-
print(repr(comm))
9796
print(comm)
9897
eval(repr(comm))
9998
print(comm.content.decode("utf-8"))
@@ -151,6 +150,14 @@ def random_script_config():
151150

152151
print()
153152

153+
ballPred = BallPrediction([
154+
PredictionSlice(1) for _ in range(5 * 120)
155+
])
156+
data = ballPred.pack()
157+
print(f"BallPrediction size: {len(data)} bytes")
158+
159+
print()
160+
154161
print("Running quick benchmark...")
155162

156163
num_trials = 60_000
@@ -161,15 +168,18 @@ def random_script_config():
161168
for _ in range(num_trials):
162169
start = time_ns()
163170
desired_game_state = DesiredGameState(
164-
DesiredBallState(
165-
DesiredPhysics(
166-
Vector3Partial(0, 0, 0),
167-
RotatorPartial(0, 0, 0),
168-
Vector3Partial(0, 0, 0),
169-
Vector3Partial(0, 0, 0),
171+
[
172+
DesiredBallState(
173+
DesiredPhysics(
174+
Vector3Partial(0, 0, 0),
175+
RotatorPartial(0, 0, 0),
176+
Vector3Partial(0, 0, 0),
177+
Vector3Partial(0, 0, 0),
178+
)
170179
)
171-
),
172-
car_states=[
180+
for _ in range(16)
181+
],
182+
[
173183
DesiredCarState(
174184
DesiredPhysics(
175185
Vector3Partial(0, 0, 0),

src/lib.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ pynamedmodule! {
196196
FieldInfo,
197197
Float,
198198
GameInfo,
199-
GameMessage,
200-
GameMessageWrapper,
201199
GameMode,
202200
GameSpeedOption,
203201
GameStateType,
@@ -212,7 +210,7 @@ pynamedmodule! {
212210
MatchLength,
213211
MatchSettings,
214212
MaxScore,
215-
MessagePacket,
213+
MultiBall,
216214
MutatorSettings,
217215
OvertimeOption,
218216
PartyMember,
@@ -221,10 +219,7 @@ pynamedmodule! {
221219
PlayerConfiguration,
222220
PlayerInfo,
223221
PlayerInput,
224-
PlayerInputChange,
225222
PlayerLoadout,
226-
PlayerSpectate,
227-
PlayerStatEvent,
228223
PolyLine3D,
229224
PredictionSlice,
230225
Psyonix,

0 commit comments

Comments
 (0)