From: Mikko Rasa Date: Sun, 29 Mar 2015 22:29:48 +0000 (+0300) Subject: Sync timetable on clock discontinuity X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=dfeb2d2896fe18e55b1f6c4a8028b7cfb878dede;p=r2c2.git Sync timetable on clock discontinuity --- diff --git a/source/libr2c2/clock.cpp b/source/libr2c2/clock.cpp index 286ce96..6812aeb 100644 --- a/source/libr2c2/clock.cpp +++ b/source/libr2c2/clock.cpp @@ -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) diff --git a/source/libr2c2/clock.h b/source/libr2c2/clock.h index 469d191..621cb2d 100644 --- a/source/libr2c2/clock.h +++ b/source/libr2c2/clock.h @@ -20,6 +20,7 @@ public: }; sigc::signal signal_minute; + sigc::signal signal_discontinuity; private: Msp::Time::TimeDelta current_time; diff --git a/source/libr2c2/timetable.cpp b/source/libr2c2/timetable.cpp index 5fa3639..41cbbf0 100644 --- a/source/libr2c2/timetable.cpp +++ b/source/libr2c2/timetable.cpp @@ -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), diff --git a/source/libr2c2/timetable.h b/source/libr2c2/timetable.h index 3d7622a..7557249 100644 --- a/source/libr2c2/timetable.h +++ b/source/libr2c2/timetable.h @@ -98,6 +98,7 @@ private: void update_route(); void event(TrainAI &, const Message &); void record_time(); + void clock_discontinuity(); }; } // namespace R2C2