diff --git a/src/lang/english.txt b/src/lang/english.txt index 3a4de4156c..04181e382c 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1400,6 +1400,8 @@ STR_CONFIG_SETTING_TIMETABLE_IN_TICKS :Show timetable STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Show travel times in time tables in game ticks instead of days STR_CONFIG_SETTING_TIMETABLE_SEPARATION :Use timetable to ensure vehicle separation: {STRING2} STR_CONFIG_SETTING_TIMETABLE_SEPARATION_HELPTEXT :Select whether to ensure separation of vehicles when using automatic timetables +STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE :Vehicle separation factor: {STRING2} +STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT :How much of the vehicle separation timetable change to apply at each step STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE :Show arrival and departure in timetables: {STRING2} STR_CONFIG_SETTING_TIMETABLE_SHOW_ARRIVAL_DEPARTURE_HELPTEXT :Display anticipated arrival and departure times in timetables STR_CONFIG_SETTING_QUICKGOTO :Quick creation of vehicle orders: {STRING2} diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 452f6b6fd2..1c3da570a7 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1628,6 +1628,7 @@ static SettingsContainer &GetSettingsTree() vehicles->Add(new SettingEntry("order.serviceathelipad")); vehicles->Add(new SettingEntry("order.timetable_automated")); vehicles->Add(new SettingEntry("order.timetable_separation")); + vehicles->Add(new SettingEntry("order.timetable_separation_rate")); } SettingsPage *limitations = main->Add(new SettingsPage(STR_CONFIG_SETTING_LIMITATIONS)); diff --git a/src/settings_type.h b/src/settings_type.h index b3eeae407f..7c3b34478d 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -440,6 +440,7 @@ struct OrderSettings { bool no_servicing_if_no_breakdowns; ///< don't send vehicles to depot when breakdowns are disabled bool timetable_automated; ///< whether to automatically manage timetables bool timetable_separation; ///< whether to perform automatic separation based on timetable + uint8 timetable_separation_rate; ///< percentage of timetable separation change to apply bool serviceathelipad; ///< service helicopters at helipads automatically (no need to send to depot) }; diff --git a/src/table/settings.ini b/src/table/settings.ini index d7c6d692a9..53efed2fe6 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -347,6 +347,20 @@ str = STR_CONFIG_SETTING_TIMETABLE_SEPARATION strhelp = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_HELPTEXT cat = SC_EXPERT +[SDT_VAR] +base = GameSettings +var = order.timetable_separation_rate +type = SLE_UINT8 +from = TIMESEP_SV +def = 100 +min = 0 +max = 100 +interval = 10 +str = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE +strhelp = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT +strval = STR_CONFIG_SETTING_PERCENTAGE +cat = SC_EXPERT + ; There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow ; these bigger values (21-255). Invalid values will fallback to english on use and (undefined string) in GUI. [SDT_OMANY] diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index 809a4149b0..3fddfbe6ac 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -548,8 +548,11 @@ void UpdateSeparationOrder(Vehicle *v_start) } int separation_ahead = SeparationBetween(v, v->AheadSeparation()); int separation_behind = SeparationBetween(v->BehindSeparation(), v); - v->lateness_counter = (separation_ahead - separation_behind) / 2; - if (separation_ahead == -1 || separation_behind == -1) v->lateness_counter = 0; + if (separation_ahead != -1 && separation_behind != -1) { + int new_lateness = (separation_ahead - separation_behind) / 2; + v->lateness_counter = (new_lateness * _settings_game.order.timetable_separation_rate + + v->lateness_counter * (100 - _settings_game.order.timetable_separation_rate)) / 100; + } v = v->AheadSeparation(); } while (v != v_start); }