aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-07-06 18:52:24 -0500
committermat <github@matdoes.dev>2022-07-06 18:52:24 -0500
commit048792f83cae75d98f77eb7a699652e5a6f8f2f9 (patch)
tree742b083e8340f5fcc6001d34c4b903f34c03d274
parentf9e42fa3d8ae96936fe8f38777128c983f3deea4 (diff)
downloadazalea-drasl-048792f83cae75d98f77eb7a699652e5a6f8f2f9.tar.xz
Fix bugs with migration
-rw-r--r--codegen/lib/code/packet.py6
-rw-r--r--codegen/migrate.py18
2 files changed, 16 insertions, 8 deletions
diff --git a/codegen/lib/code/packet.py b/codegen/lib/code/packet.py
index 186f59e6..59632270 100644
--- a/codegen/lib/code/packet.py
+++ b/codegen/lib/code/packet.py
@@ -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()
diff --git a/codegen/migrate.py b/codegen/migrate.py
index fad546e9..2dacc208 100644
--- a/codegen/migrate.py
+++ b/codegen/migrate.py
@@ -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)