diff --git a/src/protocol/generate_protocol.py b/src/protocol/generate_protocol.py index a913fff..9f189d8 100644 --- a/src/protocol/generate_protocol.py +++ b/src/protocol/generate_protocol.py @@ -259,7 +259,8 @@ def print_rw_logic(types, value, name, read, prefix=''): if isinstance(v, dict): # print_definition() already warns if this is false if len(v) > 0: for k1, v1 in v.items(): - print_rw_logic(types, v1, k1, read, prefix=prefix) + prefix_case = f'{prefix}{k}.' + print_rw_logic(types, v1, k1, read, prefix=prefix_case) else: add_text('// no other fields') #print_rw_logic(types, v, name, read, prefix=prefix) @@ -345,8 +346,8 @@ def print_definition(types, name, value, serverbound): switch = get_switch_condition(name) if switch != None: # .switch(cond) {} block - # TODO: could give the union and its structs names to avoid having to manually resolve name conflicts ? - add_text('union {{') + newline() + add_text(f'union {{{{ // switch ({switch})') indent() for k, v in value.items(): if not isinstance(v, dict): @@ -354,14 +355,14 @@ def print_definition(types, name, value, serverbound): continue # switch case block newline() - add_text(f'struct {{{{ // if {switch} == {k}') + add_text('struct {{') indent() if len(v) == 0: add_text('// no other fields') for k1, v1 in v.items(): print_definition(types, k1, v1, serverbound) unindent() - add_text('}};') + add_text(f'}}}} {k};') unindent() add_text('}};') else: diff --git a/src/protocol/protocol.hjson b/src/protocol/protocol.hjson index 7ee5ae1..7bbfc35 100644 --- a/src/protocol/protocol.hjson +++ b/src/protocol/protocol.hjson @@ -302,7 +302,7 @@ UpdateLatency: { # in ms - newPing: varint + ping: varint } UpdateDisplayName: {