summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-12-21 13:52:10 +0000
committerterkhen <terkhen@openttd.org>2010-12-21 13:52:10 +0000
commita1ff6859c501dd90152b912f748d2b452d745acc (patch)
tree829b9c33e44e4bf29009bc300a915d1e6579572c /src/vehicle.cpp
parentd92f29b8221e06d24df0416ae1609e8588e0b2c3 (diff)
downloadopenttd-a1ff6859c501dd90152b912f748d2b452d745acc.tar.xz
(svn r21561) -Change: Allow to specify the number of vehicles to refit in the refit vehicle command.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r--src/vehicle.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index cb915a6f7..94a4c488f 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2257,3 +2257,21 @@ const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const
return &RoadVehicle::From(this)->gcache;
}
}
+
+/**
+ * Calculates the set of vehicles that will be affected by a given selection.
+ * @param set Set of affected vehicles.
+ * @param v First vehicle of the selection.
+ * @param num_vehicles Number of vehicles in the selection.
+ * @pre \c set must be empty.
+ * @post \c set will contain the vehicles that will be refitted.
+ */
+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()) {
+ /* Include current vehicle in the selection. */
+ set.Include(u->index);
+ }
+ }
+}