summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-12-21 13:53:19 +0000
committerterkhen <terkhen@openttd.org>2010-12-21 13:53:19 +0000
commit8fc48a79dae5d60a8b1c3db7d663f1188e2aba2c (patch)
treed3d556de79228ee87ffda7f81eb2a8170f6170aa /src
parenta1ff6859c501dd90152b912f748d2b452d745acc (diff)
downloadopenttd-8fc48a79dae5d60a8b1c3db7d663f1188e2aba2c.tar.xz
(svn r21562) -Change: Add articulated parts of vehicles in a refit selection to that selection.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 94a4c488f..e1065f823 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2269,9 +2269,28 @@ const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles)
{
if (v->type == VEH_TRAIN) {
- for (Train *u = Train::From(v); u != NULL && num_vehicles > 0; num_vehicles--, u = u->Next()) {
+ Train *u = Train::From(v);
+ /* If the first vehicle in the selection is part of an articulated vehicle, add the previous parts of the vehicle. */
+ if (u->IsArticulatedPart()) {
+ u = u->GetFirstEnginePart();
+ while (u->index != v->index) {
+ set.Include(u->index);
+ u = u->GetNextArticPart();
+ }
+ }
+
+ for (;u != NULL && num_vehicles > 0; num_vehicles--, u = u->Next()) {
/* Include current vehicle in the selection. */
set.Include(u->index);
+
+ /* If the vehicle is multiheaded, add the other part too. */
+ if (u->IsMultiheaded()) set.Include(u->other_multiheaded_part->index);
+ }
+
+ /* If the last vehicle is part of an articulated vehicle, add the following parts of the vehicle. */
+ while (u != NULL && u->IsArticulatedPart()) {
+ set.Include(u->index);
+ u = u->Next();
}
}
}