]> git.tdb.fi Git - r2c2.git/commitdiff
Things with different gauges don't go together
authorMikko Rasa <tdb@tdb.fi>
Sat, 3 May 2014 11:04:14 +0000 (14:04 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 3 May 2014 11:04:14 +0000 (14:04 +0300)
source/libr2c2/track.cpp
source/libr2c2/vehicle.cpp

index 7b6bef1de2d7e914846f67ec1b8c5f8b4eadfd64..f1fdd992822180c26ddd5c39a6095bb8145516e4 100644 (file)
@@ -320,6 +320,10 @@ bool Track::link_to(Object &other)
        if(!otrack)
                return false;
 
+       float gauge_ratio = otrack->get_type().get_gauge()/type.get_gauge();
+       if(gauge_ratio<0.99 || gauge_ratio>1.01)
+               return false;
+
        float limit = type.get_gauge();
        if(!flex && !otrack->get_flex())
                limit /= 10;
index cb776f413daacb20f82889076aeab17e451cc842..6615fb25b768cebf6c05003eb1e52fba5d2efcd2 100644 (file)
@@ -106,6 +106,9 @@ void Vehicle::place(const TrackOffsetIter &t, VehiclePlacement::Anchor a)
 {
        if(!t)
                throw invalid_argument("Vehicle::place");
+       float gauge_ratio = t->get_type().get_gauge()/type.get_gauge();
+       if(gauge_ratio<0.99 || gauge_ratio>1.01)
+               throw logic_error("Incompatible gauge");
 
        placement.place(t, a);