From dcbe77ccf560aae2d10d645a02f6256fc0caf6f3 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 13 Dec 2009 11:35:20 +0000 Subject: [PATCH] Handle position estimate when reversing the direction of a train --- source/libmarklin/train.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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) -- 2.43.0