]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/train.cpp
Add a maximum speed property for vehicle types
[r2c2.git] / source / libr2c2 / train.cpp
index bb82fe4c34090cf22b53f90cda41aa74478dcc01..845232fa4d9cf442fc5dddc692c5873291c35302 100644 (file)
@@ -161,6 +161,18 @@ float Train::get_quantized_speed() const
                return controller->get_speed();
 }
 
+float Train::get_maximum_speed() const
+{
+       float ms = 0;
+       for(vector<Vehicle *>::const_iterator i=vehicles.begin(); i!=vehicles.end(); ++i)
+       {
+               float vms = (*i)->get_type().get_maximum_speed();
+               if(ms<=0 || (vms>0 && vms<ms))
+                       ms = vms;
+       }
+       return ms;
+}
+
 bool Train::get_function(unsigned func) const
 {
        return (functions>>func)&1;