+
+ for(vector<const VehicleType *>::const_iterator i=add_vehicles.begin(); i!=add_vehicles.end(); ++i)
+ train->add_vehicle(**i);
+}
+
+void TrainProperties::new_vehicle_selected(unsigned n, const string &)
+{
+ if(n==0)
+ return;
+
+ const VehicleType &type = get_vehicle_type(n-1, false);
+ add_vehicles.push_back(&type);
+ lst_vehicles->append(format("%d %s", type.get_article_number(), type.get_name()));
+
+ drp_new_vehicle->set_selected_index(0);
+}
+
+const VehicleType &TrainProperties::get_vehicle_type(unsigned n, bool loco)
+{
+ const map<unsigned, VehicleType *> &vehs = engineer.get_catalogue().get_vehicles();
+ map<unsigned, VehicleType *>::const_iterator i = vehs.begin();
+ while(i!=vehs.end())
+ {
+ if(i->second->is_locomotive()==loco)
+ {
+ if(!n)
+ return *i->second;
+ --n;
+ }
+ ++i;
+ }
+
+ throw InvalidParameterValue("Vehicle type index out of range");