diff --git a/src/lang/english.txt b/src/lang/english.txt index f907a1812d..3268ca2f47 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1453,8 +1453,8 @@ STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY :Enter timetable STR_CONFIG_SETTING_TIMETABLE_START_TEXT_ENTRY_HELPTEXT :Select whether timetable start times may be entered as text if time is being shown in minutes 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 ce70c92417..64926ecad0 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -313,7 +313,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 @@ -336,7 +336,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 @@ -493,6 +493,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 7c6240176c..2b133e7f90 100644 --- a/src/saveload/extended_ver_sl.cpp +++ b/src/saveload/extended_ver_sl.cpp @@ -56,7 +56,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { { XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 1, 1, "signal_tunnel_bridge", NULL, NULL, NULL }, { XSLFI_IMPROVED_BREAKDOWNS, XSCF_NULL, 1, 1, "improved_breakdowns", NULL, NULL, NULL }, { XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL }, - { 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_VEHICLE_REPAIR_COST, XSCF_NULL, 1, 1, "vehicle_repair_cost", NULL, NULL, NULL }, { XSLFI_ENH_VIEWPORT_PLANS, XSCF_IGNORABLE_ALL, 1, 1, "enh_viewport_plans", NULL, NULL, "PLAN,PLLN" }, { XSLFI_INFRA_SHARING, XSCF_NULL, 1, 1, "infra_sharing", NULL, NULL, NULL }, diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 687e630b13..436eab9491 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1635,6 +1635,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")); company->Add(new SettingEntry("order_occupancy_smoothness")); } @@ -1679,7 +1680,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")); vehicles->Add(new SettingEntry("vehicle.adjacent_crossings")); } diff --git a/src/settings_type.h b/src/settings_type.h index 616a426408..b4d81f0e70 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -479,10 +479,10 @@ 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_occupancy_smoothness; ///< moved to company settings: percentage smoothness of occupancy measurement changes + uint8 old_timetable_separation_rate; ///< moved to company settings: percentage of timetable separation change to apply }; /** Settings related to vehicles. */ @@ -590,6 +590,7 @@ struct CompanySettings { bool renew_keep_length; ///< sell some wagons if after autoreplace the train is longer than before VehicleDefaultSettings vehicle; ///< default settings for vehicles uint8 order_occupancy_smoothness; ///< percentage smoothness of occupancy measurement changes + 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 c52f921af7..7852cc9bf3 100644 --- a/src/table/company_settings.ini +++ b/src/table/company_settings.ini @@ -148,6 +148,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_VAR] base = CompanySettings diff --git a/src/table/settings.ini b/src/table/settings.ini index 2ebf175066..86e67babb1 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -367,7 +367,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 @@ -377,7 +377,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 c2d800e28d..38218b8e24 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 "settings_type.h" @@ -558,9 +559,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);