From b68d1d4f2be93a405170e7caca05760ca473dcc6 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 4 Apr 2014 19:40:10 +0300 Subject: [PATCH] Allow queueing multiple routes for a train --- source/libr2c2/trainrouter.cpp | 11 +++++++++++ source/libr2c2/trainrouter.h | 1 + 2 files changed, 12 insertions(+) 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; -- 2.43.0