]> git.tdb.fi Git - r2c2.git/commitdiff
Delay processing new trains until they are fully loaded
authorMikko Rasa <tdb@tdb.fi>
Tue, 12 Feb 2013 12:32:13 +0000 (14:32 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 12 Feb 2013 12:37:59 +0000 (14:37 +0200)
source/engineer/engineer.cpp
source/engineer/engineer.h

index e5381bd090a2f3bbf0e7e1179f4821637401727e..ba92933430ee013690ae1164b7da977c644cd640 100644 (file)
@@ -181,6 +181,10 @@ void Engineer::tick()
 {
        window.get_display().tick();
 
+       for(list<Train *>::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;
index 2bb079d62f3ab5c8c1d77ceab832294611f30bee..72fdd29c877fcd778f0a829c9fec6f51fd4a049e 100644 (file)
@@ -50,6 +50,7 @@ private:
        Msp::GL::Mesh arrow_mesh;
 
        MainPanel *main_panel;
+       std::list<R2C2::Train *> new_trains;
        std::list<TrainPanel *> train_panels;
        std::list<TrainView *> 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);
 };