diff -r 13e73691378a -r b18d1d5b047d src/ai/api/ai_vehicle.cpp --- a/src/ai/api/ai_vehicle.cpp Tue Apr 15 15:05:30 2008 +0000 +++ b/src/ai/api/ai_vehicle.cpp Tue Apr 15 15:32:47 2008 +0000 @@ -227,3 +227,28 @@ } } +/* static */ int32 AIVehicle::GetCapacity(VehicleID vehicle_id, CargoID cargo) +{ + if (!IsValidVehicle(vehicle_id)) return -1; + if (!AICargo::IsValidCargo(cargo)) return -1; + + uint32 amount = 0; + for (const Vehicle *v = ::GetVehicle(vehicle_id); v != NULL; v = v->Next()) { + if (v->cargo_type == cargo) amount += v->cargo_cap; + } + + return amount; +} + +/* static */ int32 AIVehicle::GetCargoLoad(VehicleID vehicle_id, CargoID cargo) +{ + if (!IsValidVehicle(vehicle_id)) return -1; + if (!AICargo::IsValidCargo(cargo)) return -1; + + uint32 amount = 0; + for (const Vehicle *v = ::GetVehicle(vehicle_id); v != NULL; v = v->Next()) { + if (v->cargo_type == cargo) amount += v->cargo.Count(); + } + + return amount; +}