]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/trainrouter.cpp
Get rid of the TrainAI tagging system
[r2c2.git] / source / libr2c2 / trainrouter.cpp
index 160c5b6a0c904cee6112608d033f9fef8bbe8c01..6e588e7a7ac4302c97db28f968fa1c8d04a01b27 100644 (file)
@@ -163,9 +163,6 @@ void TrainRouter::tick(const Time::TimeStamp &, const Time::TimeDelta &)
 
 void TrainRouter::save(list<DataFile::Statement> &st) const
 {
-       if(!tag.empty())
-               st.push_back((DataFile::Statement("tag"), tag));
-
        st.push_back((DataFile::Statement("priority"), priority));
 
        if(!routes.empty())
@@ -231,8 +228,7 @@ void TrainRouter::block_reserved(Block &block, Train *t)
                        bool exit_conflict = (exit==static_cast<unsigned>(other_entry));
                        // TODO: speed matching with preceding train
 
-                       // XXX Should invent a better way to get our counterpart from the other train
-                       TrainRouter *other_router = dynamic_cast<TrainRouter *>(other_train->get_tagged_ai("router"));
+                       TrainRouter *other_router = other_train->get_ai_of_type<TrainRouter>();
                        int other_prio = (other_router ? other_router->get_priority() : 0);
 
                        if(!entry_conflict && !exit_conflict && other_prio<priority)
@@ -283,10 +279,13 @@ void TrainRouter::train_advanced(Block &block)
                }
        }
 
-       BlockIter iter(&block, train.get_entry_to_block(block));
-       iter = iter.next();
-       if(iter && !is_on_route(*iter))
-               arriving = true;
+       if(!routes.empty())
+       {
+               BlockIter iter(&block, train.get_entry_to_block(block));
+               iter = iter.next();
+               if(iter && !is_on_route(*iter))
+                       arriving = true;
+       }
 }
 
 const Route *TrainRouter::get_route_for_block(const Block &block) const
@@ -346,7 +345,6 @@ TrainRouter::Loader::Loader(TrainRouter &r):
 {
        add("priority", &TrainRouter::priority);
        add("route",    &Loader::route);
-       add("tag",      &Loader::tag);
 }
 
 void TrainRouter::Loader::route(const string &n)
@@ -354,9 +352,4 @@ void TrainRouter::Loader::route(const string &n)
        obj.set_route(&obj.train.get_layout().get_route(n));
 }
 
-void TrainRouter::Loader::tag(const string &t)
-{
-       obj.set_tag(t);
-}
-
 } // namespace R2C2