* Calculates the set of vehicles that will be affected by a given selection. * @param[in,out] set Set of affected vehicles. * @param v First vehicle of the selection. * @param num_vehicles Number of vehicles in the selection (not counting articulated parts). * @pre \a set must be empty. * @post \a set will contain the vehicles that will be refitted. */
| 3204 | * @post \a set will contain the vehicles that will be refitted. |
| 3205 | */ |
| 3206 | void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8_t num_vehicles) |
| 3207 | { |
| 3208 | if (v->type == VEH_TRAIN) { |
| 3209 | Train *u = Train::From(v); |
| 3210 | /* Only include whole vehicles, so start with the first articulated part */ |
| 3211 | u = u->GetFirstEnginePart(); |
| 3212 | |
| 3213 | /* Include num_vehicles vehicles, not counting articulated parts */ |
| 3214 | for (; u != nullptr && num_vehicles > 0; num_vehicles--) { |
| 3215 | do { |
| 3216 | /* Include current vehicle in the selection. */ |
| 3217 | include(set, u->index); |
| 3218 | |
| 3219 | /* If the vehicle is multiheaded, add the other part too. */ |
| 3220 | if (u->IsMultiheaded()) include(set, u->other_multiheaded_part->index); |
| 3221 | |
| 3222 | u = u->Next(); |
| 3223 | } while (u != nullptr && u->IsArticulatedPart()); |
| 3224 | } |
| 3225 | } |
| 3226 | } |
| 3227 | |
| 3228 | /** |
| 3229 | * Calculates the maximum weight of the ground vehicle when loaded. |
no test coverage detected