From 72f969238bc331643516f70b1401aa0e15ffccc9 Mon Sep 17 00:00:00 2001 From: glx22 Date: Sun, 28 May 2023 04:23:08 +0200 Subject: [PATCH 1/2] Change: extend DCxx string range up to FFFF --- nml/actions/action4.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nml/actions/action4.py b/nml/actions/action4.py index 08960521..77c65e06 100644 --- a/nml/actions/action4.py +++ b/nml/actions/action4.py @@ -82,7 +82,11 @@ def skip_action9(self): 0xD0: {"random_id": True, "total": 0x400, "ids": list(range(0xD3FF, 0xCFFF, -1))}, # Misc. persistent text ids, used to set properties. # Use Ids DC00..DCFF first to keep compatibility with older versions of OTTD. - 0xDC: {"random_id": True, "total": 0x800, "ids": list(range(0xDBFF, 0xD7FF, -1)) + list(range(0xDFFF, 0xDBFF, -1))}, + 0xDC: { + "random_id": True, + "total": 0x2800, + "ids": list(range(0xFFFF, 0xDFFF, -1)) + list(range(0xDBFF, 0xD7FF, -1)) + list(range(0xDFFF, 0xDBFF, -1)), + }, } # Mapping of string identifiers to D0xx/DCxx text ids From 913100dbd9d5a11f2584edc01609dd15921cf3eb Mon Sep 17 00:00:00 2001 From: glx22 Date: Sun, 28 May 2023 16:03:30 +0200 Subject: [PATCH 2/2] Change: Use station properties 1C and 1D for names Station names use C5xx range for first 256 IDs, and DCxx range for the rest. As classnames are most likely to be shared they use only DCxx range. --- nml/actions/action0.py | 3 ++ nml/actions/action0properties.py | 5 ++- regression/expected/040_station.grf | Bin 1265 -> 1261 bytes regression/expected/040_station.nfo | 30 +++++++++--------- regression/expected/example_station.grf | Bin 3927 -> 3933 bytes regression/expected/example_station.nfo | 40 +++++++++++++----------- 6 files changed, 42 insertions(+), 36 deletions(-) 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 fbf267608128d12c1974a11ad3ae4b3a38d5fb9c..a5d99774380a9ad97adf6485e2d90ebe8b4f2595 100644 GIT binary patch delta 132 zcmey!`Ib|Zfx$hNi8m65CHKRI2f7! zGca&E`#bvhgawC4g9TaG7=eNuA+Et8vJ7`*7>)`{2r&U=cs^`A&B81$1X0Ay2s8_> Mi1Fy=56p~=0L^i{u^2cQnf@~{a60=t`uKzehX9oW z1zA`afr1<%uE8O~5<*NsF`f_HAQ={x|BMVrLQ;!M7&cyHVOHdUC}(5@3WJryRWU+T KZGOYd$Or)A-yc^1 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 ba767de2c8f1861e737af13686b8956ab627f7f9..77ffb496588f82cf408d3de80df0dd66285a6e55 100644 GIT binary patch delta 159 zcmcaEcUO*^fx$h`Hy@*z5Ca3le-@Vij0|`De0>yLD-v@Ha#ANtFy>9} zXVhS00ZRWBoVt{F$>v;EK}JTt&Gl>#7#aCDCvY$^u?YYrqnRdGGpBAo%k_hiQE>Ay Ho{3BVy7?&_ delta 171 zcmcaBcU_K~fx$hlj&ifNGj1 zH!zoME@l;EWaR~NZvwe#o8PmQF|zRixxX1FU*y@lS%cGok&Pe7k7ki~^g_@JwU^0D%ZB*#H0l 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