From: Mikko Rasa Date: Thu, 20 Mar 2014 22:28:50 +0000 (+0200) Subject: Add a maximum speed property for vehicle types X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9eb22a66345301631994cf24a21af9375d07a172;p=r2c2.git Add a maximum speed property for vehicle types --- diff --git a/locos.dat b/locos.dat index 00f63a2..dd2ebfe 100644 --- a/locos.dat +++ b/locos.dat @@ -40,6 +40,7 @@ vehicle \29820-02 function 2 "telex"; function 3 "sfx"; function 5 "whst"; + maximum_speed 0.255; length 160; width 37; @@ -286,6 +287,7 @@ vehicle \29530-01 locomotive true; function 0 "light"; function 2 "telex"; + maximum_speed 0.255; length 144; width 33; @@ -314,6 +316,7 @@ vehicle \36850 name "BR 185"; locomotive true; function 0 "light"; + maximum_speed 0.447; length 218; width 34; @@ -342,6 +345,7 @@ vehicle \37225-02 name "BR 194"; locomotive true; function 0 "light"; + maximum_speed 0.287; length 212; width 34; @@ -376,6 +380,7 @@ vehicle \39410 function 0 "light"; function 3 "sfx"; function 5 "whstl"; + maximum_speed 0.383; length 180; width 35; @@ -408,6 +413,7 @@ vehicle \37574-01 function 2 "sfx"; function 3 "whstl"; swap_direction true; + maximum_speed 0.639; length 219; width 35; @@ -442,6 +448,7 @@ vehicle \37504 function 1 "intlt"; function 2 "sfx"; function 3 "whstl"; + maximum_speed 0.383; length 268; width 33; @@ -473,6 +480,7 @@ vehicle \37851 function 0 "light"; function 1 "telex"; function 3 "whstl"; + maximum_speed 0.319; length 224; width 35; @@ -503,6 +511,7 @@ vehicle \37968 function 0 "light"; function 2 "sfx"; function 3 "whstl"; + maximum_speed 0.160; length 203; width 35; diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index bb82fe4..845232f 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -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::const_iterator i=vehicles.begin(); i!=vehicles.end(); ++i) + { + float vms = (*i)->get_type().get_maximum_speed(); + if(ms<=0 || (vms>0 && vms>func)&1; diff --git a/source/libr2c2/train.h b/source/libr2c2/train.h index 16e67a4..9603891 100644 --- a/source/libr2c2/train.h +++ b/source/libr2c2/train.h @@ -97,6 +97,7 @@ public: float get_speed() const; float get_quantized_speed() const; unsigned get_speed_step() const { return current_speed_step; } + float get_maximum_speed() const; bool get_function(unsigned) const; unsigned get_functions() const { return functions; } diff --git a/source/libr2c2/vehicletype.cpp b/source/libr2c2/vehicletype.cpp index 7200b99..15733c3 100644 --- a/source/libr2c2/vehicletype.cpp +++ b/source/libr2c2/vehicletype.cpp @@ -17,7 +17,8 @@ VehicleType::VehicleType(const ArticleNumber &an): length(0), width(0), height(0), - rotate_object(false) + rotate_object(false), + max_speed(0) { } unsigned VehicleType::get_max_function() const @@ -109,6 +110,7 @@ VehicleType::Loader::Loader(VehicleType &vt): add("height", &Loader::height); add("length", &Loader::length); add("locomotive", &VehicleType::locomotive); + add("maximum_speed", &VehicleType::max_speed); add("mirror_rods", &Loader::mirror_rods); add("object", &VehicleType::object); add("rod", &Loader::rod); diff --git a/source/libr2c2/vehicletype.h b/source/libr2c2/vehicletype.h index a027915..e49a48f 100644 --- a/source/libr2c2/vehicletype.h +++ b/source/libr2c2/vehicletype.h @@ -175,6 +175,7 @@ private: RodArray rods; std::string object; bool rotate_object; + float max_speed; public: VehicleType(const ArticleNumber &); @@ -198,6 +199,7 @@ public: float get_back_axle_offset() const; const std::string &get_object() const { return object; } bool get_rotate_object() const { return rotate_object; } + float get_maximum_speed() const { return max_speed; } }; } // namespace R2C2