]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/layout.cpp
Handle reversing in a way that allows backing out of a dead end
[r2c2.git] / source / libmarklin / layout.cpp
index af88d7d8fd2e35f3a44af86ff24640c85c003d1d..e67fbc26ebc0443440900293bd72555184e439f0 100644 (file)
@@ -237,6 +237,9 @@ void Layout::save(const string &fn)
 
        for(map<string, Route *>::iterator i=routes.begin(); i!=routes.end(); ++i)
        {
+               if(i->second->is_temporary())
+                       continue;
+
                DataFile::Statement st("route");
                st.append(i->first);
                i->second->save(st.sub);
@@ -287,6 +290,9 @@ void Layout::check_routes()
 {
        for(map<string, Route *>::iterator i=routes.begin(); i!=routes.end(); ++i)
        {
+               if(i->second->is_temporary())
+                       continue;
+
                /* We must copy the turnout map, since adding tracks to the route will
                (temporarily) mess it up */
                const map<unsigned, int> turnouts = i->second->get_turnouts();
@@ -322,6 +328,8 @@ void Layout::check_routes()
                while(1)
                {
                        // Traverse the track and get the next one
+                       if(track->get_type().get_endpoints().size()<2)
+                               break;
                        unsigned out_ep = track->traverse(ep, trk_path);
                        Track *next = track->get_links()[out_ep];
                        if(!next || next == start)