diff --git a/nml/actions/action0.py b/nml/actions/action0.py index 8592795a..9d8babb9 100644 --- a/nml/actions/action0.py +++ b/nml/actions/action0.py @@ -630,6 +630,9 @@ def parse_property(prop_info, value_list, feature, id): "String used as value for non-string property: " + str(prop_info["num"]), value.pos ) string_range = prop_info["string"] + if isinstance(string_range, tuple): + threshold, below, above = string_range + string_range = below if id.value < threshold else above stringid, string_actions = action4.get_string_action4s(feature, string_range, value, id) value = expression.ConstantNumeric(stringid) action_list_append.extend(string_actions) diff --git a/nml/actions/action0properties.py b/nml/actions/action0properties.py index 495c562e..f2ab91cc 100644 --- a/nml/actions/action0properties.py +++ b/nml/actions/action0properties.py @@ -706,9 +706,8 @@ def cargo_bitmask(value): # 19 (road routing) reserved for future use # 1A (advanced sprite layout) is implemented elsewhere # 1B (minimum bridge height) JGR only - - "classname": {"num": -1, "string": 0xC4}, - "name": {"num": -1, "string": 0xC5, "required": True}, + "name": {"size": 2, "num": 0x1C, "string": (256, 0xC5, 0xDC), "required": True}, + "classname": {"size": 2, "num": 0x1D, "string": 0xDC}, } # fmt: on diff --git a/regression/expected/040_station.grf b/regression/expected/040_station.grf index fbf26760..a5d99774 100644 Binary files a/regression/expected/040_station.grf and b/regression/expected/040_station.grf differ diff --git a/regression/expected/040_station.nfo b/regression/expected/040_station.nfo index 8e7045dc..8eb8fc98 100644 --- a/regression/expected/040_station.nfo +++ b/regression/expected/040_station.nfo @@ -5,7 +5,7 @@ // Escapes: D= = DR D+ = DF D- = DC Du* = DM D* = DnF Du<< = DnC D<< = DO D& D| Du/ D/ Du% D% // Format: spritenum imagefile depth xpos ypos xsize ysize xrel yrel zoom flags -0 * 4 \d36 +0 * 4 \d35 1 * 54 14 "C" "INFO" "B" "VRSN" \w4 \dx00000000 @@ -16,17 +16,19 @@ 00 00 2 * 52 08 08 "NML\40" "NML regression test" 00 "A test newgrf testing NML" 00 -3 * 16 00 08 \b1 02 FF \wx0000 +3 * 11 04 04 FF 01 \wxDC00 "Test" 00 + +4 * 16 00 08 \b1 02 FF \wx0000 09 "COAL" "LVST" -4 * 21 00 04 \b4 01 FF \wx0000 +5 * 27 00 04 \b6 01 FF \wx0000 08 "TEST" +1D \wxDC00 +1C \wxC500 13 18 12 \dx00000002 0C F0 -5 * 11 04 04 FF 01 \wxC400 "Test" 00 - 6 * 20 04 04 FF 01 \wxC500 "Basic station" 00 7 * 6 01 04 \b2 FF \wx0002 @@ -179,30 +181,30 @@ FF \wx00F9 // @action3_3; \wx00F8 // @action3_4; -29 * 12 00 04 \b1 01 FF \wx0001 +29 * 18 00 04 \b3 01 FF \wx0001 08 "TEST" +1D \wxDC00 +1C \wxC501 -30 * 11 04 04 FF 01 \wxC401 "Test" 00 - -31 * 22 04 04 FF 01 \wxC501 "Basic station 2" 00 +30 * 22 04 04 FF 01 \wxC501 "Basic station 2" 00 -32 * 9 00 04 \b1 01 FF \wx0001 +31 * 9 00 04 \b1 01 FF \wx0001 0A 00 // Name: @CB_FAILED_REAL04 -33 * 7 02 04 F8 \b0 \b1 +32 * 7 02 04 F8 \b0 \b1 \w0 // Name: @CB_FAILED04 -34 * 23 02 04 F8 89 +33 * 23 02 04 F8 89 0C 00 \dx0000FFFF \b1 \wx8000 \dx00000000 \dx00000000 // graphics callback -> return 0 \wx00F8 // Non-graphics callback, return graphics result // Name: @action3_7 -35 * 41 02 04 F8 89 +34 * 41 02 04 F8 89 7E FD 20 \dxFFFFFFFF // Station Layout@registers - Id 00 \2r 10 00 \dx000000FF \b2 @@ -210,6 +212,6 @@ FF \wx00F9 // @action3_3; \wx00FE \dx00000003 \dx00000003 // station_spriteset2; \wx00F8 // @CB_FAILED04; -36 * 7 03 04 01 01 \b0 +35 * 7 03 04 01 01 \b0 \wx00F8 // @action3_7; diff --git a/regression/expected/example_station.grf b/regression/expected/example_station.grf index ba767de2..77ffb496 100644 Binary files a/regression/expected/example_station.grf and b/regression/expected/example_station.grf differ diff --git a/regression/expected/example_station.nfo b/regression/expected/example_station.nfo index 0e8c930a..f1a9a462 100644 --- a/regression/expected/example_station.nfo +++ b/regression/expected/example_station.nfo @@ -16,57 +16,59 @@ 00 00 2 * 193 08 08 "NML\06" "NML Example NewGRF: Station" 00 "\8ENML Example NewGRF: Station\0D\98This NewGRF is intended to provide a coding example for the high-level NewGRF-coding language NML.\0DConversion of CHIPS Cow pens." 00 +3 * 18 04 04 FF 01 \wxDC00 "NML Example" 00 + // param[126] = param[161] -3 * 5 0D 7E \D= A1 00 +4 * 5 0D 7E \D= A1 00 // param[127] = (param[126] - 302012611) -4 * 9 0D 7F \D- 7E FF \dx120058C3 +5 * 9 0D 7F \D- 7E FF \dx120058C3 // param[127] = (param[127] << -31) -5 * 9 0D 7F \Du<< 7F FF \dxFFFFFFE1 +6 * 9 0D 7F \Du<< 7F FF \dxFFFFFFE1 -6 * 9 09 7F 04 \7= \dx00000000 01 +7 * 9 09 7F 04 \7= \dx00000000 01 -7 * 19 0B 03 7F 06 "1.2.0 (r22723)" 00 +8 * 19 0B 03 7F 06 "1.2.0 (r22723)" 00 -8 * 12 00 08 \b1 01 FF \wx0000 +9 * 12 00 08 \b1 01 FF \wx0000 09 "LVST" -9 * 6 01 04 \b3 FF \wx0002 +10 * 6 01 04 \b3 FF \wx0002 -10 cows_cargo.png 8bpp 10 10 64 65 -31 -34 normal -11 cows_cargo.png 8bpp 220 10 64 65 -31 -34 normal +11 cows_cargo.png 8bpp 10 10 64 65 -31 -34 normal +12 cows_cargo.png 8bpp 220 10 64 65 -31 -34 normal -12 cows_cargo.png 8bpp 80 10 64 65 -31 -34 normal -13 cows_cargo.png 8bpp 290 10 64 65 -31 -34 normal +13 cows_cargo.png 8bpp 80 10 64 65 -31 -34 normal +14 cows_cargo.png 8bpp 290 10 64 65 -31 -34 normal -14 cows_cargo.png 8bpp 150 10 64 65 -31 -34 normal -15 cows_cargo.png 8bpp 360 10 64 65 -31 -34 normal +15 cows_cargo.png 8bpp 150 10 64 65 -31 -34 normal +16 cows_cargo.png 8bpp 360 10 64 65 -31 -34 normal // Name: cow_pen_1 - feature 04 -16 * 11 02 04 FF \b2 \b1 +17 * 11 02 04 FF \b2 \b1 \w0 \w1 \w2 // Name: cow_pen_2 - feature 04 -17 * 13 02 04 FE \b3 \b1 +18 * 13 02 04 FE \b3 \b1 \w0 \w1 \w2 \w2 // Name: random_cow_pen -18 * 11 02 04 FE 80 00 \b16 02 +19 * 11 02 04 FE 80 00 \b16 02 \wx00FF // (1/2) -> (1/2): cow_pen_1; \wx00FE // (1/2) -> (1/2): cow_pen_2; -19 * 21 00 04 \b5 01 FF \wx0000 +20 * 27 00 04 \b7 01 FF \wx0000 08 "NML_" +1D \wxDC00 +1C \wxC500 10 \wx00A0 11 00 14 FF 15 FF -20 * 18 04 04 FF 01 \wxC400 "NML Example" 00 - 21 * 21 04 04 FF 01 \wxC500 "CHIPS Cow pens" 00 // Name: cow_pen_half - feature 04