changeset 15245:faa8301e9a4e draft

(svn r19880) -Fix: [NoAI] AIEngine::IsValidEngine() and AIEngine::IsBuildable() returned false positives. Especially wagons of unavailable railtypes were reported available.
author frosch <frosch@openttd.org>
date Sat, 22 May 2010 12:25:47 +0000
parents e72aea2333da
children 152d217137f1
files bin/ai/regression/regression.txt src/ai/api/ai_engine.cpp
diffstat 2 files changed, 334 insertions(+), 333 deletions(-) [+]
line wrap: on
line diff
--- a/bin/ai/regression/regression.txt
+++ b/bin/ai/regression/regression.txt
@@ -2148,201 +2148,201 @@
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 57
-    IsValidEngine():    true
-    GetName():          Passenger Carriage
-    GetCargoType():     0
-    CanRefitCargo():    false
-    GetCapacity():      45
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1447
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        25
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 58
-    IsValidEngine():    true
-    GetName():          Mail Van
-    GetCargoType():     2
-    CanRefitCargo():    false
-    GetCapacity():      35
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1335
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        21
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 59
-    IsValidEngine():    true
-    GetName():          Coal Truck
-    GetCargoType():     1
-    CanRefitCargo():    true
-    GetCapacity():      35
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1031
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        18
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 60
-    IsValidEngine():    true
-    GetName():          Oil Tanker
-    GetCargoType():     3
-    CanRefitCargo():    false
-    GetCapacity():      35
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1171
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        24
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 61
-    IsValidEngine():    true
-    GetName():          Livestock Van
-    GetCargoType():     4
-    CanRefitCargo():    false
-    GetCapacity():      30
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1125
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        20
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 62
-    IsValidEngine():    true
-    GetName():          Goods Van
-    GetCargoType():     5
-    CanRefitCargo():    false
-    GetCapacity():      30
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1113
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        21
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 63
-    IsValidEngine():    true
-    GetName():          Grain Hopper
-    GetCargoType():     6
-    CanRefitCargo():    false
-    GetCapacity():      35
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1066
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        19
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 64
-    IsValidEngine():    true
-    GetName():          Wood Truck
-    GetCargoType():     7
-    CanRefitCargo():    false
-    GetCapacity():      35
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1060
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        16
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 65
-    IsValidEngine():    true
-    GetName():          Iron Ore Hopper
-    GetCargoType():     8
-    CanRefitCargo():    false
-    GetCapacity():      35
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1048
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        19
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 66
-    IsValidEngine():    true
-    GetName():          Steel Truck
-    GetCargoType():     9
-    CanRefitCargo():    false
-    GetCapacity():      25
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1148
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        18
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 67
-    IsValidEngine():    true
-    GetName():          Armoured Van
-    GetCargoType():     10
-    CanRefitCargo():    false
-    GetCapacity():      25
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1494
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        30
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      2
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 68
@@ -2724,201 +2724,201 @@
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 89
-    IsValidEngine():    true
-    GetName():          Passenger Carriage
-    GetCargoType():     0
-    CanRefitCargo():    false
-    GetCapacity():      47
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1447
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        25
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 90
-    IsValidEngine():    true
-    GetName():          Mail Van
-    GetCargoType():     2
-    CanRefitCargo():    false
-    GetCapacity():      37
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1335
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        21
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 91
-    IsValidEngine():    true
-    GetName():          Coal Truck
-    GetCargoType():     1
-    CanRefitCargo():    true
-    GetCapacity():      37
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1031
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        18
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 92
-    IsValidEngine():    true
-    GetName():          Oil Tanker
-    GetCargoType():     3
-    CanRefitCargo():    false
-    GetCapacity():      37
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1171
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        24
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 93
-    IsValidEngine():    true
-    GetName():          Livestock Van
-    GetCargoType():     4
-    CanRefitCargo():    false
-    GetCapacity():      32
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1125
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        20
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 94
-    IsValidEngine():    true
-    GetName():          Goods Van
-    GetCargoType():     5
-    CanRefitCargo():    false
-    GetCapacity():      32
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1113
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        21
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 95
-    IsValidEngine():    true
-    GetName():          Grain Hopper
-    GetCargoType():     6
-    CanRefitCargo():    false
-    GetCapacity():      37
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1066
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        19
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 96
-    IsValidEngine():    true
-    GetName():          Wood Truck
-    GetCargoType():     7
-    CanRefitCargo():    false
-    GetCapacity():      37
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1060
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        16
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 97
-    IsValidEngine():    true
-    GetName():          Iron Ore Hopper
-    GetCargoType():     8
-    CanRefitCargo():    false
-    GetCapacity():      37
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1048
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        19
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 98
-    IsValidEngine():    true
-    GetName():          Steel Truck
-    GetCargoType():     9
-    CanRefitCargo():    false
-    GetCapacity():      27
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1148
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        18
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 99
-    IsValidEngine():    true
-    GetName():          Armoured Van
-    GetCargoType():     10
-    CanRefitCargo():    false
-    GetCapacity():      27
-    GetReliability():   -1
-    GetMaxSpeed():      0
-    GetPrice():         1494
-    GetMaxAge():        -1
-    GetRunningCost():   0
-    GetPower():         -1
-    GetWeight():        30
-    GetMaxTractiveEffort(): -1
-    GetVehicleType():   0
-    GetRailType():      3
+    IsValidEngine():    false
+    GetName():          (null : 0x00000000)
+    GetCargoType():     255
+    CanRefitCargo():    false
+    GetCapacity():      -1
+    GetReliability():   -1
+    GetMaxSpeed():      -1
+    GetPrice():         -1
+    GetMaxAge():        -1
+    GetRunningCost():   -1
+    GetPower():         -1
+    GetWeight():        -1
+    GetMaxTractiveEffort(): -1
+    GetVehicleType():   255
+    GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
   Engine 100
@@ -5747,7 +5747,7 @@
     GetRailType():      255
     GetRoadType():      -1
     GetPlaneType():     -1
-  Valid Engines:        53
+  Valid Engines:        31
 
 --EngineList--
   Count():             11
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -16,20 +16,21 @@
 #include "../../strings_func.h"
 #include "../../rail.h"
 #include "../../engine_base.h"
+#include "../../engine_func.h"
 #include "../../articulated_vehicles.h"
 #include "table/strings.h"
 
 /* static */ bool AIEngine::IsValidEngine(EngineID engine_id)
 {
 	const Engine *e = ::Engine::GetIfValid(engine_id);
-	return e != NULL && (HasBit(e->company_avail, _current_company) || ::Company::Get(_current_company)->num_engines[engine_id] > 0);
+	return e != NULL && (::IsEngineBuildable(engine_id, e->type, _current_company) || ::Company::Get(_current_company)->num_engines[engine_id] > 0);
 
 }
 
 /* static */ bool AIEngine::IsBuildable(EngineID engine_id)
 {
 	const Engine *e = ::Engine::GetIfValid(engine_id);
-	return e != NULL && HasBit(e->company_avail, _current_company);
+	return e != NULL && ::IsEngineBuildable(engine_id, e->type, _current_company);
 }
 
 /* static */ char *AIEngine::GetName(EngineID engine_id)