X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Frouteselect.cpp;h=6cda460c810652b42b5adb89641f6093ffe347fd;hb=e9653dffd0026fb3c02c91a4c0feca688a86c721;hp=8b526aeab75b80fdb42613c0ce90346c0cea2dab;hpb=7587f018794f53974409a2aad76a0a421cea2d24;p=r2c2.git diff --git a/source/engineer/routeselect.cpp b/source/engineer/routeselect.cpp index 8b526ae..6cda460 100644 --- a/source/engineer/routeselect.cpp +++ b/source/engineer/routeselect.cpp @@ -32,12 +32,14 @@ RouteSelect::RouteSelect(Engineer &e, const GLtk::Resources &r, Train &t): drp_route->set_selected_index(0); const set &routes = engineer.get_layout().get_routes(); unsigned n = 1; - for(set::const_iterator i=routes.begin(); i!=routes.end(); ++i, ++n) - { - drp_route->append((*i)->get_name()); - if(*i==train.get_route()) - drp_route->set_selected_index(n); - } + for(set::const_iterator i=routes.begin(); i!=routes.end(); ++i) + if(!(*i)->is_temporary()) + { + drp_route->append((*i)->get_name()); + if(*i==train.get_route()) + drp_route->set_selected_index(n); + ++n; + } } void RouteSelect::on_ok_clicked() @@ -46,7 +48,17 @@ void RouteSelect::on_ok_clicked() { const set &routes = engineer.get_layout().get_routes(); set::const_iterator i = routes.begin(); - advance(i, drp_route->get_selected_index()-1); + unsigned n = drp_route->get_selected_index()-1; + while(i!=routes.end()) + { + if(!(*i)->is_temporary()) + { + if(!n) + break; + --n; + } + ++i; + } train.set_route(*i); }