From: Mikko Rasa Date: Wed, 10 Jul 2013 18:39:34 +0000 (+0300) Subject: Use beam gates for positioning vehicles X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=0c1214ad0680c3bf65c1ee5f366dbafabc9d188d;p=r2c2.git Use beam gates for positioning vehicles --- diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index b5f600e..02e9d31 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -6,6 +6,7 @@ #include #include #include "aicontrol.h" +#include "beamgate.h" #include "block.h" #include "catalogue.h" #include "driver.h" @@ -475,6 +476,25 @@ void Train::sensor_state_changed(Sensor &sensor, Sensor::State state) vehicles.front()->place(track, 0, Vehicle::FRONT_AXLE); } } + else if(BeamGate *gate = dynamic_cast(&sensor)) + { + if(!advancing && vehicles.front()->get_track()) + { + TrackIter track = allocator.iter_for(*block).track_iter(); + for(; (track && &track->get_block()==block); track=track.next()) + if(track.track()==gate->get_track()) + { + if(reverse) + track = track.reverse(); + float offset = gate->get_offset_from_endpoint(track.entry()); + if(reverse) + vehicles.back()->place(track, offset, Vehicle::BACK_BUFFER); + else + vehicles.front()->place(track, offset, Vehicle::FRONT_BUFFER); + break; + } + } + } } void Train::halt_event(bool h)