summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_vehicle.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api/ai_vehicle.cpp')
-rw-r--r--src/ai/api/ai_vehicle.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp
index 5d1579364..3e30601fe 100644
--- a/src/ai/api/ai_vehicle.cpp
+++ b/src/ai/api/ai_vehicle.cpp
@@ -19,9 +19,8 @@
/* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
{
- if (!::Vehicle::IsValidID(vehicle_id)) return false;
- const Vehicle *v = ::Vehicle::Get(vehicle_id);
- return v->owner == _current_company && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::IsFreeWagon(v)));
+ const Vehicle *v = ::Vehicle::GetIfValid(vehicle_id);
+ return v != NULL && v->owner == _current_company && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::IsFreeWagon(v)));
}
/* static */ int32 AIVehicle::GetNumWagons(VehicleID vehicle_id)