From: Mikko Rasa Date: Thu, 29 Jan 2015 16:50:52 +0000 (+0200) Subject: Ensure that Timetable has necessary helper AIs X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=76e277499fec494a96a1120692a1c6b4dc85ba60;p=r2c2.git Ensure that Timetable has necessary helper AIs Since AIControl and TrainRouter don't emit statements to the state file, they are not created automatically when loading the state. If they are missing, the timetable won't be able to operate. --- diff --git a/source/libr2c2/timetable.cpp b/source/libr2c2/timetable.cpp index 9608182..42414f6 100644 --- a/source/libr2c2/timetable.cpp +++ b/source/libr2c2/timetable.cpp @@ -1,8 +1,10 @@ #include +#include "aicontrol.h" #include "clock.h" #include "layout.h" #include "timetable.h" #include "train.h" +#include "trainrouter.h" #include "zone.h" using namespace std; @@ -15,6 +17,11 @@ Timetable::Timetable(Train &t): current_row(rows.end()), update_pending(false) { + if(!train.get_ai_of_type()) + new AIControl(train); + if(!train.get_ai_of_type()) + new TrainRouter(train); + train.signal_ai_event.connect(sigc::mem_fun(this, &Timetable::event)); }