From: Mikko Rasa Date: Sat, 2 Oct 2010 11:41:44 +0000 (+0000) Subject: Fix vacated distance calculation when moving backwards X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=cf643875a0aec0864901cd12795495bb8c6a5d75;p=r2c2.git Fix vacated distance calculation when moving backwards Be consistent with vehicle placement when placing a train --- 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())