From 9d0de818f8306a401efcd9244c6e06aa5e8189db Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 25 May 2022 20:21:50 -0500 Subject: [PATCH] fixed changing packet ids --- codegen/migrate.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/codegen/migrate.py b/codegen/migrate.py index f15844d9..890186b8 100644 --- a/codegen/migrate.py +++ b/codegen/migrate.py @@ -38,8 +38,8 @@ for packet, packet_name in old_packets.items(): if packet_name not in new_packets.values(): removed_packets.append(packet) print('Removed packet:', packet, packet_name) -# for (direction, state), packets in group_packets(removed_packets).items(): -# lib.code.packet.remove_packet_ids(packets, direction, state) +for (direction, state), packets in group_packets(removed_packets).items(): + lib.code.packet.remove_packet_ids(packets, direction, state) print() @@ -52,8 +52,14 @@ for old_packet, old_packet_name in old_packets.items(): print('Changed packet id:', old_packet, '->', new_packet, f'({new_packet_name})') break -# for (direction, state), packets in group_packets(list(changed_packets.keys())).items(): -# lib.code.packet.remove_packet_ids(packets, direction, state) +for (direction, state), packets in group_packets(list(changed_packets.keys())).items(): + id_map: dict[int, int] = {} + for old_packet_id in packets: + new_packet_id = changed_packets[PacketIdentifier( + old_packet_id, direction, state)] + id_map[old_packet_id] = new_packet_id + + lib.code.packet.change_packet_ids(id_map, direction, state) print() @@ -64,9 +70,9 @@ for packet, packet_name in new_packets.items(): if packet_name not in old_packets.values(): added_packets.append(packet) print('Added packet:', packet, packet_name) -# for packet in added_packets: -# lib.code.packet.generate_packet( -# new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state) +for packet in added_packets: + lib.code.packet.generate_packet( + new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state) lib.code.utils.fmt() print('Done!')