Skip to content

Commit

Permalink
Change: Use station properties 1C and 1D for names
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
glx22 committed Jun 28, 2023
1 parent e44e679 commit a9a1a3e
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 36 deletions.
3 changes: 3 additions & 0 deletions nml/actions/action0.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions nml/actions/action0properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Binary file modified regression/expected/040_station.grf
Binary file not shown.
30 changes: 16 additions & 14 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 \d36
0 * 4 \d35

1 * 54 14 "C" "INFO"
"B" "VRSN" \w4 \dx00000000
Expand All @@ -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
Expand Down Expand Up @@ -179,37 +181,37 @@
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
\wx00FF \dx00000001 \dx00000001 // station_spriteset;
\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;

Binary file modified regression/expected/example_station.grf
Binary file not shown.
40 changes: 21 additions & 19 deletions regression/expected/example_station.nfo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a9a1a3e

Please sign in to comment.