Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: always assume non-track station ground tile #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions examples/station/example_station.nml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ spriteset (cow_pen_full, "cows_cargo.png") {
[ 360, 10, 64, 65, -31, -34 ]
}

spritelayout cow_pen_X(a) {
spritelayout cow_pen_X {
ground {
sprite: 2022 + a; // prevent railtype offset
sprite: 2022;
}
building {
sprite: DEFAULT(0); // first sprite in active spriteset
Expand All @@ -72,9 +72,9 @@ spritelayout cow_pen_X(a) {
}
}

spritelayout cow_pen_Y(a) {
spritelayout cow_pen_Y {
ground {
sprite: 2022 + a; // prevent railtype offset
sprite: 2022;
}
building {
sprite: DEFAULT(1); // second sprite in active spriteset
Expand Down Expand Up @@ -115,7 +115,7 @@ item(FEAT_STATIONS, cow_pen) {
];
}
graphics {
sprite_layouts: [cow_pen_X(0), cow_pen_Y(0)];
sprite_layouts: [cow_pen_X, cow_pen_Y];
select_tile_type: 0;
purchase: cow_pen_half;
LVST: random_cow_pen;
Expand Down
10 changes: 9 additions & 1 deletion nml/actions/action2layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
with NML; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."""

from nml import expression, generic, nmlop
from nml import expression, generic, global_constants, nmlop
from nml.actions import action0, action1, action2, action2real, action2var, action6, actionD, real_sprite
from nml.ast import general, spriteblock

Expand Down Expand Up @@ -296,6 +296,14 @@ def _validate_sprite(self, name, value):
else:
self.sprite_from_action1 = False
if isinstance(value, expression.ConstantNumeric):
# For stations always assume a non-track tile ground, unless explicit rail ground sprite.
if (
self.feature == 0x04
and self.type == Action2LayoutSpriteType.GROUND
and value.value != global_constants.constant_numbers["GROUNDSPRITE_RAIL_X"]
and value.value != global_constants.constant_numbers["GROUNDSPRITE_RAIL_Y"]
):
self.create_register(name, expression.ConstantNumeric(0))
generic.check_range(value.value, 0, (1 << 14) - 1, "sprite", value.pos)
return value
if value.supported_by_actionD(raise_error=False):
Expand Down
Binary file modified regression/expected/example_station.grf
Binary file not shown.
24 changes: 6 additions & 18 deletions regression/expected/example_station.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -81,29 +81,17 @@

24 * 51 00 04 \b1 01 FF \wx0000
1A \b2
\b65 \dx00000000 \wx0002 82
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 83
\b65 \dx00000000 \wx0002 84
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 85
\b65 \dx000007E6 \wx0002 80
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 80
\b65 \dx000007E6 \wx0002 80
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 81

// Name: Station Layout@registers - Id 00
// a : register 80
// a : register 81
25 * 106 02 04 FC 89
25 * 34 02 04 FC 89
1A 20 \dx00000000
\2sto 1A 20 \dx00000080
\2r 1A 20 \dx00000000
\2sto 1A 20 \dx00000081
\2r 7D 80 20 \dxFFFFFFFF // a
\2+ 1A 20 \dx000007E6
\2sto 1A 20 \dx00000082
\2r 1A 20 \dx00000000
\2sto 1A 20 \dx00000083
\2r 7D 81 20 \dxFFFFFFFF // a
\2+ 1A 20 \dx000007E6
\2sto 1A 20 \dx00000084
\2r 1A 20 \dx00000001
\2sto 1A 00 \dx00000085
\2sto 1A 00 \dx00000081
\b0
\wx8000 // Return computed value

Expand Down
Loading