diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 0b273e6519..af24164f86 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -463,7 +463,18 @@ Money Aircraft::GetRunningCost() const { const Engine *e = this->GetEngine(); uint cost_factor = GetVehicleProperty(this, PROP_AIRCRAFT_RUNNING_COST_FACTOR, e->u.air.running_cost); - return GetPrice(PR_RUNNING_AIRCRAFT, cost_factor, e->GetGRF()); + Money cost = GetPrice(PR_RUNNING_AIRCRAFT, cost_factor, e->GetGRF()); + + if (this->cur_speed == 0) { + if (this->IsInDepot()) { + /* running costs if in depot */ + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_in_depot); + } else { + /* running costs if stopped */ + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_when_stopped); + } + } + return cost; } void Aircraft::OnNewDay() diff --git a/src/lang/english.txt b/src/lang/english.txt index 6fc7c7ae0c..9643d69fa8 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1265,6 +1265,14 @@ STR_CONFIG_SETTING_INTEREST_RATE_HELPTEXT :Loan interest r STR_CONFIG_SETTING_RUNNING_COSTS :Running costs: {STRING2} STR_CONFIG_SETTING_RUNNING_COSTS_HELPTEXT :Set level of maintenance and running costs of vehicles and infrastructure +STR_CONFIG_SETTING_RUNNING_COSTS_IN_DEPOT :Running costs of Vehicles in Depot: {STRING2} +STR_CONFIG_SETTING_RUNNING_COSTS_IN_DEPOT_HELPTEXT :Set level of maintenance and running costs of vehicles while waiting in depots (not stopped) +STR_CONFIG_SETTING_RUNNING_COSTS_IN_DEPOT_VALUE :1 / {COMMA} + +STR_CONFIG_SETTING_RUNNING_COSTS_WHEN_STOPPED :Running costs of Stationary Vehicles: {STRING2} +STR_CONFIG_SETTING_RUNNING_COSTS_WHEN_STOPPED_HELPTEXT :Set level of maintenance and running costs of vehicles while stationary and not in a depot +STR_CONFIG_SETTING_RUNNING_COSTS_WHEN_STOPPED_VALUE :1 / {COMMA} + STR_CONFIG_SETTING_CONSTRUCTION_SPEED :Construction speed: {STRING2} STR_CONFIG_SETTING_CONSTRUCTION_SPEED_HELPTEXT :Limit the amount of construction actions for AIs diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 131d8d76ea..9ec01ab4b6 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -2131,7 +2131,18 @@ Money RoadVehicle::GetRunningCost() const uint cost_factor = GetVehicleProperty(this, PROP_ROADVEH_RUNNING_COST_FACTOR, e->u.road.running_cost); if (cost_factor == 0) return 0; - return GetPrice(e->u.road.running_cost_class, cost_factor, e->GetGRF()); + Money cost = GetPrice(e->u.road.running_cost_class, cost_factor, e->GetGRF()); + + if (this->cur_speed == 0) { + if (this->IsInDepot()) { + /* running costs if in depot */ + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_in_depot); + } else { + /* running costs if stopped */ + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_when_stopped); + } + } + return cost; } bool RoadVehicle::Tick() diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index f98f7fe16e..2e92d5f3a4 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1930,6 +1930,8 @@ static SettingsContainer &GetSettingsTree() accounting->Add(new SettingEntry("economy.feeder_payment_share")); accounting->Add(new SettingEntry("economy.infrastructure_maintenance")); accounting->Add(new SettingEntry("difficulty.vehicle_costs")); + accounting->Add(new SettingEntry("difficulty.vehicle_costs_in_depot")); + accounting->Add(new SettingEntry("difficulty.vehicle_costs_when_stopped")); accounting->Add(new SettingEntry("difficulty.construction_cost")); } diff --git a/src/settings_type.h b/src/settings_type.h index 28a11053e3..97b76f6631 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -78,6 +78,8 @@ struct DifficultySettings { uint32 max_loan; ///< the maximum initial loan byte initial_interest; ///< amount of interest (to pay over the loan) byte vehicle_costs; ///< amount of money spent on vehicle running cost + uint8 vehicle_costs_in_depot; ///< amount of money spent on vehicle running cost when in depot + uint8 vehicle_costs_when_stopped; ///< amount of money spent on vehicle running cost when vehicle is stopped byte competitor_speed; ///< the speed at which the AI builds byte vehicle_breakdowns; ///< likelihood of vehicles breaking down byte subsidy_multiplier; ///< payment multiplier for subsidized deliveries diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 30d208ac3d..1f7914bf40 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -229,7 +229,18 @@ Money Ship::GetRunningCost() const { const Engine *e = this->GetEngine(); uint cost_factor = GetVehicleProperty(this, PROP_SHIP_RUNNING_COST_FACTOR, e->u.ship.running_cost); - return GetPrice(PR_RUNNING_SHIP, cost_factor, e->GetGRF()); + Money cost = GetPrice(PR_RUNNING_SHIP, cost_factor, e->GetGRF()); + + if (this->cur_speed == 0) { + if (this->IsInDepot()) { + /* running costs if in depot */ + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_in_depot); + } else { + /* running costs if stopped */ + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_when_stopped); + } + } + return cost; } void Ship::OnNewDay() diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index c0bcc26ab8..6946b098e1 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -272,6 +272,31 @@ strhelp = STR_CONFIG_SETTING_RUNNING_COSTS_HELPTEXT strval = STR_SEA_LEVEL_LOW cat = SC_BASIC +[SDT_VAR] +var = difficulty.vehicle_costs_in_depot +type = SLE_UINT8 +from = SLV_97 +def = 1 +min = 1 +max = 8 +str = STR_CONFIG_SETTING_RUNNING_COSTS_IN_DEPOT +strhelp = STR_CONFIG_SETTING_RUNNING_COSTS_IN_DEPOT_HELPTEXT +strval = STR_CONFIG_SETTING_RUNNING_COSTS_IN_DEPOT_VALUE +patxname = ""difficulty.vehicle_costs_in_depot"" + +[SDT_VAR] +var = difficulty.vehicle_costs_when_stopped +type = SLE_UINT8 +from = SLV_97 +def = 1 +min = 1 +max = 8 +str = STR_CONFIG_SETTING_RUNNING_COSTS_WHEN_STOPPED +strhelp = STR_CONFIG_SETTING_RUNNING_COSTS_WHEN_STOPPED_HELPTEXT +strval = STR_CONFIG_SETTING_RUNNING_COSTS_WHEN_STOPPED_VALUE +strval = STR_CONFIG_SETTING_RUNNING_COSTS_IN_DEPOT_VALUE +patxname = ""difficulty.vehicle_costs_when_stopped"" + [SDT_VAR] var = difficulty.competitor_speed type = SLE_UINT8 diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 79be35f455..753726d74f 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -6481,6 +6481,16 @@ Money Train::GetRunningCost() const cost += GetPrice(e->u.rail.running_cost_class, cost_factor, e->GetGRF()); } while ((v = v->GetNextVehicle()) != nullptr); + if (this->cur_speed == 0) { + if (this->IsInDepot()) { + /* running costs if in depot */ + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_in_depot); + } else { + /* running costs if stopped */ + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_when_stopped); + } + } + return cost; }