]> git.tdb.fi Git - r2c2.git/commitdiff
Don't reset router to free run mode until allocator has deactivated
authorMikko Rasa <tdb@tdb.fi>
Sun, 7 Jul 2013 22:05:57 +0000 (01:05 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 7 Jul 2013 22:05:57 +0000 (01:05 +0300)
Setting route causes stop_at information to be cleared.  If the allocator
is still active when this happens, it will allocate more blocks.

source/libr2c2/trainrouter.cpp
source/libr2c2/trainrouter.h

index 8de191b70ef0ac6fcf5cae6e289d238e3038d35a..100842b6001fc44ebbf32a06e08ed0331f346189 100644 (file)
@@ -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<DataFile::Statement> &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;
        }
 }
 
index 9938533cc86dfd36b03ffc3a4932626ac55d19a7..b36a0135dfcde0850e6a5036cdea30d915ce00b4 100644 (file)
@@ -40,7 +40,7 @@ private:
 
        int priority;
        RouteList routes;
-       bool arriving;
+       unsigned arriving;
        const Zone *dest_zone;
        const Block *dest_block;
        std::list<Wait> waits;