]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/timetable.cpp
New routing system for trains
[r2c2.git] / source / libr2c2 / timetable.cpp
index 753aae83f719a2f453605a78f6dac417a7bcec30..44e859e9a5b9becbb3d943adc8bb198287428f1a 100644 (file)
@@ -88,15 +88,15 @@ void Timetable::tick(const Time::TimeStamp &t, const Time::TimeDelta &)
                {
                case GOTO_SENSOR:
                        arrived = false;
-                       train.ai_message(Message("go-to-track", &get_sensor(row.get_param<unsigned>(0))));
+                       train.ai_message(Message("set-destination-block", &get_sensor(row.get_param<unsigned>(0))));
                        break;
                case GOTO_ZONE:
                        arrived = false;
-                       train.ai_message(Message("go-to-zone", &get_zone(row.get_param<string>(0))));
+                       train.ai_message(Message("set-destination-zone", &get_zone(row.get_param<string>(0))));
                        break;
                case TRAVEL_TO:
                        {
-                               Block *block = &get_sensor(row.get_param<unsigned>(0)).get_block();
+                               Block *block = &get_sensor(row.get_param<unsigned>(0));
                                if(block->get_train()!=&train || block->get_state()<Block::MAYBE_ACTIVE)
                                {
                                        pending_block = block;
@@ -126,7 +126,7 @@ void Timetable::tick(const Time::TimeStamp &t, const Time::TimeDelta &)
                case WAIT_TRAIN:
                        {
                                Train *other_train = &train.get_layout().get_train(row.get_param<unsigned>(0));
-                               Block *block = &get_sensor(row.get_param<unsigned>(1)).get_block();
+                               Block *block = &get_sensor(row.get_param<unsigned>(1));
                                if(block->get_train()!=other_train || block->get_state()<Block::MAYBE_ACTIVE)
                                {
                                        pending_train = other_train;
@@ -166,10 +166,9 @@ void Timetable::save(list<DataFile::Statement> &st) const
                st.push_back(i->save());
 }
 
-Track &Timetable::get_sensor(unsigned id)
+Block &Timetable::get_sensor(unsigned id)
 {
-       Block &block = train.get_layout().get_block(id|0x1000);
-       return **block.get_tracks().begin();
+       return train.get_layout().get_block(id|0x1000);
 }
 
 Track &Timetable::get_turnout(unsigned id)