* Return how much a new engine costs. * @return Cost of the engine. */
| 315 | * @return Cost of the engine. |
| 316 | */ |
| 317 | Money Engine::GetCost() const |
| 318 | { |
| 319 | Price base_price; |
| 320 | uint cost_factor; |
| 321 | switch (this->type) { |
| 322 | case VEH_ROAD: |
| 323 | base_price = PR_BUILD_VEHICLE_ROAD; |
| 324 | cost_factor = GetEngineProperty(this->index, PROP_ROADVEH_COST_FACTOR, this->VehInfo<RoadVehicleInfo>().cost_factor); |
| 325 | break; |
| 326 | |
| 327 | case VEH_TRAIN: |
| 328 | if (this->VehInfo<RailVehicleInfo>().railveh_type == RAILVEH_WAGON) { |
| 329 | base_price = PR_BUILD_VEHICLE_WAGON; |
| 330 | cost_factor = GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->VehInfo<RailVehicleInfo>().cost_factor); |
| 331 | } else { |
| 332 | base_price = PR_BUILD_VEHICLE_TRAIN; |
| 333 | cost_factor = GetEngineProperty(this->index, PROP_TRAIN_COST_FACTOR, this->VehInfo<RailVehicleInfo>().cost_factor); |
| 334 | } |
| 335 | break; |
| 336 | |
| 337 | case VEH_SHIP: |
| 338 | base_price = PR_BUILD_VEHICLE_SHIP; |
| 339 | cost_factor = GetEngineProperty(this->index, PROP_SHIP_COST_FACTOR, this->VehInfo<ShipVehicleInfo>().cost_factor); |
| 340 | break; |
| 341 | |
| 342 | case VEH_AIRCRAFT: |
| 343 | base_price = PR_BUILD_VEHICLE_AIRCRAFT; |
| 344 | cost_factor = GetEngineProperty(this->index, PROP_AIRCRAFT_COST_FACTOR, this->VehInfo<AircraftVehicleInfo>().cost_factor); |
| 345 | break; |
| 346 | |
| 347 | default: NOT_REACHED(); |
| 348 | } |
| 349 | |
| 350 | return GetPrice(base_price, cost_factor, this->GetGRF(), -8); |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * Returns max speed of the engine for display purposes |
no test coverage detected