Initial commit to allow configuring running costs as a fraction (1/1 default thru 1/4) independently for both vehicles stopped in depots (doesn't work for planes, I'm not smart enuff), or vehicles that are stationary.

pull/335/head
reldred 3 years ago
parent 782fba3064
commit 904ff346c2

@ -463,6 +463,14 @@ Money Aircraft::GetRunningCost() const
{
const Engine *e = this->GetEngine();
uint cost_factor = GetVehicleProperty(this, PROP_AIRCRAFT_RUNNING_COST_FACTOR, e->u.air.running_cost);
/* running costs if in depot -- I haven't gotten this one working yet, can't figure out how to tell if plane is in the depot */
if (this->current_order.IsType(OT_GOTO_DEPOT)) cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
/* running costs if stopped */
if ((this->cur_speed == 0) && !(this->current_order.IsType(OT_GOTO_DEPOT))) cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
return GetPrice(PR_RUNNING_AIRCRAFT, cost_factor, e->GetGRF());
}

@ -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

@ -2131,6 +2131,12 @@ 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;
/* running costs if in depot */
if (IsRoadDepotTile(this->tile)) cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
/* running costs if stopped */
if ((this->cur_speed == 0) && !(IsRoadDepotTile(this->tile))) cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
return GetPrice(e->u.road.running_cost_class, cost_factor, e->GetGRF());
}

@ -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"));
}

@ -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

@ -229,6 +229,13 @@ Money Ship::GetRunningCost() const
{
const Engine *e = this->GetEngine();
uint cost_factor = GetVehicleProperty(this, PROP_SHIP_RUNNING_COST_FACTOR, e->u.ship.running_cost);
/* running costs if in depot */
if (IsShipDepotTile(this->tile)) cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
/* running costs if stopped */
if ((this->cur_speed == 0) && !(IsShipDepotTile(this->tile))) cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
return GetPrice(PR_RUNNING_SHIP, cost_factor, e->GetGRF());
}

@ -272,6 +272,30 @@ 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
flags = SF_NEWGAME_ONLY | SF_SCENEDIT_TOO
def = 1
min = 1
max = 4
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
[SDT_VAR]
var = difficulty.vehicle_costs_when_stopped
type = SLE_UINT8
from = SLV_97
flags = SF_NEWGAME_ONLY | SF_SCENEDIT_TOO
def = 1
min = 1
max = 4
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
[SDT_VAR]
var = difficulty.competitor_speed
type = SLE_UINT8

@ -6456,6 +6456,12 @@ Money Train::GetRunningCost() const
/* Halve running cost for multiheaded parts */
if (v->IsMultiheaded()) cost_factor /= 2;
/* running costs if in depot */
if (v->track == TRACK_BIT_DEPOT) cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot;
/* running costs if stopped */
if ((v->cur_speed == 0) && !(v->track == TRACK_BIT_DEPOT)) cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped;
cost += GetPrice(e->u.rail.running_cost_class, cost_factor, e->GetGRF());
} while ((v = v->GetNextVehicle()) != nullptr);

Loading…
Cancel
Save