* Return how much the running costs of this engine are. * @return Yearly running cost of the engine. */
| 278 | * @return Yearly running cost of the engine. |
| 279 | */ |
| 280 | Money Engine::GetRunningCost() const |
| 281 | { |
| 282 | Price base_price; |
| 283 | uint cost_factor; |
| 284 | switch (this->type) { |
| 285 | case VEH_ROAD: |
| 286 | base_price = this->VehInfo<RoadVehicleInfo>().running_cost_class; |
| 287 | if (base_price == INVALID_PRICE) return 0; |
| 288 | cost_factor = GetEngineProperty(this->index, PROP_ROADVEH_RUNNING_COST_FACTOR, this->VehInfo<RoadVehicleInfo>().running_cost); |
| 289 | break; |
| 290 | |
| 291 | case VEH_TRAIN: |
| 292 | base_price = this->VehInfo<RailVehicleInfo>().running_cost_class; |
| 293 | if (base_price == INVALID_PRICE) return 0; |
| 294 | cost_factor = GetEngineProperty(this->index, PROP_TRAIN_RUNNING_COST_FACTOR, this->VehInfo<RailVehicleInfo>().running_cost); |
| 295 | break; |
| 296 | |
| 297 | case VEH_SHIP: |
| 298 | base_price = PR_RUNNING_SHIP; |
| 299 | cost_factor = GetEngineProperty(this->index, PROP_SHIP_RUNNING_COST_FACTOR, this->VehInfo<ShipVehicleInfo>().running_cost); |
| 300 | break; |
| 301 | |
| 302 | case VEH_AIRCRAFT: |
| 303 | base_price = PR_RUNNING_AIRCRAFT; |
| 304 | cost_factor = GetEngineProperty(this->index, PROP_AIRCRAFT_RUNNING_COST_FACTOR, this->VehInfo<AircraftVehicleInfo>().running_cost); |
| 305 | break; |
| 306 | |
| 307 | default: NOT_REACHED(); |
| 308 | } |
| 309 | |
| 310 | return GetPrice(base_price, cost_factor, this->GetGRF(), -8); |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * Return how much a new engine costs. |
no test coverage detected