From: Mikko Rasa Date: Sun, 7 Jul 2013 22:05:57 +0000 (+0300) Subject: Don't reset router to free run mode until allocator has deactivated X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=32739f060d1c025756b3ed702da1cbbdd6793064;hp=110a865e1a175f304ecaaa7a31b6985cf0c12a99;p=r2c2.git Don't reset router to free run mode until allocator has deactivated Setting route causes stop_at information to be cleared. If the allocator is still active when this happens, it will allocate more blocks. --- diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index 8de191b..100842b 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -14,7 +14,7 @@ namespace R2C2 { TrainRouter::TrainRouter(Train &t): TrainAI(t), priority(0), - arriving(false), + arriving(0), dest_zone(0), dest_block(0), update_pending(false) @@ -55,7 +55,7 @@ bool TrainRouter::set_route(const Route *r) if(r) routes.push_back(r); train.stop_at(0); - arriving = false; + arriving = 0; train.refresh_blocks_from(*fncb); @@ -142,12 +142,14 @@ void TrainRouter::tick(const Time::TimeDelta &) if(update_pending) create_plans(train.get_layout()); - if(arriving && !train.get_speed()) + if(arriving==1 && !train.get_speed()) { signal_arrived.emit(); signal_event.emit(Message("arrived")); - set_route(0); + arriving = 2; } + else if(arriving==2 && !train.get_block_allocator().is_active()) + set_route(0); } void TrainRouter::save(list &st) const @@ -223,7 +225,7 @@ void TrainRouter::train_advanced(Block &block) { b_iter = b_iter.next(); if(b_iter && !is_on_route(*b_iter)) - arriving = true; + arriving = 1; } } diff --git a/source/libr2c2/trainrouter.h b/source/libr2c2/trainrouter.h index 9938533..b36a013 100644 --- a/source/libr2c2/trainrouter.h +++ b/source/libr2c2/trainrouter.h @@ -40,7 +40,7 @@ private: int priority; RouteList routes; - bool arriving; + unsigned arriving; const Zone *dest_zone; const Block *dest_block; std::list waits;