Skip to content

Commit 6d36f0a

Browse files
committed
Change: always assume non-track station ground tile
For track station ground tile explicitly use `GROUNDSPRITE_RAIL_X` and `GROUNDSPRITE_RAIL_Y`
1 parent 26f271f commit 6d36f0a

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

examples/station/example_station.nml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ spriteset (cow_pen_full, "cows_cargo.png") {
6060
[ 360, 10, 64, 65, -31, -34 ]
6161
}
6262

63-
spritelayout cow_pen_X(a) {
63+
spritelayout cow_pen_X {
6464
ground {
65-
sprite: 2022 + a; // prevent railtype offset
65+
sprite: 2022;
6666
}
6767
building {
6868
sprite: DEFAULT(0); // first sprite in active spriteset
@@ -72,9 +72,9 @@ spritelayout cow_pen_X(a) {
7272
}
7373
}
7474

75-
spritelayout cow_pen_Y(a) {
75+
spritelayout cow_pen_Y {
7676
ground {
77-
sprite: 2022 + a; // prevent railtype offset
77+
sprite: 2022;
7878
}
7979
building {
8080
sprite: DEFAULT(1); // second sprite in active spriteset
@@ -114,7 +114,7 @@ item(FEAT_STATIONS, cow_pen) {
114114
non_traversable_tiles: 0xFF;
115115
}
116116
graphics {
117-
sprite_layouts: [cow_pen_X(0), cow_pen_Y(0)];
117+
sprite_layouts: [cow_pen_X, cow_pen_Y];
118118
purchase: cow_pen_half;
119119
LVST: random_cow_pen;
120120
cow_pen_empty;

nml/actions/action2layout.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
with NML; if not, write to the Free Software Foundation, Inc.,
1414
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."""
1515

16-
from nml import expression, generic, nmlop
16+
from nml import expression, generic, global_constants, nmlop
1717
from nml.actions import action0, action1, action2, action2real, action2var, action6, actionD, real_sprite
1818
from nml.ast import general, spriteblock
1919

@@ -292,6 +292,14 @@ def _validate_sprite(self, name, value):
292292
else:
293293
self.sprite_from_action1 = False
294294
if isinstance(value, expression.ConstantNumeric):
295+
# For stations always assume a non-track tile ground, unless explicit rail ground sprite.
296+
if (
297+
self.feature == 0x04
298+
and self.type == Action2LayoutSpriteType.GROUND
299+
and value.value != global_constants.constant_numbers["GROUNDSPRITE_RAIL_X"]
300+
and value.value != global_constants.constant_numbers["GROUNDSPRITE_RAIL_Y"]
301+
):
302+
self.create_register(name, expression.ConstantNumeric(0))
295303
generic.check_range(value.value, 0, (1 << 14) - 1, "sprite", value.pos)
296304
return value
297305
if value.supported_by_actionD(raise_error=False):
-44 Bytes
Binary file not shown.

regression/expected/example_station.nfo

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,21 @@
8181

8282
24 * 51 00 04 \b1 01 FF \wx0000
8383
1A \b2
84-
\b65 \dx00000000 \wx0002 82
84+
\b65 \dx000007E6 \wx0002 80
85+
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 81
86+
\b65 \dx000007E6 \wx0002 82
8587
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 83
86-
\b65 \dx00000000 \wx0002 84
87-
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 85
8888

8989
// Name: Station Layout@registers - Id 00
90-
// a : register 80
91-
// a : register 81
92-
25 * 106 02 04 FC 89
90+
25 * 62 02 04 FC 89
9391
1A 20 \dx00000000
9492
\2sto 1A 20 \dx00000080
95-
\2r 7D 80 20 \dxFFFFFFFF // a
96-
\2+ 1A 20 \dx000007E6
97-
\2sto 1A 20 \dx00000082
98-
\2r 1A 20 \dx00000000
99-
\2sto 1A 20 \dx00000083
10093
\2r 1A 20 \dx00000000
10194
\2sto 1A 20 \dx00000081
102-
\2r 7D 81 20 \dxFFFFFFFF // a
103-
\2+ 1A 20 \dx000007E6
104-
\2sto 1A 20 \dx00000084
95+
\2r 1A 20 \dx00000000
96+
\2sto 1A 20 \dx00000082
10597
\2r 1A 20 \dx00000001
106-
\2sto 1A 00 \dx00000085
98+
\2sto 1A 00 \dx00000083
10799
\b0
108100
\wx8000 // Return computed value
109101

0 commit comments

Comments
 (0)