From: Mikko Rasa Date: Fri, 4 Apr 2014 16:40:10 +0000 (+0300) Subject: Allow queueing multiple routes for a train X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b68d1d4f2be93a405170e7caca05760ca473dcc6;p=r2c2.git Allow queueing multiple routes for a train --- diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index 93dbedf..508a7b1 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -80,6 +80,17 @@ bool TrainRouter::set_route(const Route *r) return true; } +bool TrainRouter::add_route(const Route &r) +{ + if(routes.empty()) + return set_route(&r); + + // TODO Check that it can be reached from previous routes + routes.push_back(&r); + + return true; +} + void TrainRouter::add_wait(Block &block, Train *tr) { Wait wait; diff --git a/source/libr2c2/trainrouter.h b/source/libr2c2/trainrouter.h index c69d28c..c1b6977 100644 --- a/source/libr2c2/trainrouter.h +++ b/source/libr2c2/trainrouter.h @@ -58,6 +58,7 @@ public: int get_priority() const { return priority; } bool set_route(const Route *); + bool add_route(const Route &); void add_wait(Block &, Train *); const Route *get_route() const;