summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/api/ai_engine.cpp29
-rw-r--r--src/ai/api/ai_event_types.cpp29
2 files changed, 2 insertions, 56 deletions
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp
index 06ed3d728..545305f3f 100644
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -193,34 +193,7 @@
{
if (!IsValidEngine(engine_id)) return -1;
- /* We need to create an instance in order to obtain GetRunningCost.
- * This means we temporary allocate a vehicle in the pool, but
- * there is no other way.. */
- Vehicle *vehicle;
- switch (::GetEngine(engine_id)->type) {
- case VEH_ROAD: {
- vehicle = new RoadVehicle();
- } break;
-
- case VEH_TRAIN: {
- vehicle = new Train();
- } break;
-
- case VEH_SHIP: {
- vehicle = new Ship();
- } break;
-
- case VEH_AIRCRAFT: {
- vehicle = new Aircraft();
- } break;
-
- default: NOT_REACHED();
- }
-
- vehicle->engine_type = engine_id;
- Money runningCost = vehicle->GetRunningCost();
- delete vehicle;
- return runningCost >> 8;
+ return ::GetEngine(engine_id)->GetRunningCost();
}
/* static */ AIVehicle::VehicleType AIEngine::GetVehicleType(EngineID engine_id)
diff --git a/src/ai/api/ai_event_types.cpp b/src/ai/api/ai_event_types.cpp
index 09d801e70..9792f92f9 100644
--- a/src/ai/api/ai_event_types.cpp
+++ b/src/ai/api/ai_event_types.cpp
@@ -140,34 +140,7 @@ Money AIEventEnginePreview::GetPrice()
Money AIEventEnginePreview::GetRunningCost()
{
- /* We need to create an instance in order to obtain GetRunningCost.
- * This means we temporary allocate a vehicle in the pool, but
- * there is no other way.. */
- Vehicle *vehicle;
- switch (::GetEngine(engine)->type) {
- case VEH_ROAD: {
- vehicle = new RoadVehicle();
- } break;
-
- case VEH_TRAIN: {
- vehicle = new Train();
- } break;
-
- case VEH_SHIP: {
- vehicle = new Ship();
- } break;
-
- case VEH_AIRCRAFT: {
- vehicle = new Aircraft();
- } break;
-
- default: NOT_REACHED();
- }
-
- vehicle->engine_type = engine;
- Money runningCost = vehicle->GetRunningCost();
- delete vehicle;
- return runningCost >> 8;
+ return ::GetEngine(engine)->GetRunningCost();
}
AIVehicle::VehicleType AIEventEnginePreview::GetVehicleType()