]> git.tdb.fi Git - r2c2.git/commitdiff
Sync timetable on clock discontinuity
authorMikko Rasa <tdb@tdb.fi>
Sun, 29 Mar 2015 22:29:48 +0000 (01:29 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 29 Mar 2015 22:29:48 +0000 (01:29 +0300)
source/libr2c2/clock.cpp
source/libr2c2/clock.h
source/libr2c2/timetable.cpp
source/libr2c2/timetable.h

index 286ce966873af6b6735398ba1e5908f879460eda..6812aeba109bb05f10f3038c30ac19777a88dc39 100644 (file)
@@ -18,6 +18,7 @@ void Clock::set_rate(float s)
 void Clock::set_current_time(const Time::TimeDelta &t)
 {
        current_time = t;
+       signal_discontinuity.emit();
 }
 
 void Clock::stop(bool s)
index 469d1916e1de77667cb57bb74b84a719c9da0540..621cb2d5df1afa5dcda619d3a60c04337099ceb1 100644 (file)
@@ -20,6 +20,7 @@ public:
        };
 
        sigc::signal<void> signal_minute;
+       sigc::signal<void> signal_discontinuity;
 
 private:
        Msp::Time::TimeDelta current_time;
index 5fa36395825d0afdb6dfb92df83e76f97d3cd6cb..41cbbf00ab834350714025c865853d54462c4796 100644 (file)
@@ -25,6 +25,7 @@ Timetable::Timetable(Train &t):
                new TrainRouter(train);
 
        train.signal_ai_event.connect(sigc::mem_fun(this, &Timetable::event));
+       train.get_layout().get_clock().signal_discontinuity.connect(sigc::mem_fun(this, &Timetable::clock_discontinuity));
 }
 
 void Timetable::append_row(const Row &r)
@@ -229,6 +230,12 @@ void Timetable::record_time()
        signal_row_modified.emit(i, *current_row);
 }
 
+void Timetable::clock_discontinuity()
+{
+       update_pending = true;
+       sync_to_clock = true;
+}
+
 
 Timetable::Row::Row():
        type(ARRIVE),
index 3d7622aeb918c8ac35462df46e28cdc105548964..75572490665ae80d66a670cc6f42131cdb68dcf6 100644 (file)
@@ -98,6 +98,7 @@ private:
        void update_route();
        void event(TrainAI &, const Message &);
        void record_time();
+       void clock_discontinuity();
 };
 
 } // namespace R2C2