diff --git a/src/lang/english.txt b/src/lang/english.txt index 697846856c..349471435b 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1400,8 +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_SEPARATION_RATE :Auto timetable vehicle separation factor: {STRING2} +STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT :How much of the vehicle separation auto 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/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 93c3cc0254..94b7952a9c 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -312,7 +312,7 @@ static const SaveLoad _company_settings_desc[] = { SLE_CONDVAR(Company, settings.vehicle.servint_roadveh, SLE_UINT16, 120, SL_MAX_VERSION), SLE_CONDVAR(Company, settings.vehicle.servint_aircraft, SLE_UINT16, 120, SL_MAX_VERSION), SLE_CONDVAR(Company, settings.vehicle.servint_ships, SLE_UINT16, 120, SL_MAX_VERSION), - SLE_CONDVAR_X(Company, settings.vehicle.auto_timetable_by_default, SLE_BOOL, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 2)), + SLE_CONDVAR_X(Company, settings.vehicle.auto_timetable_by_default, SLE_BOOL, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 2, 2)), SLE_CONDNULL(63, 2, 143), // old reserved space @@ -335,7 +335,7 @@ static const SaveLoad _company_settings_skip_desc[] = { SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_roadveh SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_aircraft SLE_CONDNULL(2, 120, SL_MAX_VERSION), // settings.vehicle.servint_ships - SLE_CONDNULL_X(1, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 2)), // settings.vehicle.auto_timetable_by_default + SLE_CONDNULL_X(1, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 2, 2)), // settings.vehicle.auto_timetable_by_default SLE_CONDNULL(63, 2, 143), // old reserved space @@ -492,6 +492,11 @@ static void Load_PLYR() SetDefaultCompanySettings(c->index); SaveLoad_PLYR(c); _company_colours[index] = (Colours)c->colour; + + // setting moved from game settings to company settings + if (SlXvIsFeaturePresent(XSLFI_AUTO_TIMETABLE, 1, 2)) { + c->settings.auto_timetable_separation_rate = _settings_game.order.old_timetable_separation_rate; + } } } diff --git a/src/saveload/extended_ver_sl.cpp b/src/saveload/extended_ver_sl.cpp index 11eddbd807..914f2e7e81 100644 --- a/src/saveload/extended_ver_sl.cpp +++ b/src/saveload/extended_ver_sl.cpp @@ -45,7 +45,7 @@ std::vector _sl_xv_discardable_chunk_ids; ///< list of chunks static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version os SLXI chunk const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { - { XSLFI_AUTO_TIMETABLE, XSCF_NULL, 2, 2, "auto_timetables", NULL, NULL, NULL }, + { XSLFI_AUTO_TIMETABLE, XSCF_NULL, 3, 3, "auto_timetables", NULL, NULL, NULL }, { XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker }; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 7dc6174dea..44fbda382b 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1587,6 +1587,7 @@ static SettingsContainer &GetSettingsTree() company->Add(new SettingEntry("vehicle.servint_ships")); company->Add(new SettingEntry("vehicle.servint_aircraft")); company->Add(new SettingEntry("vehicle.auto_timetable_by_default")); + company->Add(new SettingEntry("auto_timetable_separation_rate")); } SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING)); @@ -1629,7 +1630,6 @@ 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 a335c992a3..cc55dcf6c9 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -440,8 +440,9 @@ 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) + + uint8 old_timetable_separation_rate; ///< moved to company settings: percentage of timetable separation change to apply }; /** Settings related to vehicles. */ @@ -539,6 +540,7 @@ struct CompanySettings { uint32 engine_renew_money; ///< minimum amount of money before autorenew is used bool renew_keep_length; ///< sell some wagons if after autoreplace the train is longer than before VehicleDefaultSettings vehicle; ///< default settings for vehicles + uint8 auto_timetable_separation_rate; ///< percentage of auto timetable separation change to apply }; /** All settings together for the game. */ diff --git a/src/table/company_settings.ini b/src/table/company_settings.ini index edabaaa148..41adc867a7 100644 --- a/src/table/company_settings.ini +++ b/src/table/company_settings.ini @@ -142,6 +142,22 @@ guiflags = SGF_PER_COMPANY def = false str = STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT strhelp = STR_CONFIG_SETTING_AUTO_TIMETABLE_BY_DEFAULT_HELPTEXT +patxname = ""vehicle.auto_timetable_by_default"" + +[SDT_VAR] +base = CompanySettings +var = auto_timetable_separation_rate +type = SLE_UINT8 +guiflags = SGF_PER_COMPANY +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 +patxname = ""auto_timetable_separation_rate"" [SDT_END] diff --git a/src/table/settings.ini b/src/table/settings.ini index 05bdbc05e6..175ed1e926 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -353,7 +353,7 @@ patxname = ""auto_timetables.order.timetable_separation"" [SDT_VAR] base = GameSettings -var = order.timetable_separation_rate +var = order.old_timetable_separation_rate type = SLE_UINT8 def = 100 min = 0 @@ -363,7 +363,7 @@ str = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE strhelp = STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE_HELPTEXT strval = STR_CONFIG_SETTING_PERCENTAGE cat = SC_EXPERT -extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE) +extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_AUTO_TIMETABLE, 1, 2) patxname = ""auto_timetables.order.timetable_separation_rate"" ; There are only 21 predefined town_name values (0-20), but you can have more with newgrf action F so allow diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index 3fddfbe6ac..8b29fea630 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -17,6 +17,7 @@ #include "vehicle_base.h" #include "settings_type.h" #include "cmd_helper.h" +#include "company_base.h" #include "core/sort_func.hpp" #include "table/strings.h" @@ -549,9 +550,11 @@ void UpdateSeparationOrder(Vehicle *v_start) int separation_ahead = SeparationBetween(v, v->AheadSeparation()); int separation_behind = SeparationBetween(v->BehindSeparation(), v); if (separation_ahead != -1 && separation_behind != -1) { + Company *owner = Company::GetIfValid(v->owner); + uint8 timetable_separation_rate = owner ? owner->settings.auto_timetable_separation_rate : 100; 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->lateness_counter = (new_lateness * timetable_separation_rate + + v->lateness_counter * (100 - timetable_separation_rate)) / 100; } v = v->AheadSeparation(); } while (v != v_start);