|
16 | 16 | import itertools |
17 | 17 |
|
18 | 18 | from nml import generic, nmlop, global_constants |
| 19 | +from nml.global_constants import constant_numbers as global_constant_numbers |
19 | 20 | from nml.expression import ( |
20 | 21 | AcceptCargo, |
21 | 22 | Array, |
@@ -825,13 +826,27 @@ def generated_function(value): |
825 | 826 | if not isinstance(value, Array): |
826 | 827 | raise generic.ScriptError(f"{list_type} list must be an array", value.pos) |
827 | 828 | if len(value.values) % 2 != 0: |
828 | | - generic.print_warning(generic.Warning.GENERIC, f"{list_type} list does not have even length", 0) |
| 829 | + raise generic.ScriptError(f"{list_type} list does not have even length", value.pos) |
829 | 830 | return [VariableByteListProp(prop_num, [[flags.reduce_constant().value for flags in value.values]], True)] |
830 | 831 |
|
831 | 832 | return generated_function |
832 | 833 |
|
833 | 834 |
|
834 | | - |
| 835 | +def invert_bridge_pillars_flags(value): |
| 836 | + out = ConstantNumeric(0, value.pos) |
| 837 | + for i_flag, o_flag in [ |
| 838 | + (global_constant_numbers["BRIDGE_PILLAR_CORNER_W"], global_constant_numbers["BRIDGE_PILLAR_CORNER_S"]), |
| 839 | + (global_constant_numbers["BRIDGE_PILLAR_CORNER_S"], global_constant_numbers["BRIDGE_PILLAR_CORNER_W"]), |
| 840 | + (global_constant_numbers["BRIDGE_PILLAR_CORNER_N"], global_constant_numbers["BRIDGE_PILLAR_CORNER_E"]), |
| 841 | + (global_constant_numbers["BRIDGE_PILLAR_CORNER_E"], global_constant_numbers["BRIDGE_PILLAR_CORNER_N"]), |
| 842 | + (global_constant_numbers["BRIDGE_PILLAR_EDGE_NE"], global_constant_numbers["BRIDGE_PILLAR_EDGE_NE"]), |
| 843 | + (global_constant_numbers["BRIDGE_PILLAR_EDGE_SE"], global_constant_numbers["BRIDGE_PILLAR_EDGE_SW"]), |
| 844 | + (global_constant_numbers["BRIDGE_PILLAR_EDGE_SW"], global_constant_numbers["BRIDGE_PILLAR_EDGE_SE"]), |
| 845 | + (global_constant_numbers["BRIDGE_PILLAR_EDGE_NW"], global_constant_numbers["BRIDGE_PILLAR_EDGE_NW"]), |
| 846 | + ] : |
| 847 | + if value.value & (1 << i_flag): |
| 848 | + out.value += 1 << o_flag |
| 849 | + return out |
835 | 850 |
|
836 | 851 |
|
837 | 852 | # fmt: off |
@@ -860,7 +875,7 @@ def generated_function(value): |
860 | 875 | "classname": {"size": 2, "num": (256, -1, 0x1D), "string": (256, 0xC4, 0xDC)}, |
861 | 876 | "tile_flags": {"custom_function": station_tile_flags}, # = prop 1E |
862 | 877 | "minimum_bridge_height": {"custom_function": array_for_station_properties(0x20, "Bridge heights", 10, lambda v : v)}, |
863 | | - "bridge_pillars_flags": {"custom_function": array_for_station_properties(0x21, "Flag", 10, lambda v : v)}, |
| 878 | + "bridge_pillars_flags": {"custom_function": array_for_station_properties(0x21, "Flag", 10, invert_bridge_pillars_flags)}, |
864 | 879 | } |
865 | 880 | # fmt: on |
866 | 881 |
|
|
0 commit comments