From: Mikko Rasa Date: Tue, 12 Feb 2013 12:32:13 +0000 (+0200) Subject: Delay processing new trains until they are fully loaded X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=5c45baac3643a3c7ade8ab0dbaa97dfa55b5117d;p=r2c2.git Delay processing new trains until they are fully loaded --- diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index e5381bd..ba92933 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -181,6 +181,10 @@ void Engineer::tick() { window.get_display().tick(); + for(list::iterator i=new_trains.begin(); i!=new_trains.end(); ++i) + process_new_train(**i); + new_trains.clear(); + layout.tick(); event_disp.tick(Time::zero); @@ -392,7 +396,7 @@ Track *Engineer::pick_track(const Vector &p) return layout.pick_track(Vector(start.x, start.y, start.z), Vector(ray.x, ray.y, ray.z)); } -void Engineer::train_added(Train &train) +void Engineer::process_new_train(Train &train) { TrainPanel *tpanel = new TrainPanel(*this, train); root->add(*tpanel); @@ -402,6 +406,11 @@ void Engineer::train_added(Train &train) Vehicle3D &loco3d = layout_3d.get_vehicle(train.get_vehicle(0)); overlay->set_label(loco3d, train.get_name()); train.signal_name_changed.connect(sigc::bind<0>(sigc::mem_fun(overlay, &Overlay3D::set_label), sigc::ref(loco3d))); +} + +void Engineer::train_added(Train &train) +{ + new_trains.push_back(&train); GL::Color best_color; float best_d_sq = 0; diff --git a/source/engineer/engineer.h b/source/engineer/engineer.h index 2bb079d..72fdd29 100644 --- a/source/engineer/engineer.h +++ b/source/engineer/engineer.h @@ -50,6 +50,7 @@ private: Msp::GL::Mesh arrow_mesh; MainPanel *main_panel; + std::list new_trains; std::list train_panels; std::list train_views; Msp::Time::TimeStamp status_timeout; @@ -88,6 +89,7 @@ private: void block_reserved(const R2C2::Block &, const R2C2::Train *); R2C2::Track *pick_track(const R2C2::Vector &); void train_added(R2C2::Train &); + void process_new_train(R2C2::Train &); virtual void sighandler(int); };