Skip to content

Commit 3ea3a61

Browse files
committed
Add: bridge pillar flags
1 parent 55a3324 commit 3ea3a61

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

nml/actions/action0properties.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import itertools
1717

1818
from nml import generic, nmlop, global_constants
19+
from nml.global_constants import constant_numbers as global_constant_numbers
1920
from nml.expression import (
2021
AcceptCargo,
2122
Array,
@@ -825,13 +826,27 @@ def generated_function(value):
825826
if not isinstance(value, Array):
826827
raise generic.ScriptError(f"{list_type} list must be an array", value.pos)
827828
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)
829830
return [VariableByteListProp(prop_num, [[flags.reduce_constant().value for flags in value.values]], True)]
830831

831832
return generated_function
832833

833834

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
835850

836851

837852
# fmt: off
@@ -860,7 +875,7 @@ def generated_function(value):
860875
"classname": {"size": 2, "num": (256, -1, 0x1D), "string": (256, 0xC4, 0xDC)},
861876
"tile_flags": {"custom_function": station_tile_flags}, # = prop 1E
862877
"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)},
864879
}
865880
# fmt: on
866881

nml/global_constants.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,16 @@ def constant_number(name, info, pos):
385385
# station tiles
386386
"STAT_ALL_TILES" : 0xFF,
387387

388+
# bridge pillar flags
389+
"BRIDGE_PILLAR_CORNER_W" : 0,
390+
"BRIDGE_PILLAR_CORNER_S" : 1,
391+
"BRIDGE_PILLAR_CORNER_E" : 2,
392+
"BRIDGE_PILLAR_CORNER_N" : 3,
393+
"BRIDGE_PILLAR_EDGE_NE" : 4,
394+
"BRIDGE_PILLAR_EDGE_SE" : 5,
395+
"BRIDGE_PILLAR_EDGE_SW" : 6,
396+
"BRIDGE_PILLAR_EDGE_NW" : 7,
397+
388398
# house flags
389399
"HOUSE_FLAG_NOT_SLOPED" : 1,
390400
"HOUSE_FLAG_ANIMATE" : 5,

0 commit comments

Comments
 (0)