summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aircraft_cmd.cpp4
-rw-r--r--src/depot.cpp1
-rw-r--r--src/order_cmd.cpp6
-rw-r--r--src/order_func.h12
-rw-r--r--src/roadveh_cmd.cpp4
-rw-r--r--src/saveload/afterload.cpp8
-rw-r--r--src/saveload/company_sl.cpp7
-rw-r--r--src/saveload/saveload.cpp2
-rw-r--r--src/settings.cpp25
-rw-r--r--src/settings_internal.h2
-rw-r--r--src/settings_type.h15
-rw-r--r--src/ship_cmd.cpp4
-rw-r--r--src/table/settings.h23
-rw-r--r--src/train_cmd.cpp4
-rw-r--r--src/vehicle.cpp2
-rw-r--r--src/vehicle_cmd.cpp5
-rw-r--r--src/vehicle_gui.cpp17
17 files changed, 88 insertions, 53 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index 1b6c2d3bd..dc169ff5c 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -378,7 +378,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
v->targetairport = GetStationIndex(tile);
v->SetNext(u);
- v->service_interval = _settings_game.vehicle.servint_aircraft;
+ v->service_interval = Company::Get(_current_company)->settings.vehicle.servint_aircraft;
v->date_of_last_service = _date;
v->build_year = u->build_year = _cur_year;
@@ -582,7 +582,7 @@ CommandCost CmdRefitAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
static void CheckIfAircraftNeedsService(Aircraft *v)
{
- if (_settings_game.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
+ if (Company::Get(v->owner)->settings.vehicle.servint_aircraft == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
diff --git a/src/depot.cpp b/src/depot.cpp
index b034e8531..d241caf72 100644
--- a/src/depot.cpp
+++ b/src/depot.cpp
@@ -4,6 +4,7 @@
#include "stdafx.h"
#include "depot_base.h"
+#include "company_type.h"
#include "order_func.h"
#include "window_func.h"
#include "core/bitmath_func.hpp"
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 68d255d78..c367a9e87 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -1340,7 +1340,7 @@ CommandCost CmdRestoreOrderIndex(TileIndex tile, DoCommandFlag flags, uint32 p1,
Vehicle *v = Vehicle::GetIfValid(p1);
/* Check the vehicle type and ownership, and if the service interval and order are in range */
if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
- if (serv_int != GetServiceIntervalClamped(serv_int) || cur_ord >= v->GetNumOrders()) return CMD_ERROR;
+ if (serv_int != GetServiceIntervalClamped(serv_int, v->owner) || cur_ord >= v->GetNumOrders()) return CMD_ERROR;
if (flags & DC_EXEC) {
v->cur_order_index = cur_ord;
@@ -1527,9 +1527,9 @@ void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist)
}
}
-Date GetServiceIntervalClamped(uint index)
+uint16 GetServiceIntervalClamped(uint interval, CompanyID company_id)
{
- return (_settings_game.vehicle.servint_ispercent) ? Clamp(index, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(index, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
+ return (Company::Get(company_id)->settings.vehicle.servint_ispercent) ? Clamp(interval, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(interval, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS);
}
/**
diff --git a/src/order_func.h b/src/order_func.h
index 62a33f089..c8dffe1a3 100644
--- a/src/order_func.h
+++ b/src/order_func.h
@@ -47,12 +47,12 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
#define MAX_SERVINT_DAYS 800
/**
- * Get the service interval domain.
- * Get the new proposed service interval for the vehicle is indeed, clamped
- * within the given bounds. @see MIN_SERVINT_PERCENT ,etc.
- * @param index proposed service interval
- * @return service interval
+ * Clamp the service interval to the correct min/max. The actual min/max values
+ * depend on whether it's in percent or days.
+ * @param interval proposed service interval
+ * @param company_id the owner of the vehicle
+ * @return Clamped service interval
*/
-Date GetServiceIntervalClamped(uint index);
+uint16 GetServiceIntervalClamped(uint interval, CompanyID company_id);
#endif /* ORDER_FUNC_H */
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 41213de94..6bbe7ef93 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -233,7 +233,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
v->name = NULL;
- v->service_interval = _settings_game.vehicle.servint_roadveh;
+ v->service_interval = Company::Get(v->owner)->settings.vehicle.servint_roadveh;
v->date_of_last_service = _date;
v->build_year = _cur_year;
@@ -1825,7 +1825,7 @@ bool RoadVehicle::Tick()
static void CheckIfRoadVehNeedsService(RoadVehicle *v)
{
/* If we already got a slot at a stop, use that FIRST, and go to a depot later */
- if (v->slot != NULL || _settings_game.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
+ if (v->slot != NULL || Company::Get(v->owner)->settings.vehicle.servint_roadveh == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index d55b821e3..a298108aa 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1846,6 +1846,14 @@ bool AfterLoadGame()
}
}
+ if (CheckSavegameVersion(120)) {
+ extern VehicleDefaultSettings _old_vds;
+ Company *c;
+ FOR_ALL_COMPANIES(c) {
+ c->settings.vehicle = _old_vds;
+ }
+ }
+
AfterLoadLabelMaps();
GamelogPrintDebug(1);
diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp
index 8c44fee0c..940b561be 100644
--- a/src/saveload/company_sl.cpp
+++ b/src/saveload/company_sl.cpp
@@ -140,6 +140,13 @@ static const SaveLoad _company_desc[] = {
SLE_CONDVAR(Company, settings.engine_renew_money, SLE_UINT32, 16, SL_MAX_VERSION),
SLE_CONDVAR(Company, settings.renew_keep_length, SLE_BOOL, 2, SL_MAX_VERSION),
+ /* Default vehicle settings */
+ SLE_CONDVAR(Company, settings.vehicle.servint_ispercent, SLE_BOOL, 120, SL_MAX_VERSION),
+ SLE_CONDVAR(Company, settings.vehicle.servint_trains, SLE_UINT16, 120, SL_MAX_VERSION),
+ 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),
+
/* Reserve extra space in savegame here. (currently 63 bytes) */
SLE_CONDNULL(63, 2, SL_MAX_VERSION),
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 3412ae218..bdc292fcc 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -40,7 +40,7 @@
#include "saveload_internal.h"
-extern const uint16 SAVEGAME_VERSION = 119;
+extern const uint16 SAVEGAME_VERSION = 120;
SavegameType _savegame_type; ///< type of savegame we are loading
diff --git a/src/settings.cpp b/src/settings.cpp
index dca90a6ca..37e64fb4f 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -67,6 +67,7 @@
ClientSettings _settings_client;
GameSettings _settings_game;
GameSettings _settings_newgame;
+VehicleDefaultSettings _old_vds; ///< Used for loading default vehicles settings from old savegames
typedef void SettingDescProc(IniFile *ini, const SettingDesc *desc, const char *grpname, void *object);
typedef void SettingDescProcList(IniFile *ini, const char *grpname, StringList *list);
@@ -705,18 +706,23 @@ static bool UpdateConsists(int32 p1)
/* Check service intervals of vehicles, p1 is value of % or day based servicing */
static bool CheckInterval(int32 p1)
{
- VehicleSettings *ptc = (_game_mode == GM_MENU) ? &_settings_newgame.vehicle : &_settings_game.vehicle;
+ VehicleDefaultSettings *vds;
+ if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) {
+ vds = &_settings_client.company.vehicle;
+ } else {
+ vds = &Company::Get(_current_company)->settings.vehicle;
+ }
if (p1) {
- ptc->servint_trains = 50;
- ptc->servint_roadveh = 50;
- ptc->servint_aircraft = 50;
- ptc->servint_ships = 50;
+ vds->servint_trains = 50;
+ vds->servint_roadveh = 50;
+ vds->servint_aircraft = 50;
+ vds->servint_ships = 50;
} else {
- ptc->servint_trains = 150;
- ptc->servint_roadveh = 150;
- ptc->servint_aircraft = 360;
- ptc->servint_ships = 100;
+ vds->servint_trains = 150;
+ vds->servint_roadveh = 150;
+ vds->servint_aircraft = 360;
+ vds->servint_ships = 100;
}
InvalidateDetailsWindow(0);
@@ -1425,7 +1431,6 @@ CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
*/
CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- DEBUG(misc, 0, "Change company setting: %u into %u", p1, p2);
if (p1 >= lengthof(_company_settings)) return CMD_ERROR;
const SettingDesc *sd = &_company_settings[p1];
diff --git a/src/settings_internal.h b/src/settings_internal.h
index cd45dd8d3..322d54ca5 100644
--- a/src/settings_internal.h
+++ b/src/settings_internal.h
@@ -80,4 +80,6 @@ bool SetSettingValue(uint index, int32 value);
bool SetSettingValue(uint index, const char *value);
void SetCompanySetting(uint index, int32 value);
+extern VehicleDefaultSettings _old_vds;
+
#endif /* SETTINGS_H */
diff --git a/src/settings_type.h b/src/settings_type.h
index d4f4137bb..88df6945d 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -293,11 +293,6 @@ struct VehicleSettings {
UnitID max_roadveh; ///< max trucks in game per company
UnitID max_aircraft; ///< max planes in game per company
UnitID max_ships; ///< max ships in game per company
- bool servint_ispercent; ///< service intervals are in percents
- uint16 servint_trains; ///< service interval for trains
- uint16 servint_roadveh; ///< service interval for road vehicles
- uint16 servint_aircraft; ///< service interval for aircraft
- uint16 servint_ships; ///< service interval for ships
uint8 plane_speed; ///< divisor for speed of aircraft
uint8 freight_trains; ///< value to multiply the weight of cargo by
bool dynamic_engines; ///< enable dynamic allocation of engine data
@@ -338,12 +333,22 @@ struct StationSettings {
byte station_spread; ///< amount a station may spread
};
+/** Default settings for vehicles. */
+struct VehicleDefaultSettings {
+ bool servint_ispercent; ///< service intervals are in percents
+ uint16 servint_trains; ///< service interval for trains
+ uint16 servint_roadveh; ///< service interval for road vehicles
+ uint16 servint_aircraft; ///< service interval for aircraft
+ uint16 servint_ships; ///< service interval for ships
+};
+
/** Settings that can be set per company. */
struct CompanySettings {
bool engine_renew; ///< is autorenew enabled
int16 engine_renew_months; ///< months before/after the maximum vehicle age a vehicle should be renewed
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
};
/** All settings together for the game. */
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 0e947eccd..c2c5a72cd 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -127,7 +127,7 @@ static const Depot *FindClosestShipDepot(const Vehicle *v)
static void CheckIfShipNeedsService(Vehicle *v)
{
- if (_settings_game.vehicle.servint_ships == 0 || !v->NeedsAutomaticServicing()) return;
+ if (Company::Get(v->owner)->settings.vehicle.servint_ships == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
@@ -805,7 +805,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
v->name = NULL;
v->state = TRACK_BIT_DEPOT;
- v->service_interval = _settings_game.vehicle.servint_ships;
+ v->service_interval = Company::Get(_current_company)->settings.vehicle.servint_ships;
v->date_of_last_service = _date;
v->build_year = _cur_year;
v->cur_image = SPR_IMG_QUERY;
diff --git a/src/table/settings.h b/src/table/settings.h
index efec8ea77..4d557b74e 100644
--- a/src/table/settings.h
+++ b/src/table/settings.h
@@ -377,11 +377,11 @@ const SettingDesc _settings[] = {
SDT_VAR(GameSettings, vehicle.max_roadveh, SLE_UINT16, 0, 0, 500, 0, 5000, 0, STR_CONFIG_SETTING_MAX_ROADVEH, RedrawScreen),
SDT_VAR(GameSettings, vehicle.max_aircraft, SLE_UINT16, 0, 0, 200, 0, 5000, 0, STR_CONFIG_SETTING_MAX_AIRCRAFT, RedrawScreen),
SDT_VAR(GameSettings, vehicle.max_ships, SLE_UINT16, 0, 0, 300, 0, 5000, 0, STR_CONFIG_SETTING_MAX_SHIPS, RedrawScreen),
- SDT_BOOL(GameSettings, vehicle.servint_ispercent, 0,NN, false, STR_CONFIG_SETTING_SERVINT_ISPERCENT, CheckInterval),
- SDT_VAR(GameSettings, vehicle.servint_trains, SLE_UINT16, 0,D0, 150, 5, 800, 0, STR_CONFIG_SETTING_SERVINT_TRAINS, InvalidateDetailsWindow),
- SDT_VAR(GameSettings, vehicle.servint_roadveh, SLE_UINT16, 0,D0, 150, 5, 800, 0, STR_CONFIG_SETTING_SERVINT_ROADVEH, InvalidateDetailsWindow),
- SDT_VAR(GameSettings, vehicle.servint_ships, SLE_UINT16, 0,D0, 360, 5, 800, 0, STR_CONFIG_SETTING_SERVINT_SHIPS, InvalidateDetailsWindow),
- SDT_VAR(GameSettings, vehicle.servint_aircraft, SLE_UINT16, 0,D0, 100, 5, 800, 0, STR_CONFIG_SETTING_SERVINT_AIRCRAFT, InvalidateDetailsWindow),
+ SDTG_CONDBOOL(NULL, 0, NN, _old_vds.servint_ispercent, false, STR_NULL, NULL, 0, 119),
+ SDTG_CONDVAR(NULL, SLE_UINT16, 0, D0, _old_vds.servint_trains, 150, 5, 800, 0, STR_NULL, NULL, 0, 119),
+ SDTG_CONDVAR(NULL, SLE_UINT16, 0, D0, _old_vds.servint_roadveh, 150, 5, 800, 0, STR_NULL, NULL, 0, 119),
+ SDTG_CONDVAR(NULL, SLE_UINT16, 0, D0, _old_vds.servint_ships, 360, 5, 800, 0, STR_NULL, NULL, 0, 119),
+ SDTG_CONDVAR(NULL, SLE_UINT16, 0, D0, _old_vds.servint_aircraft, 150, 5, 800, 0, STR_NULL, NULL, 0, 119),
SDT_BOOL(GameSettings, order.no_servicing_if_no_breakdowns, 0, 0, false, STR_CONFIG_SETTING_NOSERVICE, NULL),
SDT_BOOL(GameSettings, vehicle.wagon_speed_limits, 0,NN, true, STR_CONFIG_SETTING_WAGONSPEEDLIMITS, UpdateConsists),
SDT_CONDBOOL(GameSettings, vehicle.disable_elrails, 38, SL_MAX_VERSION, 0,NN, false, STR_CONFIG_SETTING_DISABLE_ELRAILS, SettingsDisableElrail),
@@ -615,10 +615,15 @@ const SettingDesc _settings[] = {
};
static const SettingDesc _company_settings[] = {
- SDT_BOOL(CompanySettings, engine_renew, 0, PC, false, STR_CONFIG_SETTING_AUTORENEW_VEHICLE, NULL),
- SDT_VAR(CompanySettings, engine_renew_months, SLE_INT16, 0, PC, 6, -12, 12, 0, STR_CONFIG_SETTING_AUTORENEW_MONTHS, NULL),
- SDT_VAR(CompanySettings, engine_renew_money, SLE_UINT, 0, PC|CR,100000, 0, 2000000, 0, STR_CONFIG_SETTING_AUTORENEW_MONEY, NULL),
- SDT_BOOL(CompanySettings, renew_keep_length, 0, PC, false, STR_NULL, NULL),
+ SDT_BOOL(CompanySettings, engine_renew, 0, PC, false, STR_CONFIG_SETTING_AUTORENEW_VEHICLE, NULL),
+ SDT_VAR(CompanySettings, engine_renew_months, SLE_INT16, 0, PC, 6, -12, 12, 0, STR_CONFIG_SETTING_AUTORENEW_MONTHS, NULL),
+ SDT_VAR(CompanySettings, engine_renew_money, SLE_UINT, 0, PC|CR, 100000, 0, 2000000, 0, STR_CONFIG_SETTING_AUTORENEW_MONEY, NULL),
+ SDT_BOOL(CompanySettings, renew_keep_length, 0, PC, false, STR_NULL, NULL),
+ SDT_BOOL(CompanySettings, vehicle.servint_ispercent, 0, PC, false, STR_CONFIG_SETTING_SERVINT_ISPERCENT, CheckInterval),
+ SDT_VAR(CompanySettings, vehicle.servint_trains, SLE_UINT16, 0, PC|D0, 150, 5, 800, 0, STR_CONFIG_SETTING_SERVINT_TRAINS, InvalidateDetailsWindow),
+ SDT_VAR(CompanySettings, vehicle.servint_roadveh, SLE_UINT16, 0, PC|D0, 150, 5, 800, 0, STR_CONFIG_SETTING_SERVINT_ROADVEH, InvalidateDetailsWindow),
+ SDT_VAR(CompanySettings, vehicle.servint_ships, SLE_UINT16, 0, PC|D0, 360, 5, 800, 0, STR_CONFIG_SETTING_SERVINT_SHIPS, InvalidateDetailsWindow),
+ SDT_VAR(CompanySettings, vehicle.servint_aircraft, SLE_UINT16, 0, PC|D0, 100, 5, 800, 0, STR_CONFIG_SETTING_SERVINT_AIRCRAFT, InvalidateDetailsWindow),
SDT_END()
};
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index eef3ebe82..568bf18bd 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -858,7 +858,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
v->railtype = rvi->railtype;
_new_vehicle_id = v->index;
- v->service_interval = _settings_game.vehicle.servint_trains;
+ v->service_interval = Company::Get(_current_company)->settings.vehicle.servint_trains;
v->date_of_last_service = _date;
v->build_year = _cur_year;
v->cur_image = SPR_IMG_QUERY;
@@ -4464,7 +4464,7 @@ static void CheckIfTrainNeedsService(Train *v)
{
static const uint MAX_ACCEPTABLE_DEPOT_DIST = 16;
- if (_settings_game.vehicle.servint_trains == 0 || !v->NeedsAutomaticServicing()) return;
+ if (Company::Get(v->owner)->settings.vehicle.servint_trains == 0 || !v->NeedsAutomaticServicing()) return;
if (v->IsInDepot()) {
VehicleServiceInDepot(v);
return;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 5684abcc0..e798f7b80 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -90,7 +90,7 @@ bool Vehicle::NeedsServicing() const
return EngineHasReplacementForCompany(Company::Get(this->owner), this->engine_type, this->group_id);
}
- return _settings_game.vehicle.servint_ispercent ?
+ return Company::Get(this->owner)->settings.vehicle.servint_ispercent ?
(this->reliability < Engine::Get(this->engine_type)->reliability * (100 - this->service_interval) / 100) :
(this->date_of_last_service + this->service_interval < _date);
}
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index e2556e04c..e579d7575 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -558,10 +558,11 @@ CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
*/
CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
- uint16 serv_int = GetServiceIntervalClamped(p2); // Double check the service interval from the user-input
Vehicle *v = Vehicle::GetIfValid(p1);
+ if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
- if (serv_int != p2 || v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
+ uint16 serv_int = GetServiceIntervalClamped(p2, v->owner); // Double check the service interval from the user-input
+ if (serv_int != p2) return CMD_ERROR;
if (flags & DC_EXEC) {
v->service_interval = serv_int;
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 455aed43a..2cea2dae3 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1389,14 +1389,15 @@ struct VehicleDetailsWindow : Window {
}
/** Checks whether service interval is enabled for the vehicle. */
- static bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type)
+ static bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type, CompanyID company_id)
{
+ const VehicleDefaultSettings *vds = &Company::Get(company_id)->settings.vehicle;
switch (vehicle_type) {
default: NOT_REACHED();
- case VEH_TRAIN: return _settings_game.vehicle.servint_trains != 0;
- case VEH_ROAD: return _settings_game.vehicle.servint_roadveh != 0;
- case VEH_SHIP: return _settings_game.vehicle.servint_ships != 0;
- case VEH_AIRCRAFT: return _settings_game.vehicle.servint_aircraft != 0;
+ case VEH_TRAIN: return vds->servint_trains != 0;
+ case VEH_ROAD: return vds->servint_roadveh != 0;
+ case VEH_SHIP: return vds->servint_ships != 0;
+ case VEH_AIRCRAFT: return vds->servint_aircraft != 0;
}
}
@@ -1445,7 +1446,7 @@ struct VehicleDetailsWindow : Window {
WIDGET_LIST_END);
/* Disable service-scroller when interval is set to disabled */
- this->SetWidgetsDisabledState(!IsVehicleServiceIntervalEnabled(v->type),
+ this->SetWidgetsDisabledState(!IsVehicleServiceIntervalEnabled(v->type, v->owner),
VLD_WIDGET_INCREASE_SERVICING_INTERVAL,
VLD_WIDGET_DECREASE_SERVICING_INTERVAL,
WIDGET_LIST_END);
@@ -1496,7 +1497,7 @@ struct VehicleDetailsWindow : Window {
/* Draw service interval text */
SetDParam(0, v->service_interval);
SetDParam(1, v->date_of_last_service);
- DrawString(13, this->width - 2, this->height - (v->type != VEH_TRAIN ? 11 : 23), _settings_game.vehicle.servint_ispercent ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
+ DrawString(13, this->width - 2, this->height - (v->type != VEH_TRAIN ? 11 : 23), Company::Get(v->owner)->settings.vehicle.servint_ispercent ? STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT : STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS);
switch (v->type) {
case VEH_TRAIN:
@@ -1537,7 +1538,7 @@ struct VehicleDetailsWindow : Window {
const Vehicle *v = Vehicle::Get(this->window_number);
mod = (widget == VLD_WIDGET_DECREASE_SERVICING_INTERVAL) ? -mod : mod;
- mod = GetServiceIntervalClamped(mod + v->service_interval);
+ mod = GetServiceIntervalClamped(mod + v->service_interval, v->owner);
if (mod == v->service_interval) return;
DoCommandP(v->tile, v->index, mod, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_SERVICING));