X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fvehicle.cpp;h=250aefd568064e2d3ee979d354af27626803587e;hb=f950f5a77714a155e57c868101911e181a617818;hp=4259c7dcde26a2b0a441210387bf4da011ef8a10;hpb=ac3bd4db7b4d639488e05dab7d8316182f5368c7;p=r2c2.git diff --git a/source/libr2c2/vehicle.cpp b/source/libr2c2/vehicle.cpp index 4259c7d..250aefd 100644 --- a/source/libr2c2/vehicle.cpp +++ b/source/libr2c2/vehicle.cpp @@ -14,11 +14,10 @@ using namespace Msp; namespace R2C2 { Vehicle::Vehicle(Layout &l, const VehicleType &t): - layout(l), + Object(l), type(t), next(0), prev(0), - direction(0), front_sensor(0), back_sensor(0) { @@ -38,6 +37,14 @@ Vehicle::~Vehicle() layout.remove_vehicle(*this); } +Vehicle *Vehicle::clone(Layout *to_layout) const +{ + Vehicle *veh = new Vehicle((to_layout ? *to_layout : layout), type); + veh->set_position(position); + veh->set_rotation(rotation); + return veh; +} + void Vehicle::attach_back(Vehicle &veh) { if(next || veh.prev) @@ -189,7 +196,7 @@ void Vehicle::update_position() position = tp.pos; position.z += layout.get_catalogue().get_rail_elevation(); - direction = tp.dir; + rotation = tp.dir; } void Vehicle::update_position_from(const Vehicle &veh)