From ea2f90d1485b8443214ecc84c64975de072e5ad0 Mon Sep 17 00:00:00 2001 From: glx22 Date: Sun, 27 Sep 2026 15:34:04 +0200 Subject: [PATCH] Add: basic sanity check for 'articulated_part' callback --- nml/actions/action3.py | 6 ++++++ nml/actions/action3_callbacks.py | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/nml/actions/action3.py b/nml/actions/action3.py index 8fcb599fe..63d5a17ab 100644 --- a/nml/actions/action3.py +++ b/nml/actions/action3.py @@ -329,6 +329,12 @@ def parse_graphics_block_single_id( for info in info_list: if "deprecate_message" in info: generic.print_warning(generic.Warning.DEPRECATION, info["deprecate_message"], cargo_id.pos) + if "maxid" in info and id.value > info["maxid"]: + generic.print_warning( + generic.Warning.GENERIC, + "Make sure you don't use this item as result for callback '{}'.".format(cb_name), + cargo_id.pos, + ) if house_tile is not None and "tiles" in info and house_tile not in info["tiles"]: continue diff --git a/nml/actions/action3_callbacks.py b/nml/actions/action3_callbacks.py index 50ed1ea4d..c1f20c642 100644 --- a/nml/actions/action3_callbacks.py +++ b/nml/actions/action3_callbacks.py @@ -55,7 +55,7 @@ def vehicle_length(value): 'cargo_capacity' : [ {'type': 'cb', 'num': 0x15, 'flag_bit': 3}, {'type': 'cb', 'num': 0x36, 'var10': 0x14, 'purchase': 'purchase_cargo_capacity'}], 'purchase_cargo_capacity' : {'type': 'cb', 'num': 0x36, 'var10': 0x14, 'purchase': 2}, - 'articulated_part' : {'type': 'cb', 'num': 0x16, 'flag_bit': 4, 'purchase': 1}, # Don't add separate purchase CB here + 'articulated_part' : {'type': 'cb', 'num': 0x16, 'flag_bit': 4, 'maxid': 0x3FFF, 'purchase': 1}, # Don't add separate purchase CB here 'can_attach_wagon' : {'type': 'cb', 'num': 0x1D}, 'speed' : {'type': 'cb', 'num': 0x36, 'var10': 0x09, 'purchase': 'purchase_speed'}, 'purchase_speed' : {'type': 'cb', 'num': 0x36, 'var10': 0x09, 'purchase': 2}, @@ -84,7 +84,7 @@ def vehicle_length(value): 'cargo_capacity' : [ {'type': 'cb', 'num': 0x15, 'flag_bit': 3}, {'type': 'cb', 'num': 0x36, 'var10': 0x0F, 'purchase': 'purchase_cargo_capacity'}], 'purchase_cargo_capacity' : {'type': 'cb', 'num': 0x36, 'var10': 0x0F, 'purchase': 2}, - 'articulated_part' : {'type': 'cb', 'num': 0x16, 'flag_bit': 4, 'purchase': 1}, # Don't add separate purchase CB here + 'articulated_part' : {'type': 'cb', 'num': 0x16, 'flag_bit': 4, 'maxid': 0x3FFF, 'purchase': 1}, # Don't add separate purchase CB here 'running_cost_factor' : {'type': 'cb', 'num': 0x36, 'var10': 0x09, 'purchase': 'purchase_running_cost_factor'}, 'purchase_running_cost_factor' : {'type': 'cb', 'num': 0x36, 'var10': 0x09, 'purchase': 2}, 'cost_factor' : {'type': 'cb', 'num': 0x36, 'var10': 0x11, 'purchase': 2},