(lines)
| 107 | |
| 108 | |
| 109 | def parse_tunings(lines): |
| 110 | def parse_value(value): |
| 111 | value = value.strip() |
| 112 | try: |
| 113 | if value.endswith("f / (float)SERVER_TICK_SPEED"): |
| 114 | return float(value.rstrip("f / (float)SERVER_TICK_SPEED")) / 50.0 |
| 115 | return float(value.strip("f")) |
| 116 | except Exception as e: |
| 117 | raise RuntimeError("Failed to parse tuning value: {value}") from e |
| 118 | |
| 119 | parsed_tunings = [] |
| 120 | for line in lines: |
| 121 | args = re.match(r"^MACRO_TUNING_PARAM\((.*)\)", line) |
| 122 | if args is None: |
| 123 | continue |
| 124 | parsed = parse_arguments(args[1], num=4, name="tuning") |
| 125 | parsed_tunings.append({"name": parsed[1], "description": parsed[3], "default": parse_value(parsed[2])}) |
| 126 | parsed_tunings.sort(key=lambda tuning: tuning["name"]) |
| 127 | return parsed_tunings |
| 128 | |
| 129 | |
| 130 | def export_commands(parsed_commands): |
no test coverage detected