]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/timetable.h
Sync timetable to clock on first tick
[r2c2.git] / source / libr2c2 / timetable.h
index b67e5fb3c2baa4761b639dae6a55e3902795e014..3385a8eeaf97de6a3142d868a436d01d0125f22e 100644 (file)
@@ -7,7 +7,7 @@
 namespace R2C2 {
 
 class Layout;
-class Zone;
+class TrackChain;
 
 class Timetable: public TrainAI
 {
@@ -27,7 +27,8 @@ public:
        enum RowType
        {
                ARRIVE = 1,
-               DEPART
+               DEPART,
+               THROUGH
        };
 
        struct Row
@@ -41,12 +42,13 @@ public:
                        Loader(Row &, Layout &);
 
                private:
-                       void zone(const std::string &, unsigned);
+                       void block(unsigned);
                        void time(Msp::Time::RawTime);
+                       void zone(const std::string &, unsigned);
                };
 
                RowType type;
-               Zone *zone;
+               TrackChain *target;
                Msp::Time::TimeDelta time;
 
                Row();
@@ -54,6 +56,15 @@ public:
                void save(std::list<Msp::DataFile::Statement> &) const;
        };
 
+       struct RowTypeMatch
+       {
+               RowType type;
+
+               RowTypeMatch(RowType t): type(t) { }
+
+               bool operator()(const Row &r) const { return r.type==type; }
+       };
+
        sigc::signal<void, unsigned, const Row &> signal_row_added;
        sigc::signal<void, unsigned, const Row &> signal_row_modified;
        sigc::signal<void, unsigned> signal_row_removed;
@@ -62,6 +73,7 @@ private:
        std::list<Row> rows;
        std::list<Row>::iterator current_row;
        bool update_pending;
+       bool sync_to_clock;
 
 public:
        Timetable(Train &);
@@ -80,8 +92,10 @@ public:
 
 private:
        void check_update(std::list<Row>::const_iterator);
+       std::list<Row>::iterator find_trip(const std::list<Row>::iterator &, std::list<Row>::iterator *);
        void update_route();
        void event(TrainAI &, const Message &);
+       void record_time();
 };
 
 } // namespace R2C2