]> git.tdb.fi Git - r2c2.git/commitdiff
Set vehicle position from reference if it has no track
authorMikko Rasa <tdb@tdb.fi>
Sat, 26 Jan 2013 20:30:19 +0000 (22:30 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 26 Jan 2013 20:30:19 +0000 (22:30 +0200)
This only became apparent when I happened to park a train near the origin
and the program went into an infinite loop while loading the layout.

source/libr2c2/vehicle.cpp

index 1699fd8eeef1cf0b89618cb806d3c6623aabc07b..4259c7dcde26a2b0a441210387bf4da011ef8a10 100644 (file)
@@ -200,7 +200,7 @@ void Vehicle::update_position_from(const Vehicle &veh)
        float margin = layout.get_catalogue().get_scale();
 
        float dist = distance(veh.position, position);
-       if(dist<tdist-margin || dist>tdist+margin)
+       if(!track_pos.track || dist<tdist-margin || dist>tdist+margin)
        {
                track_pos = veh.track_pos;
                track_pos.advance(sign*tdist);