Skip to content

Commit ea1699a

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 bbe945e commit ea1699a

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
@@ -83,29 +83,21 @@
8383

8484
24 * 51 00 04 \b1 01 FF \wx0000
8585
1A \b2
86-
\b65 \dx00000000 \wx0002 82
86+
\b65 \dx000007E6 \wx0002 80
87+
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 81
88+
\b65 \dx000007E6 \wx0002 82
8789
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 83
88-
\b65 \dx00000000 \wx0002 84
89-
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 85
9090

9191
// Name: Station Layout@registers - Id 00
92-
// a : register 80
93-
// a : register 81
94-
25 * 106 02 04 FC 89
92+
25 * 62 02 04 FC 89
9593
1A 20 \dx00000000
9694
\2sto 1A 20 \dx00000080
97-
\2r 7D 80 20 \dxFFFFFFFF // a
98-
\2+ 1A 20 \dx000007E6
99-
\2sto 1A 20 \dx00000082
100-
\2r 1A 20 \dx00000000
101-
\2sto 1A 20 \dx00000083
10295
\2r 1A 20 \dx00000000
10396
\2sto 1A 20 \dx00000081
104-
\2r 7D 81 20 \dxFFFFFFFF // a
105-
\2+ 1A 20 \dx000007E6
106-
\2sto 1A 20 \dx00000084
97+
\2r 1A 20 \dx00000000
98+
\2sto 1A 20 \dx00000082
10799
\2r 1A 20 \dx00000001
108-
\2sto 1A 00 \dx00000085
100+
\2sto 1A 00 \dx00000083
109101
\b0
110102
\wx8000 // Return computed value
111103

0 commit comments

Comments
 (0)