]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/train.cpp
Add utility functions to make endpoint path mask operations clearer
[r2c2.git] / source / libr2c2 / train.cpp
index a45675c90c146e078427bb754848b6b907d806d5..eb1133a565e2d94ff4c1f2ea91eae290e8f2fae1 100644 (file)
@@ -674,7 +674,7 @@ void Train::reserve_more()
        else if(&*start==pending_block)
        {
                TrackIter track = start.track_iter();
-               if(!(track.endpoint().paths&(1<<track->get_active_path())))
+               if(!track.endpoint().has_path(track->get_active_path()))
                        return;
        }
 
@@ -736,11 +736,12 @@ void Train::reserve_more()
                {
                        const TrackType::Endpoint &entry_ep = track.endpoint();
                        unsigned path = track->get_active_path();
-                       if(!(entry_ep.paths&(1<<path)))
+                       if(!entry_ep.has_path(path))
                        {
                                const TrackType::Endpoint &exit_ep = track.reverse().endpoint();
-                               if(unsigned mask = entry_ep.paths&exit_ep.paths)
+                               if(entry_ep.has_common_paths(exit_ep))
                                {
+                                       unsigned mask = entry_ep.paths&exit_ep.paths;
                                        for(path=0; mask>1; ++path, mask>>=1) ;
 
                                        track->set_active_path(path);