summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/api/ai_engine.cpp24
-rw-r--r--src/ai/api/ai_event_types.cpp24
2 files changed, 2 insertions, 46 deletions
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp
index 545305f3f..5d301f47c 100644
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -157,29 +157,7 @@
{
if (!IsValidEngine(engine_id)) return -1;
- switch (::GetEngine(engine_id)->type) {
- case VEH_ROAD: {
- const RoadVehicleInfo *vi = ::RoadVehInfo(engine_id);
- return (_price.roadveh_base >> 3) * vi->cost_factor >> 5;
- } break;
-
- case VEH_TRAIN: {
- const RailVehicleInfo *vi = ::RailVehInfo(engine_id);
- return (_price.build_railvehicle >> 3) * vi->cost_factor >> 5;
- } break;
-
- case VEH_SHIP: {
- const ShipVehicleInfo *vi = ::ShipVehInfo(engine_id);
- return (_price.ship_base >> 3) * vi->cost_factor >> 5;
- } break;
-
- case VEH_AIRCRAFT: {
- const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine_id);
- return (_price.aircraft_base >> 3) * vi->cost_factor >> 5;
- } break;
-
- default: NOT_REACHED();
- }
+ return ::GetEngine(engine_id)->GetCost();
}
/* static */ int32 AIEngine::GetMaxAge(EngineID engine_id)
diff --git a/src/ai/api/ai_event_types.cpp b/src/ai/api/ai_event_types.cpp
index 9792f92f9..6230caad6 100644
--- a/src/ai/api/ai_event_types.cpp
+++ b/src/ai/api/ai_event_types.cpp
@@ -113,29 +113,7 @@ int32 AIEventEnginePreview::GetMaxSpeed()
Money AIEventEnginePreview::GetPrice()
{
- switch (::GetEngine(engine)->type) {
- case VEH_ROAD: {
- const RoadVehicleInfo *vi = ::RoadVehInfo(engine);
- return (_price.roadveh_base >> 3) * vi->cost_factor >> 5;
- } break;
-
- case VEH_TRAIN: {
- const RailVehicleInfo *vi = ::RailVehInfo(engine);
- return (_price.build_railvehicle >> 3) * vi->cost_factor >> 5;
- } break;
-
- case VEH_SHIP: {
- const ShipVehicleInfo *vi = ::ShipVehInfo(engine);
- return (_price.ship_base >> 3) * vi->cost_factor >> 5;
- } break;
-
- case VEH_AIRCRAFT: {
- const AircraftVehicleInfo *vi = ::AircraftVehInfo(engine);
- return (_price.aircraft_base >> 3) * vi->cost_factor >> 5;
- } break;
-
- default: NOT_REACHED();
- }
+ return ::GetEngine(engine)->GetCost();
}
Money AIEventEnginePreview::GetRunningCost()