From cf643875a0aec0864901cd12795495bb8c6a5d75 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 2 Oct 2010 11:41:44 +0000 Subject: [PATCH] Fix vacated distance calculation when moving backwards Be consistent with vehicle placement when placing a train --- source/libmarklin/train.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/libmarklin/train.cpp b/source/libmarklin/train.cpp index d87d376..c3affef 100644 --- a/source/libmarklin/train.cpp +++ b/source/libmarklin/train.cpp @@ -272,7 +272,7 @@ void Train::place(Block &block, unsigned entry) else { const Block::Endpoint &bep = block.get_endpoints()[entry]; - vehicles.front()->place(bep.track, bep.track_ep, 0, Vehicle::BACK_BUFFER); + vehicles.back()->place(bep.track, bep.track_ep, 0, Vehicle::BACK_BUFFER); } } @@ -435,7 +435,10 @@ void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt) unsigned entry = bep.track_ep; bool found = false; - float dist = veh.get_offset()-veh.get_type().get_length()/2; + float dist = veh.get_offset(); + if(reverse) + dist = veh.get_track()->get_type().get_path_length(veh.get_track()->get_active_path())-dist; + dist -= veh.get_type().get_length()/2; while(1) { if(track==veh.get_track()) -- 2.45.2