From: Mikko Rasa Date: Sat, 3 May 2014 11:04:14 +0000 (+0300) Subject: Things with different gauges don't go together X-Git-Url: http://git.tdb.fi/?p=r2c2.git;a=commitdiff_plain;h=93c148ff88ba2c8266b44c336ba7ddd948010de7 Things with different gauges don't go together --- diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index 7b6bef1..f1fdd99 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -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; diff --git a/source/libr2c2/vehicle.cpp b/source/libr2c2/vehicle.cpp index cb776f4..6615fb2 100644 --- a/source/libr2c2/vehicle.cpp +++ b/source/libr2c2/vehicle.cpp @@ -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);