X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftimetable.cpp;h=5fa36395825d0afdb6dfb92df83e76f97d3cd6cb;hb=d990c03a06a494ce3596862ce61e2a5684dea7e1;hp=7ce8127d433b7995a6b9ff91aa9f1f0f53909f60;hpb=b652dfb998dd416d26f909798e58964ef84eda11;p=r2c2.git diff --git a/source/libr2c2/timetable.cpp b/source/libr2c2/timetable.cpp index 7ce8127..5fa3639 100644 --- a/source/libr2c2/timetable.cpp +++ b/source/libr2c2/timetable.cpp @@ -116,7 +116,7 @@ void Timetable::save(list &st) const } } -void Timetable::check_update(list::const_iterator i) +void Timetable::check_update(const list::const_iterator &i) { for(list::const_iterator j=current_row; (j!=rows.end() && j!=i); ++j) if(j->type==ARRIVE) @@ -176,21 +176,19 @@ void Timetable::update_route() current_row = depart; for(list::const_iterator i=depart; i!=rows.end(); ++i) { - if(i->type==ARRIVE) - { - train.ai_message(Message("set-destination", i->target)); - break; - } - else if(i->type==DEPART) + if(i->type==DEPART) { Time::TimeDelta dt = i->time-clock.get_current_time(); while(dttarget, i->direction))); + if(i->type==ARRIVE) + break; } - else if(i->type==THROUGH) - train.ai_message(Message("add-waypoint", i->target)); } list::iterator next_depart = find_trip(arrive, 0); @@ -234,7 +232,8 @@ void Timetable::record_time() Timetable::Row::Row(): type(ARRIVE), - target(0) + target(0), + direction(TrackChain::UNSPECIFIED) { } void Timetable::Row::save(list &st) const @@ -242,6 +241,8 @@ void Timetable::Row::save(list &st) const st.push_back((DataFile::Statement("type"), type)); st.push_back((DataFile::Statement("time"), time.raw())); st.push_back(target->save_reference()); + if(direction) + st.push_back((DataFile::Statement("direction"), direction)); } @@ -266,9 +267,11 @@ Timetable::Row::Loader::Loader(Row &r, Layout &l): layout(l) { add("block", &Loader::block); + add("direction", &Row::direction); add("time", &Loader::time); add("type", &Row::type); add("zone", &Loader::zone); + add("zone", &Loader::zone_numbered); } void Timetable::Row::Loader::block(unsigned id) @@ -281,7 +284,12 @@ void Timetable::Row::Loader::time(Time::RawTime t) obj.time = Time::TimeDelta(t); } -void Timetable::Row::Loader::zone(const string &name, unsigned number) +void Timetable::Row::Loader::zone(const string &name) +{ + zone_numbered(name, 0); +} + +void Timetable::Row::Loader::zone_numbered(const string &name, unsigned number) { obj.target = &layout.get_zone(name, number); }