]> git.tdb.fi Git - r2c2.git/commitdiff
Make further use of the traverse functions always returning a valid result
authorMikko Rasa <tdb@tdb.fi>
Tue, 22 Dec 2009 18:39:03 +0000 (18:39 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 22 Dec 2009 18:39:03 +0000 (18:39 +0000)
source/libmarklin/layout.cpp
source/libmarklin/train.cpp

index 67d646b1d5f542b1e5b156713c7ef79156660ba0..1df37d3d3ea6b742dfb75e7f893a1d7056426fa0 100644 (file)
@@ -145,9 +145,7 @@ void Layout::check_routes()
                Track *start = track;
                while(1)
                {
-                       int out_ep = track->traverse(ep, trk_path);
-                       if(out_ep<0)
-                               break;
+                       unsigned out_ep = track->traverse(ep, trk_path);
                        Track *next = track->get_links()[out_ep];
                        if(!next || next == start)
                                break;
index 330bb70e1fdd7de75a70e91e138c9a8d52e49e44..4beda974bf85d65f10c0547325038322aead6975 100644 (file)
@@ -156,17 +156,12 @@ void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt)
                offset += get_real_speed(loco.get_speed())*(dt/Time::sec);
                if(offset>cur_track->get_type().get_path_length(path))
                {
-                       int out = cur_track->traverse(cur_track_ep, path);
-                       if(out>=0)
-                       {
-                               Track *next = cur_track->get_link(out);
-                               if(next)
-                                       cur_track_ep = next->get_endpoint_by_link(*cur_track);
-                               cur_track = next;
-                               offset = 0;
-                       }
-                       else
-                               cur_track = 0;
+                       unsigned out = cur_track->traverse(cur_track_ep, path);
+                       Track *next = cur_track->get_link(out);
+                       if(next)
+                               cur_track_ep = next->get_endpoint_by_link(*cur_track);
+                       cur_track = next;
+                       offset = 0;
                }
 
                if(cur_track)