diff options
| author | mat <github@matdoes.dev> | 2022-10-24 21:25:36 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-10-24 21:25:36 -0500 |
| commit | 489cdb01aa94870301ea0f56e47a01a839b91b56 (patch) | |
| tree | 16b8f7544bb6235271833d02752dcb862910a4e8 /codegen/lib/code/packet.py | |
| parent | f38d0660d16364cc4d6a720889acee68441b28fd (diff) | |
| download | azalea-drasl-489cdb01aa94870301ea0f56e47a01a839b91b56.tar.xz | |
fix repeated ids in game/mod.rs
Diffstat (limited to 'codegen/lib/code/packet.py')
| -rw-r--r-- | codegen/lib/code/packet.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/codegen/lib/code/packet.py b/codegen/lib/code/packet.py index 1d95ef71..a7751c23 100644 --- a/codegen/lib/code/packet.py +++ b/codegen/lib/code/packet.py @@ -121,6 +121,9 @@ def generate_packet(burger_packets, mappings: Mappings, target_packet_id, target def set_packets(packet_ids: list[int], packet_class_names: list[str], direction: str, state: str): assert len(packet_ids) == len(packet_class_names) + # ids are repeated + assert len(packet_ids) == len(set(packet_ids)) + # sort the packets by id packet_ids, packet_class_names = [list(x) for x in zip( *sorted(zip(packet_ids, packet_class_names), key=lambda pair: pair[0]))] # type: ignore @@ -376,6 +379,8 @@ def change_packet_ids(id_map: dict[int, int], direction: str, state: str): for packet_id in existing_packet_ids: new_packet_id = id_map.get(packet_id, packet_id) + if new_packet_id in new_packet_ids: + raise Exception('Two packets have the same id') new_packet_ids.append(new_packet_id) set_packets(new_packet_ids, existing_packet_class_names, direction, state) |
