Compare commits

...

2 Commits

Author SHA1 Message Date
3e04103ae4 fix formatting 2023-09-18 21:09:20 -05:00
3559682d18 genstructs.py: generate PacketIDToString()
this will be nice to have for debugging
2023-09-18 20:46:37 -05:00
2 changed files with 1023 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -368,6 +368,13 @@ if __name__ == '__main__':
source += "\t%s = 0x%x\n" % (const.name, const.value) source += "\t%s = 0x%x\n" % (const.name, const.value)
source += ")\n\n" source += ")\n\n"
source += "func PacketIDToString(id uint32) string {\n"
source += "\tswitch id {\n"
for const in consts:
if const.name.startswith("P_"):
source += "\tcase %s:\n\t\treturn \"%s\"\n" % (const.name, const.name)
source += "\t}\n\treturn \"UNKNOWN\"\n}\n\n"
for struct in structs: for struct in structs:
source += struct.toGoStyle() + "\n" source += struct.toGoStyle() + "\n"
print(source) print(source)