X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fvehicle.cpp;h=6615fb25b768cebf6c05003eb1e52fba5d2efcd2;hb=93c148ff88ba2c8266b44c336ba7ddd948010de7;hp=099644a1301ca8360101d894fec8c9d5c74a4fc3;hpb=b28062f2dc88e082ee5a28b2e1f7c4c8bd989023;p=r2c2.git diff --git a/source/libr2c2/vehicle.cpp b/source/libr2c2/vehicle.cpp index 099644a..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); @@ -175,7 +178,8 @@ void Vehicle::update_position(int sign) { OrientedPoint p = placement.get_point(); position = p.position; - position.z += layout.get_catalogue().get_rail_elevation(); + // TODO Move the z adjustment to VehiclePlacement + position.z += placement.get_position(VehiclePlacement::FRONT_AXLE)->get_type().get_appearance().get_rail_elevation(); rotation = p.rotation; tilt = p.tilt; @@ -355,10 +359,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; }