// Update cur_blocks_end first to keep things consistent.
cur_blocks_end = end;
for(; i!=end; ++i)
- signal_advanced.emit(**i);
+ signal_advanced.emit(**i, (*i)->get_sensor());
}
void BlockAllocator::advance_front(const Sensor *sensor)
{
if(&sensor==next_sensor)
{
+ if(is_block_current(*block))
+ signal_advanced.emit(*block, &sensor);
update_next_sensor(next_sensor);
advance_front(next_sensor);
layout.get_driver().signal_loco_speed.connect(sigc::mem_fun(this, &Train::loco_speed_event));
layout.get_driver().signal_loco_function.connect(sigc::mem_fun(this, &Train::loco_func_event));
- layout.signal_sensor_state_changed.connect(sigc::mem_fun(this, &Train::sensor_state_changed));
-
layout.get_driver().signal_halt.connect(sigc::mem_fun(this, &Train::halt_event));
controller->signal_control_changed.connect(sigc::mem_fun(this, &Train::control_changed));
- allocator.signal_advanced.connect(signal_advanced);
+ allocator.signal_advanced.connect(sigc::mem_fun(this, &Train::advanced));
}
Train::~Train()
}
}
-void Train::sensor_state_changed(Sensor &sensor, Sensor::State state)
+void Train::advanced(Block &block, Sensor *sensor)
{
- if(!current_speed_step || state!=Sensor::MAYBE_ACTIVE)
- return;
+ if(!sensor || sensor==block.get_sensor())
+ signal_advanced.emit(block);
- Block *block = sensor.get_block();
- if(!block || block->get_train()!=this)
+ if(!sensor)
return;
- if(last_entry_block && &*last_entry_block!=block)
- {
- for(BlockIter i=last_entry_block.next(); (i && &*i!=block); i=i.next())
- if(i->get_train()!=this || i->get_sensor_address())
- return;
- }
-
- if(dynamic_cast<TrackCircuit *>(&sensor))
+ if(sensor==block.get_sensor())
{
if(last_entry_block && pure_speed && speed_quantizer)
{
float travel_distance = 0;
- for(BlockIter i=last_entry_block; &*i!=block; i=i.next())
+ for(BlockIter i=last_entry_block; &*i!=█ i=i.next())
travel_distance += i->get_path_length(i.entry());
if(travel_distance>0)
}
}
- last_entry_block = allocator.iter_for(*block);
+ last_entry_block = allocator.iter_for(block);
travel_time = Time::zero;
if(!layout.get_driver().is_halted())
{
vehicles.front()->place(track, VehiclePlacement::FRONT_AXLE);
}
}
- else if(BeamGate *gate = dynamic_cast<BeamGate *>(&sensor))
+ else if(BeamGate *gate = dynamic_cast<BeamGate *>(sensor))
{
if(!advancing && vehicles.front()->is_placed())
{
- TrackIter track = allocator.iter_for(*block).track_iter();
- for(; (track && &track->get_block()==block); track=track.next())
+ TrackIter track = allocator.iter_for(block).track_iter();
+ for(; (track && &track->get_block()==&block); track=track.next())
if(track.track()==gate->get_track())
{
if(reverse)
void control_changed(const Controller::Control &);
void loco_speed_event(unsigned, unsigned, bool);
void loco_func_event(unsigned, unsigned, bool);
- void sensor_state_changed(Sensor &, Sensor::State);
+ void advanced(Block &, Sensor *);
void halt_event(bool);
void block_reserved(const Block &, const Train *);
float get_reserved_distance_until(const Block *) const;