From ea1699abb3ea7655ff97f492cb12dce5323a4256 Mon Sep 17 00:00:00 2001 From: glx22 Date: Wed, 20 Sep 2023 23:43:45 +0200 Subject: [PATCH] Change: always assume non-track station ground tile For track station ground tile explicitly use `GROUNDSPRITE_RAIL_X` and `GROUNDSPRITE_RAIL_Y` --- examples/station/example_station.nml | 10 +++++----- nml/actions/action2layout.py | 10 +++++++++- regression/expected/example_station.grf | Bin 3933 -> 3889 bytes regression/expected/example_station.nfo | 22 +++++++--------------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/station/example_station.nml b/examples/station/example_station.nml index 05bf3e6f..20c547c7 100644 --- a/examples/station/example_station.nml +++ b/examples/station/example_station.nml @@ -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 @@ -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 @@ -114,7 +114,7 @@ item(FEAT_STATIONS, cow_pen) { non_traversable_tiles: 0xFF; } graphics { - sprite_layouts: [cow_pen_X(0), cow_pen_Y(0)]; + sprite_layouts: [cow_pen_X, cow_pen_Y]; purchase: cow_pen_half; LVST: random_cow_pen; cow_pen_empty; diff --git a/nml/actions/action2layout.py b/nml/actions/action2layout.py index 288222f8..aa995e50 100644 --- a/nml/actions/action2layout.py +++ b/nml/actions/action2layout.py @@ -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 @@ -292,6 +292,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): diff --git a/regression/expected/example_station.grf b/regression/expected/example_station.grf index 77ffb496588f82cf408d3de80df0dd66285a6e55..513707c87ff6523b1068523072d911b9dbe7011a 100644 GIT binary patch delta 153 zcmcaBw^5Fpfx$h6B6cspFGUXaG|Da9$${uL;6q1X6rb49!4_fuTVjNC1ua+gbNV;Xe@Y3ovZv IVGiU00BYwQI{*Lx delta 173 zcmdlecUO*^fx$h`cNkMW0}wDVH0ic5G%$hK0s<<{ju62XWWm-fpx}Qd zmOq_R3Lt4dDTM|g#b4W?@E-^mq!ga9gGHM_qHs0MD7;3njz%OM!XSfMAc`1)6rU7B K>*nK3Sv&x2e