(svn r19880) -Fix: [NoAI] AIEngine::IsValidEngine() and AIEngine::IsBuildable() returned false positives. Especially wagons of unavailable railtypes were reported available.

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
frosch 14 years ago
parent 557c3f7daa
commit 03cacb797a

@ -2148,201 +2148,201 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 57 Engine 57
IsValidEngine(): true IsValidEngine(): false
GetName(): Passenger Carriage GetName(): (null : 0x00000000)
GetCargoType(): 0 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 45 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1447 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 25 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 58 Engine 58
IsValidEngine(): true IsValidEngine(): false
GetName(): Mail Van GetName(): (null : 0x00000000)
GetCargoType(): 2 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 35 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1335 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 21 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 59 Engine 59
IsValidEngine(): true IsValidEngine(): false
GetName(): Coal Truck GetName(): (null : 0x00000000)
GetCargoType(): 1 GetCargoType(): 255
CanRefitCargo(): true CanRefitCargo(): false
GetCapacity(): 35 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1031 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 18 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 60 Engine 60
IsValidEngine(): true IsValidEngine(): false
GetName(): Oil Tanker GetName(): (null : 0x00000000)
GetCargoType(): 3 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 35 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1171 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 24 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 61 Engine 61
IsValidEngine(): true IsValidEngine(): false
GetName(): Livestock Van GetName(): (null : 0x00000000)
GetCargoType(): 4 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 30 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1125 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 20 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 62 Engine 62
IsValidEngine(): true IsValidEngine(): false
GetName(): Goods Van GetName(): (null : 0x00000000)
GetCargoType(): 5 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 30 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1113 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 21 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 63 Engine 63
IsValidEngine(): true IsValidEngine(): false
GetName(): Grain Hopper GetName(): (null : 0x00000000)
GetCargoType(): 6 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 35 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1066 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 19 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 64 Engine 64
IsValidEngine(): true IsValidEngine(): false
GetName(): Wood Truck GetName(): (null : 0x00000000)
GetCargoType(): 7 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 35 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1060 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 16 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 65 Engine 65
IsValidEngine(): true IsValidEngine(): false
GetName(): Iron Ore Hopper GetName(): (null : 0x00000000)
GetCargoType(): 8 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 35 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1048 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 19 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 66 Engine 66
IsValidEngine(): true IsValidEngine(): false
GetName(): Steel Truck GetName(): (null : 0x00000000)
GetCargoType(): 9 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 25 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1148 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 18 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 67 Engine 67
IsValidEngine(): true IsValidEngine(): false
GetName(): Armoured Van GetName(): (null : 0x00000000)
GetCargoType(): 10 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 25 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1494 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 30 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 2 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 68 Engine 68
@ -2724,201 +2724,201 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 89 Engine 89
IsValidEngine(): true IsValidEngine(): false
GetName(): Passenger Carriage GetName(): (null : 0x00000000)
GetCargoType(): 0 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 47 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1447 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 25 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 90 Engine 90
IsValidEngine(): true IsValidEngine(): false
GetName(): Mail Van GetName(): (null : 0x00000000)
GetCargoType(): 2 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 37 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1335 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 21 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 91 Engine 91
IsValidEngine(): true IsValidEngine(): false
GetName(): Coal Truck GetName(): (null : 0x00000000)
GetCargoType(): 1 GetCargoType(): 255
CanRefitCargo(): true CanRefitCargo(): false
GetCapacity(): 37 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1031 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 18 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 92 Engine 92
IsValidEngine(): true IsValidEngine(): false
GetName(): Oil Tanker GetName(): (null : 0x00000000)
GetCargoType(): 3 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 37 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1171 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 24 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 93 Engine 93
IsValidEngine(): true IsValidEngine(): false
GetName(): Livestock Van GetName(): (null : 0x00000000)
GetCargoType(): 4 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 32 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1125 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 20 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 94 Engine 94
IsValidEngine(): true IsValidEngine(): false
GetName(): Goods Van GetName(): (null : 0x00000000)
GetCargoType(): 5 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 32 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1113 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 21 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 95 Engine 95
IsValidEngine(): true IsValidEngine(): false
GetName(): Grain Hopper GetName(): (null : 0x00000000)
GetCargoType(): 6 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 37 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1066 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 19 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 96 Engine 96
IsValidEngine(): true IsValidEngine(): false
GetName(): Wood Truck GetName(): (null : 0x00000000)
GetCargoType(): 7 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 37 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1060 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 16 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 97 Engine 97
IsValidEngine(): true IsValidEngine(): false
GetName(): Iron Ore Hopper GetName(): (null : 0x00000000)
GetCargoType(): 8 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 37 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1048 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 19 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 98 Engine 98
IsValidEngine(): true IsValidEngine(): false
GetName(): Steel Truck GetName(): (null : 0x00000000)
GetCargoType(): 9 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 27 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1148 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 18 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 99 Engine 99
IsValidEngine(): true IsValidEngine(): false
GetName(): Armoured Van GetName(): (null : 0x00000000)
GetCargoType(): 10 GetCargoType(): 255
CanRefitCargo(): false CanRefitCargo(): false
GetCapacity(): 27 GetCapacity(): -1
GetReliability(): -1 GetReliability(): -1
GetMaxSpeed(): 0 GetMaxSpeed(): -1
GetPrice(): 1494 GetPrice(): -1
GetMaxAge(): -1 GetMaxAge(): -1
GetRunningCost(): 0 GetRunningCost(): -1
GetPower(): -1 GetPower(): -1
GetWeight(): 30 GetWeight(): -1
GetMaxTractiveEffort(): -1 GetMaxTractiveEffort(): -1
GetVehicleType(): 0 GetVehicleType(): 255
GetRailType(): 3 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Engine 100 Engine 100
@ -5747,7 +5747,7 @@ ERROR: IsEnd() is invalid as Begin() is never called
GetRailType(): 255 GetRailType(): 255
GetRoadType(): -1 GetRoadType(): -1
GetPlaneType(): -1 GetPlaneType(): -1
Valid Engines: 53 Valid Engines: 31
--EngineList-- --EngineList--
Count(): 11 Count(): 11

@ -16,20 +16,21 @@
#include "../../strings_func.h" #include "../../strings_func.h"
#include "../../rail.h" #include "../../rail.h"
#include "../../engine_base.h" #include "../../engine_base.h"
#include "../../engine_func.h"
#include "../../articulated_vehicles.h" #include "../../articulated_vehicles.h"
#include "table/strings.h" #include "table/strings.h"
/* static */ bool AIEngine::IsValidEngine(EngineID engine_id) /* static */ bool AIEngine::IsValidEngine(EngineID engine_id)
{ {
const Engine *e = ::Engine::GetIfValid(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) /* static */ bool AIEngine::IsBuildable(EngineID engine_id)
{ {
const Engine *e = ::Engine::GetIfValid(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) /* static */ char *AIEngine::GetName(EngineID engine_id)

Loading…
Cancel
Save