X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Frouterpanel.cpp;h=30857ceb7f9b0980de21ed0fce8e6fcc4b5493ef;hb=066170fbc56bb5bd33a5ce0b9b7b668a3f539ee6;hp=5097edaedf84046fc63765322c4cf8d6c1288a7f;hpb=62a0fdcdf9064f3b1748ffedc3e8de271cd4acbc;p=r2c2.git diff --git a/source/engineer/routerpanel.cpp b/source/engineer/routerpanel.cpp index 5097eda..30857ce 100644 --- a/source/engineer/routerpanel.cpp +++ b/source/engineer/routerpanel.cpp @@ -14,7 +14,7 @@ using namespace R2C2; string route_name(const Route *const &route) { - return route->get_name(); + return route ? route->get_name() : "(none)"; } RouterPanel::RouterPanel(Engineer &e, Train &t): @@ -36,9 +36,11 @@ RouterPanel::RouterPanel(Engineer &e, Train &t): dynamic_cast(get_item(widgets, "btn_goto"))->signal_clicked.connect(sigc::mem_fun(this, &RouterPanel::goto_clicked)); + routes.append(0); const set &lroutes = train.get_layout().get_all(); for(set::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(); if(!router) @@ -76,6 +78,7 @@ void RouterPanel::route_selected(unsigned index) void RouterPanel::goto_clicked() { goto_pick = true; + goto_target = 0; signal_grab_pointer.emit(); } @@ -92,7 +95,7 @@ void RouterPanel::button_press(int x, int y, unsigned btn) 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(goto_target))); } } @@ -107,7 +110,7 @@ void RouterPanel::pointer_motion(int x, int y) map_coords_to_ancestor(rx, ry, *find_ancestor()); Ray ray = engineer.get_main_view().create_ray(rx, ry); Track *track = engineer.get_layout().pick(ray); - if(track) + if(track && &track->get_block()!=goto_target) { goto_target = &track->get_block(); delete goto_highlight;