]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/vehicle.cpp
Add a generic link interface as well
[r2c2.git] / source / libr2c2 / vehicle.cpp
index 250aefd568064e2d3ee979d354af27626803587e..d1819a0fbe5c9e652b7a165970ab0d54bdd19cae 100644 (file)
@@ -398,6 +398,29 @@ TrackPoint Vehicle::get_point(const TrackPosition &pos, float tdist, float ratio
        return get_point(front.get_point().pos, back.get_point().pos, ratio);
 }
 
+unsigned Vehicle::get_n_link_slots() const
+{
+       return 2;
+}
+
+Vehicle *Vehicle::get_link(unsigned i) const
+{
+       if(i>=2)
+               throw out_of_range("Vehicle::get_link");
+
+       return (i==0 ? prev : next);
+}
+
+int Vehicle::get_link_slot(const Object &other) const
+{
+       if(&other==prev)
+               return 0;
+       else if(&other==next)
+               return 1;
+       else
+               return -1;
+}
+
 
 Vehicle::Axle::Axle(const VehicleType::Axle &t):
        type(&t),