X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fvehicle.cpp;h=62671fccab1c95fdad2e811fe9c77bc5895884a0;hb=91131237203bffe734219ab8b82b9d17f5d7a87d;hp=dee1e762239837164b7bdaed7b422e168eeff0be;hpb=d405b9943c888e3945c7ea4e496f9d300b114fe0;p=r2c2.git diff --git a/source/libr2c2/vehicle.cpp b/source/libr2c2/vehicle.cpp index dee1e76..62671fc 100644 --- a/source/libr2c2/vehicle.cpp +++ b/source/libr2c2/vehicle.cpp @@ -3,6 +3,7 @@ #include "driver.h" #include "layout.h" #include "track.h" +#include "trackappearance.h" #include "trackiter.h" #include "tracktype.h" #include "vehicle.h" @@ -106,6 +107,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); @@ -356,10 +360,10 @@ int Vehicle::get_link_slot(const Object &other) const return -1; } -bool Vehicle::collide_ray(const Ray &ray) const +bool Vehicle::collide_ray(const Ray &ray, float *d) const { if(is_placed()) - return Object::collide_ray(ray); + return Object::collide_ray(ray, d); else return false; }