From: Mikko Rasa Date: Sun, 13 Dec 2009 11:35:20 +0000 (+0000) Subject: Handle position estimate when reversing the direction of a train X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=dcbe77ccf560aae2d10d645a02f6256fc0caf6f3;p=r2c2.git Handle position estimate when reversing the direction of a train --- diff --git a/source/libmarklin/train.cpp b/source/libmarklin/train.cpp index 9c56a5d..9300267 100644 --- a/source/libmarklin/train.cpp +++ b/source/libmarklin/train.cpp @@ -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)