Skip to content

Commit

Permalink
Fix a9a1a3e: Forget about C5xx range for station names
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Sep 26, 2023
1 parent bbe945e commit c21cbcf
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 53 deletions.
3 changes: 0 additions & 3 deletions nml/actions/action0.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,6 @@ 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)
Expand Down
2 changes: 1 addition & 1 deletion nml/actions/action0properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def cargo_bitmask(value):
# 19 (road routing) reserved for future use
# 1A (advanced sprite layout) is implemented elsewhere
# 1B (minimum bridge height) JGR only
"name": {"size": 2, "num": 0x1C, "string": (256, 0xC5, 0xDC), "required": True},
"name": {"size": 2, "num": 0x1C, "string": 0xDC, "required": True},
"classname": {"size": 2, "num": 0x1D, "string": 0xDC},
}
# fmt: on
Expand Down
Binary file modified regression/expected/040_station.grf
Binary file not shown.
68 changes: 32 additions & 36 deletions regression/expected/040_station.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -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 \d35
0 * 4 \d33

1 * 54 14 "C" "INFO"
"B" "VRSN" \w4 \dx00000000
Expand All @@ -16,40 +16,38 @@
00
00
2 * 52 08 08 "NML\40" "NML regression test" 00 "A test newgrf testing NML" 00
3 * 11 04 04 FF 01 \wxDC00 "Test" 00
3 * 41 04 04 FF 03 \wxDC00 "Test" 00 "Basic station" 00 "Basic station 2" 00

4 * 16 00 08 \b1 02 FF \wx0000
09 "COAL" "LVST"

5 * 27 00 04 \b6 01 FF \wx0000
08 "TEST"
1D \wxDC00
1C \wxC500
1C \wxDC01
13 18
12 \dx00000002
0C F0

6 * 20 04 04 FF 01 \wxC500 "Basic station" 00
6 * 6 01 04 \b2 FF \wx0002

7 * 6 01 04 \b2 FF \wx0002
7 station.png 8bpp 1 1 5 5 -2 -2 normal
8 station.png 8bpp 7 1 5 5 -2 -2 normal

8 station.png 8bpp 1 1 5 5 -2 -2 normal
9 station.png 8bpp 7 1 5 5 -2 -2 normal

10 station.png 8bpp 2 2 3 3 -1 -1 normal
11 station.png 8bpp 8 2 3 3 -1 -1 normal
9 station.png 8bpp 2 2 3 3 -1 -1 normal
10 station.png 8bpp 8 2 3 3 -1 -1 normal

// Name: station_spriteset - feature 04
12 * 7 02 04 FF \b0 \b1
11 * 7 02 04 FF \b0 \b1

\w0

// Name: station_spriteset2 - feature 04
13 * 7 02 04 FE \b0 \b1
12 * 7 02 04 FE \b0 \b1

\w1

14 * 114 00 04 \b1 01 FF \wx0000
13 * 114 00 04 \b1 01 FF \wx0000
1A \b2
\b68 \dx000003F4 \wx0000
\dx0000842E \wx0000 \b0 \b0 \b0 \b16 \b5 \b2
Expand All @@ -64,7 +62,7 @@

// Name: Station Layout@registers - Id 00
// a : register 80
15 * 77 02 04 FD 89
14 * 77 02 04 FD 89
1A 20 \dx00000000
\2sto 1A 20 \dx00000081
\2r 1A 20 \dx00000000
Expand All @@ -79,7 +77,7 @@
\wx8000 // Return computed value

// Name: Station Layout@prepare - Id 00
16 * 34 02 04 FC 89
15 * 34 02 04 FC 89
1A 20 \dx00000000
\2sto 1A 20 \dx00000000
\2r 1A 20 \dx00000001
Expand All @@ -88,7 +86,7 @@
\wx8000 // Return computed value

// Name: @action3_0
17 * 49 02 04 FB 89
16 * 49 02 04 FB 89
7E FC 20 \dxFFFFFFFF // Station Layout@prepare - Id 00
\2r 7E FD 20 \dxFFFFFFFF // Station Layout@registers - Id 00
\2r 10 00 \dx000000FF
Expand All @@ -98,7 +96,7 @@
\wx00FF // station_spriteset;

// Name: @action3_1
18 * 49 02 04 FA 89
17 * 49 02 04 FA 89
7E FC 20 \dxFFFFFFFF // Station Layout@prepare - Id 00
\2r 7E FD 20 \dxFFFFFFFF // Station Layout@registers - Id 00
\2r 10 00 \dx000000FF
Expand All @@ -108,7 +106,7 @@
\wx00FE // station_spriteset2;

// Name: @action3_2
19 * 49 02 04 FC 89
18 * 49 02 04 FC 89
7E FC 20 \dxFFFFFFFF // Station Layout@prepare - Id 00
\2r 7E FD 20 \dxFFFFFFFF // Station Layout@registers - Id 00
\2r 10 00 \dx000000FF
Expand All @@ -118,7 +116,7 @@
\wx00FF // station_spriteset;

// Name: @action3_3
20 * 55 02 04 F9 89
19 * 55 02 04 F9 89
1A 20 \dx00000003
\2sto 1A 20 \dx00000003
\2r 7E FD 20 \dxFFFFFFFF // Station Layout@registers - Id 00
Expand All @@ -128,90 +126,88 @@
\wx00FE \dx00000003 \dx00000003 // station_spriteset2;
\wx00FF // station_spriteset;

21 * 9 00 04 \b1 01 FF \wx0000
20 * 9 00 04 \b1 01 FF \wx0000
0B 08

// Name: @return_action_0
22 * 20 02 04 F8 89
21 * 20 02 04 F8 89
43 38 \dx0000000F
\2+ 43 1C \dx0000000F
\b0
\wx8000 // Return computed value

// Name: @action3_4
23 * 23 02 04 F8 89
22 * 23 02 04 F8 89
0C 00 \dx0000FFFF
\b1
\wx00F8 \dx00000142 \dx00000142 // return (var[0x43, 24, 15] + var[0x43, 28, 15])
\wx00FB // @action3_0;

// Name: @return_action_1
24 * 20 02 04 F7 89
23 * 20 02 04 F7 89
43 38 \dx0000000F
\2+ 43 1C \dx0000000F
\b0
\wx8000 // Return computed value

// Name: @action3_5
25 * 33 02 04 F7 89
24 * 33 02 04 F7 89
0C 00 \dx0000FFFF
\b2
\wx00FA \dx00000000 \dx00000000 // @action3_1;
\wx00F7 \dx00000142 \dx00000142 // return (var[0x43, 24, 15] + var[0x43, 28, 15])
\wx00FB // @action3_0;

// Name: @return_action_2
26 * 20 02 04 FA 89
25 * 20 02 04 FA 89
43 38 \dx0000000F
\2+ 43 1C \dx0000000F
\b0
\wx8000 // Return computed value

// Name: @action3_6
27 * 33 02 04 FB 89
26 * 33 02 04 FB 89
0C 00 \dx0000FFFF
\b2
\wx00FC \dx00000000 \dx00000000 // @action3_2;
\wx00FA \dx00000142 \dx00000142 // return (var[0x43, 24, 15] + var[0x43, 28, 15])
\wx00FB // @action3_0;

28 * 16 03 04 01 00 \b3
27 * 16 03 04 01 00 \b3
00 \wx00F7 // @action3_5;
01 \wx00FB // @action3_6;
FF \wx00F9 // @action3_3;
\wx00F8 // @action3_4;

29 * 18 00 04 \b3 01 FF \wx0001
28 * 18 00 04 \b3 01 FF \wx0001
08 "TEST"
1D \wxDC00
1C \wxC501

30 * 22 04 04 FF 01 \wxC501 "Basic station 2" 00
1C \wxDC02

31 * 9 00 04 \b1 01 FF \wx0001
29 * 9 00 04 \b1 01 FF \wx0001
0A 00

// Name: @CB_FAILED_REAL04
32 * 7 02 04 F8 \b0 \b1
30 * 7 02 04 F8 \b0 \b1

\w0

// Name: @CB_FAILED04
33 * 23 02 04 F8 89
31 * 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
34 * 41 02 04 F8 89
32 * 41 02 04 F8 89
7E FD 20 \dxFFFFFFFF // Station Layout@registers - Id 00
\2r 10 00 \dx000000FF
\b2
\wx00FF \dx00000001 \dx00000001 // station_spriteset;
\wx00FE \dx00000003 \dx00000003 // station_spriteset2;
\wx00F8 // @CB_FAILED04;

35 * 7 03 04 01 01 \b0
33 * 7 03 04 01 01 \b0
\wx00F8 // @action3_7;

Binary file modified regression/expected/example_station.grf
Binary file not shown.
24 changes: 11 additions & 13 deletions regression/expected/example_station.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -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 \d29
0 * 4 \d28

1 * 54 14 "C" "INFO"
"B" "VRSN" \w4 \dx00000001
Expand All @@ -16,7 +16,7 @@
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
3 * 33 04 04 FF 02 \wxDC00 "NML Example" 00 "CHIPS Cow pens" 00

// param[126] = param[161]
4 * 5 0D 7E \D= A1 00
Expand Down Expand Up @@ -63,25 +63,23 @@
20 * 27 00 04 \b7 01 FF \wx0000
08 "NML_"
1D \wxDC00
1C \wxC500
1C \wxDC01
10 \wx00A0
11 00
14 FF
15 FF

21 * 21 04 04 FF 01 \wxC500 "CHIPS Cow pens" 00

// Name: cow_pen_half - feature 04
22 * 7 02 04 FF \b0 \b1
21 * 7 02 04 FF \b0 \b1

\w1

// Name: cow_pen_empty - feature 04
23 * 7 02 04 FD \b0 \b1
22 * 7 02 04 FD \b0 \b1

\w0

24 * 51 00 04 \b1 01 FF \wx0000
23 * 51 00 04 \b1 01 FF \wx0000
1A \b2
\b65 \dx00000000 \wx0002 82
\dx8000842D \wx0002 \b0 \b0 \b0 \b16 \b16 \b36 83
Expand All @@ -91,7 +89,7 @@
// Name: Station Layout@registers - Id 00
// a : register 80
// a : register 81
25 * 106 02 04 FC 89
24 * 106 02 04 FC 89
1A 20 \dx00000000
\2sto 1A 20 \dx00000080
\2r 7D 80 20 \dxFFFFFFFF // a
Expand All @@ -110,30 +108,30 @@
\wx8000 // Return computed value

// Name: @action3_0
26 * 31 02 04 FD 89
25 * 31 02 04 FD 89
7E FC 20 \dxFFFFFFFF // Station Layout@registers - Id 00
\2r 10 00 \dx000000FF
\b1
\wx00FD \dx00000000 \dx00000000 // cow_pen_empty;
\wx00FD // cow_pen_empty;

// Name: @action3_1
27 * 31 02 04 FE 89
26 * 31 02 04 FE 89
7E FC 20 \dxFFFFFFFF // Station Layout@registers - Id 00
\2r 10 00 \dx000000FF
\b1
\wx00FE \dx00000000 \dx00000000 // random_cow_pen;
\wx00FE // random_cow_pen;

// Name: @action3_2
28 * 31 02 04 FF 89
27 * 31 02 04 FF 89
7E FC 20 \dxFFFFFFFF // Station Layout@registers - Id 00
\2r 10 00 \dx000000FF
\b1
\wx00FF \dx00000000 \dx00000000 // cow_pen_half;
\wx00FF // cow_pen_half;

29 * 13 03 04 01 00 \b2
28 * 13 03 04 01 00 \b2
00 \wx00FE // @action3_1;
FF \wx00FF // @action3_2;
\wx00FD // @action3_0;
Expand Down

0 comments on commit c21cbcf

Please sign in to comment.