diff --git a/src/order_func.h b/src/order_func.h --- a/src/order_func.h +++ b/src/order_func.h @@ -26,10 +26,16 @@ uint GetOrderDistance(const Order *prev, void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int y, bool selected, bool timetable, int left, int middle, int right); -#define MIN_SERVINT_PERCENT 5 -#define MAX_SERVINT_PERCENT 90 -#define MIN_SERVINT_DAYS 30 -#define MAX_SERVINT_DAYS 800 +static const uint DEF_SERVINT_DAYS_TRAINS = 150; +static const uint DEF_SERVINT_DAYS_ROADVEH = 150; +static const uint DEF_SERVINT_DAYS_AIRCRAFT = 100; +static const uint DEF_SERVINT_DAYS_SHIPS = 360; +static const uint MIN_SERVINT_DAYS = 30; +static const uint MAX_SERVINT_DAYS = 800; + +static const uint DEF_SERVINT_PERCENT = 50; +static const uint MIN_SERVINT_PERCENT = 5; +static const uint MAX_SERVINT_PERCENT = 90; uint16 GetServiceIntervalClamped(uint interval, bool ispercent); diff --git a/src/settings_table.cpp b/src/settings_table.cpp --- a/src/settings_table.cpp +++ b/src/settings_table.cpp @@ -127,7 +127,10 @@ static void UpdateConsists(int32 new_val InvalidateWindowClassesData(WC_BUILD_VEHICLE, 0); } -/* Check service intervals of vehicles, newvalue is value of % or day based servicing */ +/** + * Check and update if needed all vehicle service intervals. + * @param new_value Contains 0 if service intervals are in days, otherwise intervals use percents. + */ static void UpdateAllServiceInterval(int32 new_value) { bool update_vehicles; @@ -141,15 +144,17 @@ static void UpdateAllServiceInterval(int } if (new_value != 0) { - vds->servint_trains = 50; - vds->servint_roadveh = 50; - vds->servint_aircraft = 50; - vds->servint_ships = 50; + /* Service intervals are in percents. */ + vds->servint_trains = DEF_SERVINT_PERCENT; + vds->servint_roadveh = DEF_SERVINT_PERCENT; + vds->servint_aircraft = DEF_SERVINT_PERCENT; + vds->servint_ships = DEF_SERVINT_PERCENT; } else { - vds->servint_trains = 150; - vds->servint_roadveh = 150; - vds->servint_aircraft = 100; - vds->servint_ships = 360; + /* Service intervals are in days. */ + vds->servint_trains = DEF_SERVINT_DAYS_TRAINS; + vds->servint_roadveh = DEF_SERVINT_DAYS_ROADVEH; + vds->servint_aircraft = DEF_SERVINT_DAYS_AIRCRAFT; + vds->servint_ships = DEF_SERVINT_DAYS_SHIPS; } if (update_vehicles) { diff --git a/src/table/settings/company_settings.ini b/src/table/settings/company_settings.ini --- a/src/table/settings/company_settings.ini +++ b/src/table/settings/company_settings.ini @@ -83,9 +83,10 @@ post_cb = UpdateAllServiceInterval var = vehicle.servint_trains type = SLE_UINT16 flags = SF_PER_COMPANY | SF_GUI_0_IS_SPECIAL -def = 150 -min = 5 -max = 800 +def = DEF_SERVINT_DAYS_TRAINS +min = MIN_SERVINT_PERCENT +max = MAX_SERVINT_DAYS +interval = 1 str = STR_CONFIG_SETTING_SERVINT_TRAINS strhelp = STR_CONFIG_SETTING_SERVINT_TRAINS_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE @@ -96,9 +97,10 @@ post_cb = [](auto new_value) { UpdateSe var = vehicle.servint_roadveh type = SLE_UINT16 flags = SF_PER_COMPANY | SF_GUI_0_IS_SPECIAL -def = 150 -min = 5 -max = 800 +def = DEF_SERVINT_DAYS_ROADVEH +min = MIN_SERVINT_PERCENT +max = MAX_SERVINT_DAYS +interval = 1 str = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES strhelp = STR_CONFIG_SETTING_SERVINT_ROAD_VEHICLES_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE @@ -109,9 +111,10 @@ post_cb = [](auto new_value) { UpdateSe var = vehicle.servint_ships type = SLE_UINT16 flags = SF_PER_COMPANY | SF_GUI_0_IS_SPECIAL -def = 360 -min = 5 -max = 800 +def = DEF_SERVINT_DAYS_SHIPS +min = MIN_SERVINT_PERCENT +max = MAX_SERVINT_DAYS +interval = 1 str = STR_CONFIG_SETTING_SERVINT_SHIPS strhelp = STR_CONFIG_SETTING_SERVINT_SHIPS_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE @@ -122,9 +125,10 @@ post_cb = [](auto new_value) { UpdateSe var = vehicle.servint_aircraft type = SLE_UINT16 flags = SF_PER_COMPANY | SF_GUI_0_IS_SPECIAL -def = 100 -min = 5 -max = 800 +def = DEF_SERVINT_DAYS_AIRCRAFT +min = MIN_SERVINT_PERCENT +max = MAX_SERVINT_DAYS +interval = 1 str = STR_CONFIG_SETTING_SERVINT_AIRCRAFT strhelp = STR_CONFIG_SETTING_SERVINT_AIRCRAFT_HELPTEXT strval = STR_CONFIG_SETTING_SERVINT_VALUE