Skip to content

Commit

Permalink
Fix OpenTTD#147: Prevent rounding errors in tracktype speeds
Browse files Browse the repository at this point in the history
  • Loading branch information
FLHerne committed May 23, 2020
1 parent 17089b8 commit 13a330f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nml/actions/action0properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ def label_list(value, prop_num, description):
'railtype_flags' : {'size': 1, 'num': 0x10},
'curve_speed_multiplier' : {'size': 1, 'num': 0x11},
'station_graphics' : {'size': 1, 'num': 0x12},
'speed_limit' : {'size': 2, 'num': 0x14, 'unit_type': 'speed', 'unit_conversion': (5000, 1397)},
'speed_limit' : {'size': 2, 'num': 0x14, 'unit_type': 'speed', 'unit_conversion': (5000, 1397), 'adjust_value': lambda val, unit: ottd_display_speed(val, 1, unit)},
'acceleration_model' : {'size': 1, 'num': 0x15},
'requires_railtype_list' : {'custom_function': lambda x: label_list(x, 0x18, "Railtype")},
'introduces_railtype_list' : {'custom_function': lambda x: label_list(x, 0x19, "Railtype")},
Expand Down Expand Up @@ -1073,7 +1073,7 @@ def label_list(value, prop_num, description):
**common_tracktype_props,
'powered_roadtype_list' : {'custom_function': lambda x: label_list(x, 0x0F, "Roadtype")},
'roadtype_flags' : {'size': 1, 'num': 0x10},
'speed_limit' : {'size': 2, 'num': 0x14, 'unit_type': 'speed', 'unit_conversion': (10000, 1397)},
'speed_limit' : {'size': 2, 'num': 0x14, 'unit_type': 'speed', 'unit_conversion': (10000, 1397), 'adjust_value': lambda val, unit: ottd_display_speed(val, 2, unit)},
'requires_roadtype_list' : {'custom_function': lambda x: label_list(x, 0x18, "Roadtype")},
'introduces_roadtype_list' : {'custom_function': lambda x: label_list(x, 0x19, "Roadtype")},
'alternative_roadtype_list': {'custom_function': lambda x: label_list(x, 0x1D, "Roadtype")},
Expand All @@ -1087,7 +1087,7 @@ def label_list(value, prop_num, description):
**common_tracktype_props,
'powered_tramtype_list' : {'custom_function': lambda x: label_list(x, 0x0F, "Tramtype")},
'tramtype_flags' : {'size': 1, 'num': 0x10},
'speed_limit' : {'size': 2, 'num': 0x14, 'unit_type': 'speed', 'unit_conversion': (10000, 1397)},
'speed_limit' : {'size': 2, 'num': 0x14, 'unit_type': 'speed', 'unit_conversion': (10000, 1397), 'adjust_value': lambda val, unit: ottd_display_speed(val, 2, unit)},
'requires_tramtype_list' : {'custom_function': lambda x: label_list(x, 0x18, "Tramtype")},
'introduces_tramtype_list' : {'custom_function': lambda x: label_list(x, 0x19, "Tramtype")},
'alternative_tramtype_list': {'custom_function': lambda x: label_list(x, 0x1D, "Tramtype")},
Expand Down
7 changes: 7 additions & 0 deletions regression/034_roadtypes.nml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

item(FEAT_ROADTYPES, regression_road, 0) {
property {
label: "ROAD";
speed_limit: 130km/h;
}
}
Binary file added regression/expected/034_roadtypes.grf
Binary file not shown.
11 changes: 11 additions & 0 deletions regression/expected/034_roadtypes.nfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Automatically generated by GRFCODEC. Do not modify!
// (Info version 32)
// Escapes: 2+ 2- 2< 2> 2u< 2u> 2/ 2% 2u/ 2u% 2* 2& 2| 2^ 2sto = 2s 2rst = 2r 2psto 2ror = 2rot 2cmp 2ucmp 2<< 2u>> 2>>
// Escapes: 71 70 7= 7! 7< 7> 7G 7g 7gG 7GG 7gg 7c 7C
// 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 * 15 00 12 \b2 01 FF \wx0000
08 "ROAD"
14 \wx0104

0 comments on commit 13a330f

Please sign in to comment.