Commits

Anonymous committed 9397230

Codechange: Split 'function' in the varaction2 variable info list, in 'value_function' (which affects the value seen by the NML user) and 'param_function' (which affects the handling of 60+x parameters).

Comments (0)

Files changed (2)

nml/actions/action2var.py

 
 def parse_var(info, pos):
     res = expression.Variable(expression.ConstantNumeric(info['var']), expression.ConstantNumeric(info['start']), expression.ConstantNumeric((1 << info['size']) - 1), None, pos)
-    if 'function' in info:
-        return info['function'](res, info)
+    if 'value_function' in info:
+        return info['value_function'](res, info)
     return res
 
 
 def parse_60x_var(name, args, pos, info):
-    if 'function' in info:
+    if 'param_function' in info:
         # Special function to extract parameters if there is more than one
-        param, extra_params = info['function'](name, args, pos, info)
+        param, extra_params = info['param_function'](name, args, pos, info)
     else:
         # Default function to extract parameters
         param, extra_params = action2var_variables.default_60xvar(name, args, pos, info)

nml/actions/action2var_variables.py

 varact2vars_vehicles = {
     'position_in_consist' : {'var': 0x40, 'start': 0, 'size': 8},
     'position_in_consist_from_end' : {'var': 0x40, 'start': 8, 'size': 8},
-    'num_vehs_in_consist' : {'var': 0x40, 'start': 16, 'size': 8, 'function': func_add_constant(1)},
+    'num_vehs_in_consist' : {'var': 0x40, 'start': 16, 'size': 8, 'value_function': func_add_constant(1)},
     'position_in_vehid_chain' : {'var': 0x41, 'start': 0, 'size': 8},
     'position_in_vehid_chain_from_end' : {'var': 0x41, 'start': 8, 'size': 8},
-    'num_vehs_in_vehid_chain' : {'var': 0x41, 'start': 16, 'size': 8, 'function': func_add_constant(1)},
+    'num_vehs_in_vehid_chain' : {'var': 0x41, 'start': 16, 'size': 8, 'value_function': func_add_constant(1)},
     'cargo_classes_in_consist' : {'var': 0x42, 'start': 0, 'size': 8},
     'most_common_refit' : {'var': 0x42, 'start': 16, 'size': 8},
     'bitmask_consist_info' : {'var': 0x42, 'start': 24, 'size': 8},
     'company_colour2' : {'var': 0x43, 'start': 28, 'size': 4},
     'aircraft_height' : {'var': 0x44, 'start': 8, 'size': 8},
     'airport_type' : {'var': 0x44, 'start': 0, 'size': 8},
-    'curv_info_prev_cur' : {'var': 0x45, 'start': 0, 'size': 4, 'function': signextend},
-    'curv_info_cur_next' : {'var': 0x45, 'start': 8, 'size': 4, 'function': signextend},
-    'curv_info_prev_next' : {'var': 0x45, 'start': 16, 'size': 4, 'function': signextend},
-    'curv_info' : {'var': 0x45, 'start': 0, 'size': 12, 'function': lambda var, info: expression.BinOp(nmlop.AND, var, expression.ConstantNumeric(0x0F0F, var.pos), var.pos).reduce()},
+    'curv_info_prev_cur' : {'var': 0x45, 'start': 0, 'size': 4, 'value_function': signextend},
+    'curv_info_cur_next' : {'var': 0x45, 'start': 8, 'size': 4, 'value_function': signextend},
+    'curv_info_prev_next' : {'var': 0x45, 'start': 16, 'size': 4, 'value_function': signextend},
+    'curv_info' : {'var': 0x45, 'start': 0, 'size': 12, 'value_function': lambda var, info: expression.BinOp(nmlop.AND, var, expression.ConstantNumeric(0x0F0F, var.pos), var.pos).reduce()},
     'motion_counter' : {'var': 0x46, 'start': 8, 'size': 4},
     'cargo_type_in_veh' : {'var': 0x47, 'start': 0, 'size': 8},
     'cargo_unit_weight' : {'var': 0x47, 'start': 8, 'size': 8},
     'vehicle_is_hidden' : {'var': 0xB2, 'start': 0, 'size': 1},
     'vehicle_is_stopped' : {'var': 0xB2, 'start': 1, 'size': 1},
     'vehicle_is_crashed' : {'var': 0xB2, 'start': 7, 'size': 1},
-    'vehicle_is_broken' : {'var': 0xCB, 'start': 0, 'size': 8, 'function': lambda var, info: expression.BinOp(nmlop.CMP_EQ, var, expression.ConstantNumeric(1, var.pos), var.pos)},
+    'vehicle_is_broken' : {'var': 0xCB, 'start': 0, 'size': 8, 'value_function': lambda var, info: expression.BinOp(nmlop.CMP_EQ, var, expression.ConstantNumeric(1, var.pos), var.pos)},
     'date_of_last_service' : {'var': 0x4B, 'start': 0, 'size': 32},
     'breakdowns_since_last_service' : {'var': 0xCA, 'start': 0, 'size': 8},
-    'reliability' : {'var': 0xCE, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 101, 0x10000)},
+    'reliability' : {'var': 0xCE, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 101, 0x10000)},
     'age_in_days' : {'var': 0xC0, 'start': 0, 'size': 16},
     'max_age_in_days' : {'var': 0xC2, 'start': 0, 'size': 16},
 }
 varact2vars_trains = {
     #0x4786 / 0x10000 is an approximation of 3.5790976, the conversion factor
     #for train speed
-    'max_speed'           : {'var': 0x98, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x4786, 0x10000)},
-    'current_speed'       : {'var': 0xB4, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x4786, 0x10000)},
-    'current_max_speed'   : {'var': 0x4C, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x4786, 0x10000)},
+    'max_speed'           : {'var': 0x98, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x4786, 0x10000)},
+    'current_speed'       : {'var': 0xB4, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x4786, 0x10000)},
+    'current_max_speed'   : {'var': 0x4C, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x4786, 0x10000)},
     'vehicle_is_in_depot' : {'var': 0xE2, 'start': 7, 'size': 1}
 }
 varact2vars_trains.update(varact2vars_vehicles)
 varact2vars_roadvehs = {
     #0x23C3 / 0x10000 is an approximation of 7.1581952, the conversion factor
     #for road vehicle speed
-    'max_speed'           : {'var': 0x98, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
-    'current_speed'       : {'var': 0xB4, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
-    'current_max_speed'   : {'var': 0x4C, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
-    'vehicle_is_in_depot' : {'var': 0xE2, 'start': 0, 'size': 8, 'function': lambda var, info: expression.BinOp(nmlop.CMP_EQ, var, expression.ConstantNumeric(0xFE, var.pos))},
+    'max_speed'           : {'var': 0x98, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
+    'current_speed'       : {'var': 0xB4, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
+    'current_max_speed'   : {'var': 0x4C, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
+    'vehicle_is_in_depot' : {'var': 0xE2, 'start': 0, 'size': 8, 'value_function': lambda var, info: expression.BinOp(nmlop.CMP_EQ, var, expression.ConstantNumeric(0xFE, var.pos))},
 }
 varact2vars_roadvehs.update(varact2vars_vehicles)
 
 varact2vars_ships = {
     #0x23C3 / 0x10000 is an approximation of 7.1581952, the conversion factor
     #for ship speed
-    'max_speed'           : {'var': 0x98, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
-    'current_speed'       : {'var': 0xB4, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
-    'current_max_speed'   : {'var': 0x4C, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
+    'max_speed'           : {'var': 0x98, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
+    'current_speed'       : {'var': 0xB4, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
+    'current_max_speed'   : {'var': 0x4C, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x23C3, 0x10000)},
     'vehicle_is_in_depot' : {'var': 0xE2, 'start': 7, 'size': 1}
 }
 varact2vars_ships.update(varact2vars_vehicles)
     #0x3939 / 0x1000 is an approximation of 0.279617, the conversion factor
     #Note that the denominator has one less zero here!
     #for aircraft speed
-    'max_speed'           : {'var': 0x98, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x3939, 0x1000)},
-    'current_speed'       : {'var': 0xB4, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x3939, 0x1000)},
-    'current_max_speed'   : {'var': 0x4C, 'start': 0, 'size': 16, 'function': lambda var, info: muldiv(var, 0x3939, 0x1000)},
-    'vehicle_is_in_depot' : {'var': 0xE6, 'start': 0, 'size': 8, 'function': lambda var, info: expression.BinOp(nmlop.CMP_EQ, var, expression.ConstantNumeric(0, var.pos))},
+    'max_speed'           : {'var': 0x98, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x3939, 0x1000)},
+    'current_speed'       : {'var': 0xB4, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x3939, 0x1000)},
+    'current_max_speed'   : {'var': 0x4C, 'start': 0, 'size': 16, 'value_function': lambda var, info: muldiv(var, 0x3939, 0x1000)},
+    'vehicle_is_in_depot' : {'var': 0xE6, 'start': 0, 'size': 8, 'value_function': lambda var, info: expression.BinOp(nmlop.CMP_EQ, var, expression.ConstantNumeric(0, var.pos))},
 }
 varact2vars_aircraft.update(varact2vars_vehicles)
 
     return tile_offset(name, args, pos, info, 0, 15)
 
 varact2vars60x_industrytiles = {
-    'nearby_tile_slope'            : {'var': 0x60, 'start':  0, 'size':  5, 'function': signed_tile_offset},
-    'nearby_tile_is_same_industry' : {'var': 0x60, 'start':  8, 'size':  1, 'function': signed_tile_offset},
-    'nearby_tile_is_water'         : {'var': 0x60, 'start':  9, 'size':  1, 'function': signed_tile_offset},
-    'nearby_tile_terrain_type'     : {'var': 0x60, 'start': 10, 'size':  3, 'function': signed_tile_offset},
-    'nearby_tile_water_class'      : {'var': 0x60, 'start': 13, 'size':  2, 'function': signed_tile_offset},
-    'nearby_tile_height'           : {'var': 0x60, 'start': 16, 'size':  8, 'function': signed_tile_offset},
-    'nearby_tile_class'            : {'var': 0x60, 'start': 24, 'size':  4, 'function': signed_tile_offset},
-    'nearby_tile_animation_frame'  : {'var': 0x61, 'start':  0, 'size':  8, 'function': signed_tile_offset},
-    'nearby_tile_industrytile_id'  : {'var': 0x62, 'start':  0, 'size': 16, 'function': signed_tile_offset},
+    'nearby_tile_slope'            : {'var': 0x60, 'start':  0, 'size':  5, 'param_function': signed_tile_offset},
+    'nearby_tile_is_same_industry' : {'var': 0x60, 'start':  8, 'size':  1, 'param_function': signed_tile_offset},
+    'nearby_tile_is_water'         : {'var': 0x60, 'start':  9, 'size':  1, 'param_function': signed_tile_offset},
+    'nearby_tile_terrain_type'     : {'var': 0x60, 'start': 10, 'size':  3, 'param_function': signed_tile_offset},
+    'nearby_tile_water_class'      : {'var': 0x60, 'start': 13, 'size':  2, 'param_function': signed_tile_offset},
+    'nearby_tile_height'           : {'var': 0x60, 'start': 16, 'size':  8, 'param_function': signed_tile_offset},
+    'nearby_tile_class'            : {'var': 0x60, 'start': 24, 'size':  4, 'param_function': signed_tile_offset},
+    'nearby_tile_animation_frame'  : {'var': 0x61, 'start':  0, 'size':  8, 'param_function': signed_tile_offset},
+    'nearby_tile_industrytile_id'  : {'var': 0x62, 'start':  0, 'size': 16, 'param_function': signed_tile_offset},
 }
 
 varact2vars_industries = {
     'produced_this_month_2' : {'var': 0x96, 'start': 0, 'size': 16},
     'transported_this_month_1' : {'var': 0x98, 'start': 0, 'size': 16},
     'transported_this_month_2' : {'var': 0x9A, 'start': 0, 'size': 16},
-    'transported_last_month_pct_1' : {'var': 0x9C, 'start': 0, 'size': 8, 'function': lambda var, info: muldiv(var, 101, 256)},
-    'transported_last_month_pct_2' : {'var': 0x9D, 'start': 0, 'size': 8, 'function': lambda var, info: muldiv(var, 101, 256)},
+    'transported_last_month_pct_1' : {'var': 0x9C, 'start': 0, 'size': 8, 'value_function': lambda var, info: muldiv(var, 101, 256)},
+    'transported_last_month_pct_2' : {'var': 0x9D, 'start': 0, 'size': 8, 'value_function': lambda var, info: muldiv(var, 101, 256)},
     'produced_last_month_1' : {'var': 0x9E, 'start': 0, 'size': 16},
     'produced_last_month_2' : {'var': 0xA0, 'start': 0, 'size': 16},
     'transported_last_month_1' : {'var': 0xA2, 'start': 0, 'size': 16},
     'colour' : {'var': 0xA8, 'start': 0, 'size': 8},
     'counter' : {'var': 0xAA, 'start': 0, 'size': 16},
     'build_type' : {'var': 0xB3, 'start': 0, 'size': 2},
-    'last_accept_date' : {'var': 0xB4, 'start':0, 'size': 16, 'function': func_add_constant(701265)}
+    'last_accept_date' : {'var': 0xB4, 'start':0, 'size': 16, 'value_function': func_add_constant(701265)}
 }
 
 def industry_count(name, args, pos, info):
     return (args[0], extra_params)
 
 varact2vars60x_industries = {
-    'nearby_tile_industry_tile_id' : { 'var': 0x60, 'start':  0, 'size': 16, 'function': unsigned_tile_offset },
-    'nearby_tile_random_bits'      : { 'var': 0x61, 'start':  0, 'size':  8, 'function': unsigned_tile_offset },
-    'nearby_tile_slope'            : { 'var': 0x62, 'start':  0, 'size':  5, 'function': unsigned_tile_offset },
-    'nearby_tile_is_water'         : { 'var': 0x62, 'start':  9, 'size':  1, 'function': unsigned_tile_offset },
-    'nearby_tile_terrain_type'     : { 'var': 0x62, 'start': 10, 'size':  3, 'function': unsigned_tile_offset },
-    'nearby_tile_water_class'      : { 'var': 0x62, 'start': 13, 'size':  2, 'function': unsigned_tile_offset },
-    'nearby_tile_height'           : { 'var': 0x62, 'start': 16, 'size':  8, 'function': unsigned_tile_offset },
-    'nearby_tile_class'            : { 'var': 0x62, 'start': 24, 'size':  4, 'function': unsigned_tile_offset },
-    'nearby_tile_animation_frame'  : { 'var': 0x63, 'start':  0, 'size':  8, 'function': unsigned_tile_offset },
-    'town_manhattan_dist'          : { 'var': 0x65, 'start':  0, 'size': 16, 'function': signed_tile_offset },
-    'town_zone'                    : { 'var': 0x65, 'start': 16, 'size':  8, 'function': signed_tile_offset },
-    'town_euclidean_dist'          : { 'var': 0x66, 'start':  0, 'size': 32, 'function': signed_tile_offset },
-    'industry_count'               : { 'var': 0x67, 'start': 16, 'size':  8, 'function': industry_count },
-    'industry_distance'            : { 'var': 0x67, 'start':  0, 'size': 16, 'function': industry_count },
-    'industry_layout_count'        : { 'var': 0x68, 'start': 16, 'size':  8, 'function': industry_layout_count },
-    'industry_layout_distance'     : { 'var': 0x68, 'start':  0, 'size': 16, 'function': industry_layout_count },
-    'industry_town_count'          : { 'var': 0x68, 'start': 16, 'size':  8, 'function': industry_town_count },
+    'nearby_tile_industry_tile_id' : { 'var': 0x60, 'start':  0, 'size': 16, 'param_function': unsigned_tile_offset },
+    'nearby_tile_random_bits'      : { 'var': 0x61, 'start':  0, 'size':  8, 'param_function': unsigned_tile_offset },
+    'nearby_tile_slope'            : { 'var': 0x62, 'start':  0, 'size':  5, 'param_function': unsigned_tile_offset },
+    'nearby_tile_is_water'         : { 'var': 0x62, 'start':  9, 'size':  1, 'param_function': unsigned_tile_offset },
+    'nearby_tile_terrain_type'     : { 'var': 0x62, 'start': 10, 'size':  3, 'param_function': unsigned_tile_offset },
+    'nearby_tile_water_class'      : { 'var': 0x62, 'start': 13, 'size':  2, 'param_function': unsigned_tile_offset },
+    'nearby_tile_height'           : { 'var': 0x62, 'start': 16, 'size':  8, 'param_function': unsigned_tile_offset },
+    'nearby_tile_class'            : { 'var': 0x62, 'start': 24, 'size':  4, 'param_function': unsigned_tile_offset },
+    'nearby_tile_animation_frame'  : { 'var': 0x63, 'start':  0, 'size':  8, 'param_function': unsigned_tile_offset },
+    'town_manhattan_dist'          : { 'var': 0x65, 'start':  0, 'size': 16, 'param_function': signed_tile_offset },
+    'town_zone'                    : { 'var': 0x65, 'start': 16, 'size':  8, 'param_function': signed_tile_offset },
+    'town_euclidean_dist'          : { 'var': 0x66, 'start':  0, 'size': 32, 'param_function': signed_tile_offset },
+    'industry_count'               : { 'var': 0x67, 'start': 16, 'size':  8, 'param_function': industry_count },
+    'industry_distance'            : { 'var': 0x67, 'start':  0, 'size': 16, 'param_function': industry_count },
+    'industry_layout_count'        : { 'var': 0x68, 'start': 16, 'size':  8, 'param_function': industry_layout_count },
+    'industry_layout_distance'     : { 'var': 0x68, 'start':  0, 'size': 16, 'param_function': industry_layout_count },
+    'industry_town_count'          : { 'var': 0x68, 'start': 16, 'size':  8, 'param_function': industry_town_count },
 }
 
 varact2vars_airports = {
 }
 
 varact2vars60x_objects = {
-    'nearby_tile_object_type'      : { 'var' : 0x60, 'start':  0, 'size': 16, 'function': signed_tile_offset },
+    'nearby_tile_object_type'      : { 'var' : 0x60, 'start':  0, 'size': 16, 'param_function': signed_tile_offset },
 
-    'nearby_tile_random_bits'      : { 'var' : 0x61, 'start':  0, 'size':  8, 'function': signed_tile_offset },
+    'nearby_tile_random_bits'      : { 'var' : 0x61, 'start':  0, 'size':  8, 'param_function': signed_tile_offset },
 
-    'nearby_tile_slope'            : { 'var' : 0x62, 'start':  0, 'size':  5, 'function': signed_tile_offset },
-    'nearby_tile_is_same_object'   : { 'var' : 0x62, 'start':  8, 'size':  1, 'function': signed_tile_offset },
-    'nearby_tile_is_water'         : { 'var' : 0x62, 'start':  9, 'size':  1, 'function': signed_tile_offset },
-    'nearby_tile_terrain_type'     : { 'var' : 0x62, 'start': 10, 'size':  3, 'function': signed_tile_offset },
-    'nearby_tile_water_class'      : { 'var' : 0x62, 'start': 13, 'size':  2, 'function': signed_tile_offset },
-    'nearby_tile_height'           : { 'var' : 0x62, 'start': 16, 'size':  8, 'function': signed_tile_offset },
-    'nearby_tile_class'            : { 'var' : 0x62, 'start': 24, 'size':  4, 'function': signed_tile_offset },
+    'nearby_tile_slope'            : { 'var' : 0x62, 'start':  0, 'size':  5, 'param_function': signed_tile_offset },
+    'nearby_tile_is_same_object'   : { 'var' : 0x62, 'start':  8, 'size':  1, 'param_function': signed_tile_offset },
+    'nearby_tile_is_water'         : { 'var' : 0x62, 'start':  9, 'size':  1, 'param_function': signed_tile_offset },
+    'nearby_tile_terrain_type'     : { 'var' : 0x62, 'start': 10, 'size':  3, 'param_function': signed_tile_offset },
+    'nearby_tile_water_class'      : { 'var' : 0x62, 'start': 13, 'size':  2, 'param_function': signed_tile_offset },
+    'nearby_tile_height'           : { 'var' : 0x62, 'start': 16, 'size':  8, 'param_function': signed_tile_offset },
+    'nearby_tile_class'            : { 'var' : 0x62, 'start': 24, 'size':  4, 'param_function': signed_tile_offset },
 
-    'nearby_tile_animation_frame'  : { 'var' : 0x63, 'start':  0, 'size':  8, 'function': signed_tile_offset },
+    'nearby_tile_animation_frame'  : { 'var' : 0x63, 'start':  0, 'size':  8, 'param_function': signed_tile_offset },
 
-    'object_count'                 : { 'var' : 0x64, 'start': 16, 'size':  8, 'function': industry_count },
-    'object_distance'              : { 'var' : 0x64, 'start':  0, 'size': 16, 'function': industry_count },
+    'object_count'                 : { 'var' : 0x64, 'start': 16, 'size':  8, 'param_function': industry_count },
+    'object_distance'              : { 'var' : 0x64, 'start':  0, 'size': 16, 'param_function': industry_count },
 }
 
 varact2vars_railtype = {
 }
 
 varact2vars60x_airporttiles = {
-    'nearby_tile_slope'            : {'var': 0x60, 'start':  0, 'size':  5, 'function': signed_tile_offset},
-    'nearby_tile_is_same_airport'  : {'var': 0x60, 'start':  8, 'size':  1, 'function': signed_tile_offset},
-    'nearby_tile_is_water'         : {'var': 0x60, 'start':  9, 'size':  1, 'function': signed_tile_offset},
-    'nearby_tile_terrain_type'     : {'var': 0x60, 'start': 10, 'size':  3, 'function': signed_tile_offset},
-    'nearby_tile_water_class'      : {'var': 0x60, 'start': 13, 'size':  2, 'function': signed_tile_offset},
-    'nearby_tile_height'           : {'var': 0x60, 'start': 16, 'size':  8, 'function': signed_tile_offset},
-    'nearby_tile_class'            : {'var': 0x60, 'start': 24, 'size':  4, 'function': signed_tile_offset},
-    'nearby_tile_animation_frame'  : {'var': 0x61, 'start':  0, 'size':  8, 'function': signed_tile_offset},
-    'nearby_tile_airporttile_id'   : {'var': 0x62, 'start':  0, 'size': 16, 'function': signed_tile_offset},
+    'nearby_tile_slope'            : {'var': 0x60, 'start':  0, 'size':  5, 'param_function': signed_tile_offset},
+    'nearby_tile_is_same_airport'  : {'var': 0x60, 'start':  8, 'size':  1, 'param_function': signed_tile_offset},
+    'nearby_tile_is_water'         : {'var': 0x60, 'start':  9, 'size':  1, 'param_function': signed_tile_offset},
+    'nearby_tile_terrain_type'     : {'var': 0x60, 'start': 10, 'size':  3, 'param_function': signed_tile_offset},
+    'nearby_tile_water_class'      : {'var': 0x60, 'start': 13, 'size':  2, 'param_function': signed_tile_offset},
+    'nearby_tile_height'           : {'var': 0x60, 'start': 16, 'size':  8, 'param_function': signed_tile_offset},
+    'nearby_tile_class'            : {'var': 0x60, 'start': 24, 'size':  4, 'param_function': signed_tile_offset},
+    'nearby_tile_animation_frame'  : {'var': 0x61, 'start':  0, 'size':  8, 'param_function': signed_tile_offset},
+    'nearby_tile_airporttile_id'   : {'var': 0x62, 'start':  0, 'size': 16, 'param_function': signed_tile_offset},
 }
 
 varact2vars_towns = {
     'is_city'                        : {'var': 0x40, 'start': 0, 'size': 1},
-    'cities_enabled'                 : {'var': 0x40, 'start': 1, 'size': 1, 'function': lambda var, info: expression.Not(var, var.pos)},
+    'cities_enabled'                 : {'var': 0x40, 'start': 1, 'size': 1, 'value_function': lambda var, info: expression.Not(var, var.pos)},
     'population'                     : {'var': 0x82, 'start': 0, 'size': 16},
     'has_church'                     : {'var': 0x92, 'start': 1, 'size': 1},
     'has_stadium'                    : {'var': 0x92, 'start': 2, 'size': 1},
     'town_zone_3_radius_square'      : {'var': 0x9A, 'start': 0, 'size': 16},
     'town_zone_4_radius_square'      : {'var': 0x9C, 'start': 0, 'size': 16},
     'num_houses'                     : {'var': 0xB6, 'start': 0, 'size': 16},
-    'percent_transported_passengers' : {'var': 0xCA, 'start': 0, 'size': 8, 'function': lambda var, info: muldiv(var, 101, 256)},
-    'percent_transported_mail'       : {'var': 0xCB, 'start': 0, 'size': 8, 'function': lambda var, info: muldiv(var, 101, 256)},
+    'percent_transported_passengers' : {'var': 0xCA, 'start': 0, 'size': 8, 'value_function': lambda var, info: muldiv(var, 101, 256)},
+    'percent_transported_mail'       : {'var': 0xCB, 'start': 0, 'size': 8, 'value_function': lambda var, info: muldiv(var, 101, 256)},
 }