+ unsigned tid = turnout->get_address();
+ for(list<BlockRef>::const_iterator i=cur_blocks.begin(); i!=cur_blocks.end(); ++i)
+ if(i->block->get_turnout_id()==tid)
+ throw TurnoutBusy(this);
+
+ unsigned nsens = 0;
+ for(list<BlockRef>::const_iterator i=rsv_blocks.begin(); i!=rsv_blocks.end(); ++i)
+ {
+ if(i->block->get_turnout_id()==tid)
+ {
+ if(nsens<1)
+ throw TurnoutBusy(this);
+ break;
+ }
+ else if(i->block->get_sensor_id())
+ ++nsens;
+ }
+}
+
+void Train::turnout_route_changed(unsigned, Turnout *turnout)
+{
+ unsigned tid = turnout->get_address();
+ for(list<BlockRef>::iterator i=rsv_blocks.begin(); i!=rsv_blocks.end(); ++i)
+ if(i->block->get_turnout_id()==tid)
+ {
+ while(i!=rsv_blocks.end())
+ {
+ i->block->reserve(0);
+ i = rsv_blocks.erase(i);
+ }
+ reserve_more();
+ update_speed();
+ return;
+ }
+}
+
+unsigned Train::reserve_more()
+{
+ BlockRef *last = 0;