Adjust stopped/depot detection for running costs division

Fix v/this use in Train::GetRunningCost
This commit is contained in:
Jonathan G Rennison
2021-11-18 23:41:12 +00:00
parent f16657ec96
commit bb8e4eb18a
4 changed files with 36 additions and 21 deletions

View File

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