]> git.tdb.fi Git - r2c2.git/commitdiff
Handle position estimate when reversing the direction of a train
authorMikko Rasa <tdb@tdb.fi>
Sun, 13 Dec 2009 11:35:20 +0000 (11:35 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 13 Dec 2009 11:35:20 +0000 (11:35 +0000)
source/libmarklin/train.cpp

index 9c56a5ddb5fc4f46147bad8645698c940683b22e..9300267331c4e0c1f68c086f014ce5696605467b 100644 (file)
@@ -183,6 +183,15 @@ void Train::locomotive_reverse_changed(bool)
                i->entry = i->block->traverse(i->entry);
        reserve_more();
        update_speed();
+
+       if(cur_track)
+       {
+               unsigned route = 0;
+               if(unsigned turnout = cur_track->get_turnout_id())
+                       route = trfc_mgr.get_control().get_turnout(turnout).get_route();
+               cur_track_ep = cur_track->traverse(cur_track_ep, route);
+               offset = cur_track->get_type().get_route_length(route)-offset;
+       }
 }
 
 void Train::sensor_event(bool state, Sensor *sensor)