* Determines whether an engine can carry something. * A vehicle cannot carry anything if its capacity is zero, or none of the possible cargoes is available in the climate. * @return true if the vehicle can carry something. */
| 165 | * @return true if the vehicle can carry something. |
| 166 | */ |
| 167 | bool Engine::CanCarryCargo() const |
| 168 | { |
| 169 | /* For engines that can appear in a consist (i.e. rail vehicles and (articulated) road vehicles), a capacity |
| 170 | * of zero is a special case, to define the vehicle to not carry anything. The default cargotype is still used |
| 171 | * for livery selection etc. |
| 172 | * Note: Only the property is tested. A capacity callback returning 0 does not have the same effect. |
| 173 | */ |
| 174 | switch (this->type) { |
| 175 | case VEH_TRAIN: |
| 176 | if (this->VehInfo<RailVehicleInfo>().capacity == 0) return false; |
| 177 | break; |
| 178 | |
| 179 | case VEH_ROAD: |
| 180 | if (this->VehInfo<RoadVehicleInfo>().capacity == 0) return false; |
| 181 | break; |
| 182 | |
| 183 | case VEH_SHIP: |
| 184 | case VEH_AIRCRAFT: |
| 185 | break; |
| 186 | |
| 187 | default: NOT_REACHED(); |
| 188 | } |
| 189 | return IsValidCargoType(this->GetDefaultCargoType()); |
| 190 | } |
| 191 | |
| 192 | |
| 193 | /** |
no test coverage detected