X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fvehicle.cpp;h=62671fccab1c95fdad2e811fe9c77bc5895884a0;hb=508ee4bfcc0f8fb1373fb7af251c59c873ef896f;hp=02fb1afce6d4c719367560d3dbf677e208b1c795;hpb=26a8dbeae14c685c6aef1aad3aa75c6f1a75e458;p=r2c2.git diff --git a/source/libr2c2/vehicle.cpp b/source/libr2c2/vehicle.cpp index 02fb1af..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); @@ -175,7 +179,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; @@ -247,7 +252,7 @@ void Vehicle::propagate_backward() void Vehicle::check_sensor(const TrackOffsetIter &t, unsigned &sensor, bool release) { - unsigned s = t->get_sensor_id(); + unsigned s = t->get_sensor_address(); if(s!=sensor) { unsigned old = sensor; @@ -355,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; }