From 5d3f4d37bd518cf08c3689161be4fc78f759d7e8 Mon Sep 17 00:00:00 2001 From: glx22 Date: Sun, 14 Sep 2025 18:24:30 +0200 Subject: [PATCH] Add: Extend FEAT_TRAIN track_type for prop 34 --- nml/actions/action0properties.py | 14 +++++++++++++- regression/013_train_callback.nml | 2 ++ regression/expected/013_train_callback.grf | Bin 7867 -> 7873 bytes regression/expected/013_train_callback.nfo | 9 ++++++--- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/nml/actions/action0properties.py b/nml/actions/action0properties.py index 5d931858e..edcab2574 100644 --- a/nml/actions/action0properties.py +++ b/nml/actions/action0properties.py @@ -412,6 +412,16 @@ def prop_test(value): ] +def single_or_list(prop_name, single_num, multiple_num, value): + if isinstance(value, ConstantNumeric): + return [Action0Property(single_num, value, 1)] + if isinstance(value, Array): + if len(value.values) == 1: + return [Action0Property(single_num, value.values[0].reduce_constant(), 1)] + return [VariableByteListProp(multiple_num, [[type.reduce_constant().value for type in value.values]])] + raise generic.ScriptError("'{}' must be a constant or an array of constants".format(prop_name)) + + # # Feature 0x00 (Trains) # @@ -419,7 +429,9 @@ def prop_test(value): # fmt: off properties[0x00] = { **general_veh_props, - "track_type": {"size": 1, "num": 0x05}, + "track_type": { + "custom_function": lambda value: single_or_list("track_type", 0x05, 0x34, value) + }, "ai_special_flag": {"size": 1, "num": 0x08}, "speed": { "size": 2, diff --git a/regression/013_train_callback.nml b/regression/013_train_callback.nml index 2286f24d9..28873ffb3 100644 --- a/regression/013_train_callback.nml +++ b/regression/013_train_callback.nml @@ -136,6 +136,8 @@ item(FEAT_TRAINS, bulk_wagon) { speed: 0; refit_cost: 40; track_type: RAIL; + track_type: [RAIL]; + track_type: [RAIL, ELRL]; power: 0; running_cost_base: RUNNING_COST_STEAM; cargo_capacity: 30; diff --git a/regression/expected/013_train_callback.grf b/regression/expected/013_train_callback.grf index d1daeed352d01b9ce4c09e3086da8613ca6e1ee3..fd8c1f115f339d152e8aecfd226eca19c0dacfca 100644 GIT binary patch delta 53 zcmdmOd(f7ffx$h3BN!MM{xdMhOs-_LXJchBVPat1 Jyn~fl5&(hs4Ilsj delta 46 zcmX?TyW5tVfx$h