string route_name(const Route *const &route)
{
- return route->get_name();
+ return route ? route->get_name() : "(none)";
}
RouterPanel::RouterPanel(Engineer &e, Train &t):
dynamic_cast<GLtk::Button *>(get_item(widgets, "btn_goto"))->signal_clicked.connect(sigc::mem_fun(this, &RouterPanel::goto_clicked));
+ routes.append(0);
const set<Route *> &lroutes = train.get_layout().get_all<Route>();
for(set<Route *>::const_iterator i=lroutes.begin(); i!=lroutes.end(); ++i)
- routes.append(*i);
+ if(!(*i)->is_temporary())
+ routes.append(*i);
TrainRouter *router = train.get_ai_of_type<TrainRouter>();
if(!router)
void RouterPanel::goto_clicked()
{
goto_pick = true;
+ goto_target = 0;
signal_grab_pointer.emit();
}
goto_highlight = 0;
if(goto_target && btn==1)
- train.ai_message(TrainAI::Message("set-destination-block", goto_target));
+ train.ai_message(TrainAI::Message("set-destination", static_cast<const TrackChain *>(goto_target)));
}
}
map_coords_to_ancestor(rx, ry, *find_ancestor<GLtk::Root>());
Ray ray = engineer.get_main_view().create_ray(rx, ry);
Track *track = engineer.get_layout().pick<Track>(ray);
- if(track)
+ if(track && &track->get_block()!=goto_target)
{
goto_target = &track->get_block();
delete goto_highlight;