Add a company setting to control auto-fill timetable rounding.

pull/8/head
Jonathan G Rennison 8 years ago
parent b43c08857b
commit ff5ee52b94

@ -1404,6 +1404,8 @@ STR_CONFIG_SETTING_TIMETABLE_SEPARATION_RATE :Auto timetable
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_TIMETABLE_AUTOFILL_ROUNDING_TICKS :Round up auto-filled timetable times to multiples of this many ticks: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_AUTOFILL_ROUNDING_TICKS_HELPTEXT :Timetable times adjusted by timetable automation are not rounded. A day at a a day length of 1 is 74 ticks.
STR_CONFIG_SETTING_QUICKGOTO :Quick creation of vehicle orders: {STRING2}
STR_CONFIG_SETTING_QUICKGOTO_HELPTEXT :Pre-select the 'goto cursor' when opening the orders window
STR_CONFIG_SETTING_DEFAULT_RAIL_TYPE :Default rail type (after new game/game load): {STRING2}

@ -1588,6 +1588,7 @@ static SettingsContainer &GetSettingsTree()
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("timetable_autofill_rounding"));
}
SettingsPage *accounting = main->Add(new SettingsPage(STR_CONFIG_SETTING_ACCOUNTING));

@ -541,6 +541,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 auto_timetable_separation_rate; ///< percentage of auto timetable separation change to apply
uint16 timetable_autofill_rounding; ///< round up timetable times to be a multiple of this number of ticks
};
/** All settings together for the game. */

@ -159,6 +159,21 @@ strval = STR_CONFIG_SETTING_PERCENTAGE
cat = SC_EXPERT
patxname = ""auto_timetable_separation_rate""
[SDT_VAR]
base = CompanySettings
var = timetable_autofill_rounding
type = SLE_UINT16
guiflags = SGF_PER_COMPANY
def = 74
min = 1
max = 1000
interval = 10
str = STR_CONFIG_SETTING_TIMETABLE_AUTOFILL_ROUNDING_TICKS
strhelp = STR_CONFIG_SETTING_TIMETABLE_AUTOFILL_ROUNDING_TICKS_HELPTEXT
strval = STR_JUST_INT
cat = SC_EXPERT
patxname = ""timetable_autofill_rounding""
[SDT_END]

@ -637,16 +637,18 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling)
/* Before modifying waiting times, check whether we want to preserve bigger ones. */
if (!real_current_order->IsType(OT_CONDITIONAL) &&
(travelling || time_taken > real_current_order->GetWaitTime() || remeasure_wait_time)) {
/* Round the time taken up to the nearest day, as this will avoid
* confusion for people who are timetabling in days, and can be
* adjusted later by people who aren't.
/* Round the time taken up to the nearest timetable rounding factor
* (default: day), as this will avoid confusion for people who are
* timetabling in days, and can be adjusted later by people who aren't.
* For trains/aircraft multiple movement cycles are done in one
* tick. This makes it possible to leave the station and process
* e.g. a depot order in the same tick, causing it to not fill
* the timetable entry like is done for road vehicles/ships.
* Thus always make sure at least one tick is used between the
* processing of different orders when filling the timetable. */
uint time_to_set = CeilDiv(max(time_taken, 1U), DAY_TICKS) * DAY_TICKS;
Company *owner = Company::GetIfValid(v->owner);
uint rounding_factor = owner ? owner->settings.timetable_autofill_rounding : DAY_TICKS;
uint time_to_set = CeilDiv(max(time_taken, 1U), rounding_factor) * rounding_factor;
if (travelling && (autofilling || !real_current_order->IsTravelTimetabled())) {
ChangeTimetable(v, v->cur_real_order_index, time_to_set, MTF_TRAVEL_TIME, autofilling);

Loading…
Cancel
Save