From: Mikko Rasa Date: Sat, 21 May 2011 11:20:40 +0000 (+0000) Subject: Add a vehicle property for swapping directions X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2d44923e135a119fde31a7a50e5fcd3e400e4f41;p=r2c2.git Add a vehicle property for swapping directions Add a BR E 03 loco from the package 37574 Add whistle function for BR E 41 --- diff --git a/locos.dat b/locos.dat index aa472db..d05b96f 100644 --- a/locos.dat +++ b/locos.dat @@ -306,6 +306,7 @@ vehicle 39410 locomotive true; function 0 "light"; function 3 "sfx"; + function 5 "whstl"; length 180; width 35; @@ -329,3 +330,36 @@ vehicle 39410 axle { position -18.5; wheel_diameter 14; powered true; object "bre41-axle.object"; }; }; }; + +vehicle \37574-01 +{ + name "BR E 03"; + locomotive true; + function 0 "light"; + function 2 "sfx"; + function 3 "whstl"; + swap_direction true; + + length 219; + width 35; + height 49; + + // XXX Create proper 3D model for this + object "br185-body.object"; + + bogie + { + position 62; + axle { position 17; wheel_diameter 14; powered true; }; + axle { position -8.5; wheel_diameter 14; powered true; }; + axle { position -34; wheel_diameter 14; powered true; }; + }; + + bogie + { + position -62; + axle { position 34; wheel_diameter 14; powered true; }; + axle { position 8.5; wheel_diameter 14; powered true; }; + axle { position -17; wheel_diameter 14; powered true; }; + }; +}; diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index ba1a861..415d491 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -588,7 +588,10 @@ void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt) if(controller->get_reverse()!=reverse) { reverse = controller->get_reverse(); - driver.set_loco_reverse(address, reverse); + bool r = reverse; + if(loco_type.get_swap_direction()) + r = !r; + driver.set_loco_reverse(address, r); release_blocks(cur_blocks_end, blocks.end()); reverse_blocks(blocks); @@ -715,8 +718,11 @@ void Train::loco_speed_event(unsigned addr, unsigned speed, bool rev) if(addr==address) { current_speed_step = speed; - if(rev!=reverse) - layout.get_driver().set_loco_reverse(address, reverse); + bool r = reverse; + if(loco_type.get_swap_direction()) + r = !r; + if(rev!=r) + layout.get_driver().set_loco_reverse(address, r); speed_changing = false; pure_speed = false; } diff --git a/source/libr2c2/vehicletype.cpp b/source/libr2c2/vehicletype.cpp index 52dc7b0..6c9d387 100644 --- a/source/libr2c2/vehicletype.cpp +++ b/source/libr2c2/vehicletype.cpp @@ -15,6 +15,7 @@ namespace R2C2 { VehicleType::VehicleType(const ArticleNumber &an): art_nr(an), locomotive(false), + swap_direction(false), length(0), width(0), height(0) @@ -119,6 +120,7 @@ VehicleType::Loader::Loader(VehicleType &vt): add("name", &VehicleType::name); add("object", &VehicleType::object); add("rod", &Loader::rod); + add("swap_direction", &VehicleType::swap_direction); add("width", &Loader::width); } diff --git a/source/libr2c2/vehicletype.h b/source/libr2c2/vehicletype.h index 461a3be..33d7d65 100644 --- a/source/libr2c2/vehicletype.h +++ b/source/libr2c2/vehicletype.h @@ -134,6 +134,7 @@ private: std::string name; bool locomotive; std::map functions; + bool swap_direction; float length; float width; float height; @@ -150,6 +151,7 @@ public: bool is_locomotive() const { return locomotive; } unsigned get_max_function() const; const std::map &get_functions() const { return functions; } + bool get_swap_direction() const { return swap_direction; } float get_length() const { return length; } float get_width() const { return width; } float get_height() const { return height; }