+ DataFile::BasicLoader<Train>(t),
+ prev_block(0)
+{
+ add("block", &Loader::block);
+ add("block_hint", &Loader::block_hint);
+ add("name", &Loader::name);
+ add("priority", &Train::priority);
+ add("real_speed", &Loader::real_speed);
+ add("route", &Loader::route);
+ add("timetable", &Loader::timetable);
+ add("vehicle", &Loader::vehicle);
+}
+
+void Train::Loader::block(unsigned id)
+{
+ Block &blk = obj.layout.get_block(id);
+ int entry = -1;
+ if(prev_block)
+ entry = blk.get_endpoint_by_link(*prev_block);
+ if(entry<0)
+ entry = 0;
+
+ blk.reserve(&obj);
+ obj.cur_blocks.push_back(BlockRef(&blk, entry));
+ obj.set_status("Stopped");
+ const Block::Endpoint &bep = blk.get_endpoints()[entry];
+ obj.vehicles.front()->place(bep.track, bep.track_ep, 0, Vehicle::BACK_BUFFER);
+
+ if(blk.get_sensor_id())
+ obj.layout.get_driver().set_sensor(blk.get_sensor_id(), true);
+
+ prev_block = &blk;
+}
+
+void Train::Loader::block_hint(unsigned id)
+{
+ prev_block = &obj.layout.get_block(id);
+}
+
+void Train::Loader::name(const string &n)
+{
+ obj.set_name(n);
+}
+
+void Train::Loader::real_speed(unsigned i, float speed, float weight)
+{
+ obj.real_speed[i].speed = speed;
+ obj.real_speed[i].weight = weight;
+}
+
+void Train::Loader::route(const string &n)
+{
+ obj.set_route(&obj.layout.get_route(n));
+}
+
+void Train::Loader::timetable()
+{
+ if(obj.timetable)
+ throw InvalidState("A timetable has already been loaded");
+
+ obj.timetable = new Timetable(obj);
+ load_sub(*obj.timetable);
+}
+
+void Train::Loader::vehicle(unsigned n)