next = &veh;
veh.prev = this;
+
+ if(track_pos.track)
+ propagate_backward();
}
void Vehicle::attach_front(Vehicle &veh)
if(prev || veh.next)
throw InvalidState("Already attached");
- next = &veh;
- veh.prev = this;
+ prev = &veh;
+ veh.next = this;
+
+ if(prev->get_track())
+ prev->propagate_backward();
}
void Vehicle::detach_back()
{
/* Sensor ID under axle has changed. Deduce movement direction by using
the sensor ID under the midpoint of the vehicle. */
+ /* XXX This depends on the simulation running fast enough. Something
+ more robust would be preferable. */
unsigned old = sensor;
sensor = s;
unsigned mid = track_pos.track->get_sensor_id();
if(s && s!=mid)
/* There's a sensor and it's different from mid. We've just entered
that sensor. */
- // XXX The Train will reset the vehicles to the start of the sensor, which is somewhat undesirable
layout.get_driver().set_sensor(sensor, true);
if(old && old!=mid)
/* A sensor was under the axle and it was different from mid. We've