From: Mikko Rasa Date: Sun, 22 Mar 2015 16:02:25 +0000 (+0200) Subject: Cosmetic tweaks X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5ec71ac8d091bb70e70528138bba9edaccc7f55d;p=r2c2.git Cosmetic tweaks --- diff --git a/source/libr2c2/trackchain.cpp b/source/libr2c2/trackchain.cpp index c6d615d..e661ed4 100644 --- a/source/libr2c2/trackchain.cpp +++ b/source/libr2c2/trackchain.cpp @@ -150,7 +150,7 @@ TrackIter TrackChain::iter_for(Track &t, Direction d) const TrackIter TrackChain::get_end(unsigned i) const { if(i>=2) - throw invalid_argument("TrackChain::get_end"); + throw out_of_range("TrackChain::get_end"); if(!ends[0]) return TrackIter(); diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index ad97cf7..7e179f3 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -498,9 +498,11 @@ void TrainRoutePlanner::TrainRoutingState::advance(const Time::TimeDelta &dt) void TrainRoutePlanner::TrainRoutingState::advance_track(unsigned next_path) { float distance = occupied_tracks->path_length-offset; + track = track.next(path); path = next_path; occupied_tracks = new OccupiedTrack(*track, path, occupied_tracks); + advance(distance); offset = 0; } diff --git a/source/libr2c2/zone.cpp b/source/libr2c2/zone.cpp index de77443..e2a5177 100644 --- a/source/libr2c2/zone.cpp +++ b/source/libr2c2/zone.cpp @@ -147,16 +147,6 @@ TrackIter Zone::iter_for(Track &track, Direction dir) const return TrackIter(); } -TrackIter Zone::get_end(Direction dir) const -{ - if(dir==UNSPECIFIED) - return ends[0]; - if(up_end<0) - return TrackIter(); - - return ends[up_end^(dir==DOWN)]; -} - TrackIter Zone::next_iter(const TrackIter &iter) const { TrackIter next_outside; @@ -174,6 +164,16 @@ TrackIter Zone::next_iter(const TrackIter &iter) const return next_outside; } +TrackIter Zone::get_end(Direction dir) const +{ + if(dir==UNSPECIFIED) + return ends[0]; + if(up_end<0) + return TrackIter(); + + return ends[up_end^(dir==DOWN)]; +} + void Zone::save(list &st) const { st.push_back((DataFile::Statement("group"), group));