]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/train.h
Prevent a crash if a layout file contains empty routes
[r2c2.git] / source / libmarklin / train.h
index e749a8336a09de542d0b6f0d3815b0f9437d121d..b891a660ac4e8ca381947421a7bc73c3c6b4397d 100644 (file)
@@ -18,6 +18,7 @@ namespace Marklin {
 class Locomotive;
 class Sensor;
 class TrafficManager;
+class Turnout;
 
 class Train: public sigc::trackable
 {
@@ -26,6 +27,8 @@ public:
        {
        public:
                Loader(Train &);
+       private:
+               void real_speed(unsigned, float, float);
        };
 
        sigc::signal<void, const std::string &> signal_name_changed;
@@ -41,6 +44,15 @@ private:
                BlockRef(Block *s, unsigned e): block(s), entry(e) { }
        };
 
+       struct RealSpeed
+       {
+               float speed;
+               float weight;
+
+               RealSpeed();
+               void add(float, float);
+       };
+
        TrafficManager &trfc_mgr;
        std::string name;
        Locomotive &loco;
@@ -54,8 +66,7 @@ private:
        float travel_dist;
        unsigned travel_speed;
        bool pure_speed;
-       float speed_scale;
-       float speed_scale_weight;
+       std::vector<RealSpeed> real_speed;
 
        Track *cur_track;
        unsigned cur_track_ep;
@@ -80,10 +91,12 @@ public:
 private:
        void locomotive_reverse_changed(bool);
        void sensor_event(bool, Sensor *);
-       void turnout_route_changing(unsigned, Turnout *);
-       void turnout_route_changed(unsigned, Turnout *);
+       void turnout_path_changing(unsigned, Turnout *);
+       void turnout_path_changed(unsigned, Turnout *);
        unsigned reserve_more();
        void update_speed();
+       float get_real_speed(unsigned) const;
+       unsigned find_speed(float) const;
        void set_status(const std::string &);
        void set_position(const Block::Endpoint &);
        void release_reserved_blocks();