]> git.tdb.fi Git - r2c2.git/commitdiff
Place vehicles on the track when attached
authorMikko Rasa <tdb@tdb.fi>
Fri, 1 Oct 2010 12:20:14 +0000 (12:20 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 1 Oct 2010 12:20:14 +0000 (12:20 +0000)
Fix Vehicle::attach_front to actually attach to the front
Initialize VehicleType::locomotive

source/libmarklin/vehicle.cpp
source/libmarklin/vehicletype.cpp

index d81848076c5984a26928873a49b13023785817d1..8761bb6f9f80bfc9a906da113ac3c7ff38adf8d7 100644 (file)
@@ -48,6 +48,9 @@ void Vehicle::attach_back(Vehicle &veh)
 
        next = &veh;
        veh.prev = this;
+
+       if(track_pos.track)
+               propagate_backward();
 }
 
 void Vehicle::attach_front(Vehicle &veh)
@@ -55,8 +58,11 @@ void Vehicle::attach_front(Vehicle &veh)
        if(prev || veh.next)
                throw InvalidState("Already attached");
 
-       next = &veh;
-       veh.prev = this;
+       prev = &veh;
+       veh.next = this;
+
+       if(prev->get_track())
+               prev->propagate_backward();
 }
 
 void Vehicle::detach_back()
index 937ce89cf28050601a0e19ef6c7fdd66186ff90d..c206108331e95bf05a7ae6bee035c342180fd51e 100644 (file)
@@ -14,6 +14,7 @@ namespace Marklin {
 
 VehicleType::VehicleType(unsigned n):
        art_nr(n),
+       locomotive(false),
        length(0),
        width(0),
        height(0)