Fix bugs with migration

This commit is contained in:
mat 2022-07-06 18:52:24 -05:00
parent f9e42fa3d8
commit 048792f83c
2 changed files with 16 additions and 8 deletions

View file

@ -110,7 +110,8 @@ def set_packets(packet_ids: list[int], packet_class_names: list[str], direction:
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
mod_rs_dir = f'../azalea-protocol/src/packets/{state}/mod.rs'
mod_rs_dir = get_dir_location(
f'../azalea-protocol/src/packets/{state}/mod.rs')
with open(mod_rs_dir, 'r') as f:
mod_rs = f.read().splitlines()
new_mod_rs = []
@ -164,7 +165,8 @@ def set_packets(packet_ids: list[int], packet_class_names: list[str], direction:
def get_packets(direction: str, state: str):
mod_rs_dir = f'../azalea-protocol/src/packets/{state}/mod.rs'
mod_rs_dir = get_dir_location(
f'../azalea-protocol/src/packets/{state}/mod.rs')
with open(mod_rs_dir, 'r') as f:
mod_rs = f.read().splitlines()

View file

@ -81,13 +81,19 @@ print()
# find added/changed packets
added_or_changed_packets: list[PacketIdentifier] = []
for packet, packet_name in new_packets.items():
for new_packet, packet_name in new_packets.items():
old_packet = None
for old_packet_tmp, old_packet_name in old_packets.items():
if old_packet_name == packet_name:
old_packet = old_packet_tmp
break
if packet_name not in old_packets.values():
added_or_changed_packets.append(packet)
print('Added packet:', packet, packet_name)
if not lib.code.packet.are_packet_instructions_identical(new_packets_data[packet].get('instructions'), old_packets_data[packet].get('instructions')):
added_or_changed_packets.append(packet)
print('Changed packet:', packet, packet_name)
added_or_changed_packets.append(new_packet)
print('Added packet:', new_packet, packet_name)
elif old_packet and not lib.code.packet.are_packet_instructions_identical(new_packets_data[new_packet].get('instructions'), old_packets_data[old_packet].get('instructions')):
added_or_changed_packets.append(new_packet)
print('Changed packet:', new_packet, packet_name)
for packet in added_or_changed_packets:
lib.code.packet.generate_packet(
new_burger_data[0]['packets']['packet'], new_mappings, packet.packet_id, packet.direction, packet.state)