mirror of
https://github.com/mat-1/azalea.git
synced 2025-08-02 14:26:04 +00:00
Correctly detect updated packets
This commit is contained in:
parent
e44afb76f4
commit
8755f18c2b
3 changed files with 29 additions and 4 deletions
|
@ -245,3 +245,28 @@ def remove_packet_ids(removing_packet_ids: list[int], direction: str, state: str
|
|||
new_packet_class_names.append(packet_class_name)
|
||||
|
||||
set_packets(new_packet_ids, new_packet_class_names, direction, state)
|
||||
|
||||
|
||||
def are_packet_instructions_identical(old_packet, new_packet):
|
||||
old_packet = old_packet or []
|
||||
new_packet = new_packet or []
|
||||
|
||||
if len(old_packet) != len(new_packet):
|
||||
return False
|
||||
|
||||
for old_field, new_field in zip(old_packet, new_packet):
|
||||
if old_field['operation'] != new_field['operation']:
|
||||
return False
|
||||
if new_field['operation'] == 'write':
|
||||
if burger_type_to_rust_type(old_field.get('type')) != burger_type_to_rust_type(new_field.get('type')):
|
||||
return False
|
||||
else:
|
||||
# comparing is too complicated here since it's possible the type has variables
|
||||
# so we just don't
|
||||
pass
|
||||
|
||||
if 'instructions' in old_field and 'instructions' in new_field:
|
||||
if not are_packet_instructions_identical(old_field['instructions'], new_field['instructions']):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
|
@ -62,8 +62,7 @@ def burger_type_to_rust_type(burger_type):
|
|||
burger_type[:-2])
|
||||
field_type_rs = f'Vec<{field_type_rs}>'
|
||||
else:
|
||||
print('Unknown field type:', burger_type)
|
||||
exit()
|
||||
raise Exception(f'Unknown field type: {burger_type}')
|
||||
return field_type_rs, is_var, uses
|
||||
|
||||
|
||||
|
|
|
@ -85,8 +85,9 @@ for packet, packet_name in new_packets.items():
|
|||
if packet_name not in old_packets.values():
|
||||
added_or_changed_packets.append(packet)
|
||||
print('Added packet:', packet, packet_name)
|
||||
if new_packets_data[packet].get('instructions') != old_packets_data[packet].get('instructions'):
|
||||
print('hmm')
|
||||
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)
|
||||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue