From 904ff346c26a23ae09c3911b8571f76101c1c124 Mon Sep 17 00:00:00 2001 From: reldred Date: Thu, 18 Nov 2021 12:47:23 +1030 Subject: [PATCH 1/6] 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. --- src/aircraft_cmd.cpp | 8 ++++++++ src/lang/english.txt | 8 ++++++++ src/roadveh_cmd.cpp | 6 ++++++ src/settings_gui.cpp | 2 ++ src/settings_type.h | 2 ++ src/ship_cmd.cpp | 7 +++++++ src/table/settings/settings.ini | 24 ++++++++++++++++++++++++ src/train_cmd.cpp | 6 ++++++ 8 files changed, 63 insertions(+) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 0b273e6519..6668b9caf2 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -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()); } 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..eb2d746f41 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -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()); } 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..8c1aa7135e 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -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()); } diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index c0bcc26ab8..1625a9b791 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -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 diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index a7d4055a61..9e8039880a 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -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); From fddc9fb975404176a6338650c9cdb71dec01e2a9 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 18 Nov 2021 23:30:40 +0000 Subject: [PATCH 2/6] Increase max value of running cost divider settings --- src/table/settings/settings.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index 1625a9b791..0669ef646a 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -279,7 +279,7 @@ from = SLV_97 flags = SF_NEWGAME_ONLY | SF_SCENEDIT_TOO def = 1 min = 1 -max = 4 +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 @@ -291,7 +291,7 @@ from = SLV_97 flags = SF_NEWGAME_ONLY | SF_SCENEDIT_TOO def = 1 min = 1 -max = 4 +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 From 33bedf006114b1850e2659780f47a4691a4c8b71 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 18 Nov 2021 23:31:21 +0000 Subject: [PATCH 3/6] Allow changing running cost divider settings in game --- src/table/settings/settings.ini | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index 0669ef646a..c9dccc93bd 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -276,7 +276,6 @@ cat = SC_BASIC var = difficulty.vehicle_costs_in_depot type = SLE_UINT8 from = SLV_97 -flags = SF_NEWGAME_ONLY | SF_SCENEDIT_TOO def = 1 min = 1 max = 8 @@ -288,7 +287,6 @@ strval = STR_CONFIG_SETTING_RUNNING_COSTS_IN_DEPOT_VALUE var = difficulty.vehicle_costs_when_stopped type = SLE_UINT8 from = SLV_97 -flags = SF_NEWGAME_ONLY | SF_SCENEDIT_TOO def = 1 min = 1 max = 8 From f16657ec96a1e83a06735b8f17725a46014caec2 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 18 Nov 2021 23:34:39 +0000 Subject: [PATCH 4/6] Fix running costs divider settings saveload --- src/table/settings/settings.ini | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/table/settings/settings.ini b/src/table/settings/settings.ini index c9dccc93bd..6946b098e1 100644 --- a/src/table/settings/settings.ini +++ b/src/table/settings/settings.ini @@ -282,6 +282,7 @@ 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 @@ -293,6 +294,8 @@ 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 From bb8e4eb18ac26f43eafae867c880c1da4aab8dfe Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 18 Nov 2021 23:41:12 +0000 Subject: [PATCH 5/6] Adjust stopped/depot detection for running costs division Fix v/this use in Train::GetRunningCost --- src/aircraft_cmd.cpp | 15 +++++++++------ src/roadveh_cmd.cpp | 14 +++++++++----- src/ship_cmd.cpp | 14 +++++++++----- src/train_cmd.cpp | 14 +++++++++----- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 6668b9caf2..b2ef6d0d78 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -464,12 +464,15 @@ 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; - + if (this->cur_speed == 0) { + if (this->IsInDepot()) { + /* running costs if in depot */ + cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot; + } else { + /* running costs if stopped */ + cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped; + } + } return GetPrice(PR_RUNNING_AIRCRAFT, cost_factor, e->GetGRF()); } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index eb2d746f41..f3e99c7f0b 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -2131,11 +2131,15 @@ 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; + if (this->cur_speed == 0) { + if (this->IsInDepot()) { + /* running costs if in depot */ + cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot; + } else { + /* running costs if stopped */ + cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped; + } + } return GetPrice(e->u.road.running_cost_class, cost_factor, e->GetGRF()); } diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 8c1aa7135e..e7de6076ac 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -230,11 +230,15 @@ 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; + if (this->cur_speed == 0) { + if (this->IsInDepot()) { + /* running costs if in depot */ + cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot; + } else { + /* running costs if stopped */ + cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped; + } + }; return GetPrice(PR_RUNNING_SHIP, cost_factor, e->GetGRF()); } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 9e8039880a..0a572ab817 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -6456,11 +6456,15 @@ 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; + if (this->cur_speed == 0) { + if (this->IsInDepot()) { + /* running costs if in depot */ + cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot; + } else { + /* running costs if stopped */ + 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); From f22a5685c38b073e94fed594218fe172559d287d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 18 Nov 2021 23:55:48 +0000 Subject: [PATCH 6/6] Divide cost instead of cost_factor in running costs division This is to prevent 0 running costs for cheap vehicles when cost_factor would be < 1 --- src/aircraft_cmd.cpp | 8 ++++---- src/roadveh_cmd.cpp | 9 +++++---- src/ship_cmd.cpp | 10 +++++----- src/train_cmd.cpp | 20 ++++++++++---------- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index b2ef6d0d78..af24164f86 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -463,18 +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); + Money cost = GetPrice(PR_RUNNING_AIRCRAFT, cost_factor, e->GetGRF()); if (this->cur_speed == 0) { if (this->IsInDepot()) { /* running costs if in depot */ - cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot; + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_in_depot); } else { /* running costs if stopped */ - cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped; + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_when_stopped); } } - - return GetPrice(PR_RUNNING_AIRCRAFT, cost_factor, e->GetGRF()); + return cost; } void Aircraft::OnNewDay() diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index f3e99c7f0b..9ec01ab4b6 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -2131,17 +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; + 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_factor /= _settings_game.difficulty.vehicle_costs_in_depot; + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_in_depot); } else { /* running costs if stopped */ - cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped; + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_when_stopped); } } - - return GetPrice(e->u.road.running_cost_class, cost_factor, e->GetGRF()); + return cost; } bool RoadVehicle::Tick() diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index e7de6076ac..1f7914bf40 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -229,18 +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); + Money cost = GetPrice(PR_RUNNING_SHIP, cost_factor, e->GetGRF()); if (this->cur_speed == 0) { if (this->IsInDepot()) { /* running costs if in depot */ - cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot; + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_in_depot); } else { /* running costs if stopped */ - cost_factor /= _settings_game.difficulty.vehicle_costs_when_stopped; + cost = CeilDivT(cost, _settings_game.difficulty.vehicle_costs_when_stopped); } - }; - - return GetPrice(PR_RUNNING_SHIP, cost_factor, e->GetGRF()); + } + return cost; } void Ship::OnNewDay() diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 0a572ab817..d60cc4c74c 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -6456,19 +6456,19 @@ Money Train::GetRunningCost() const /* Halve running cost for multiheaded parts */ if (v->IsMultiheaded()) cost_factor /= 2; - if (this->cur_speed == 0) { - if (this->IsInDepot()) { - /* running costs if in depot */ - cost_factor /= _settings_game.difficulty.vehicle_costs_in_depot; - } else { - /* running costs if stopped */ - 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); + 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; }