X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Flibr2c2%2Fvehicletype.cpp;h=9f8814652770448aa1ae1dc84f5b4d542f4e167a;hb=4236c30c0a7a48854e9634e9ad7d8d6e0fd243a3;hp=7b355ac105230458f5a5856abfb7677d687cc1de;hpb=f8a7788cee0261babfc4c804a58515aad6dfbc3d;p=r2c2.git diff --git a/source/libr2c2/vehicletype.cpp b/source/libr2c2/vehicletype.cpp index 7b355ac..9f88146 100644 --- a/source/libr2c2/vehicletype.cpp +++ b/source/libr2c2/vehicletype.cpp @@ -1,10 +1,4 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - +#include #include "vehicletype.h" using namespace std; @@ -15,6 +9,7 @@ namespace R2C2 { VehicleType::VehicleType(const ArticleNumber &an): art_nr(an), locomotive(false), + swap_direction(false), length(0), width(0), height(0) @@ -27,7 +22,7 @@ unsigned VehicleType::get_max_function() const return (--functions.end())->first; } -const VehicleType::Axle &VehicleType::get_axle(unsigned i) const +const VehicleType::Axle &VehicleType::get_fixed_axle(unsigned i) const { if(i>=axles.size()) throw InvalidParameterValue("Axle index out of range"); @@ -119,6 +114,7 @@ VehicleType::Loader::Loader(VehicleType &vt): add("name", &VehicleType::name); add("object", &VehicleType::object); add("rod", &Loader::rod); + add("swap_direction", &VehicleType::swap_direction); add("width", &Loader::width); } @@ -228,10 +224,7 @@ VehicleType::Rod::Loader::Loader(Rod &r, const map &t): void VehicleType::Rod::Loader::connect(const string &t, float px, float pz, float ox, float oz) { - map::const_iterator i = tags.find(t); - if(i==tags.end()) - throw KeyError("Unknown rod tag", t); - obj.connect_index = i->second; + obj.connect_index = get_item(tags, t); obj.connect_point = Vector(px/1000, 0, pz/1000); obj.connect_offset = Vector(ox/1000, 0, oz/1000); } @@ -256,11 +249,8 @@ void VehicleType::Rod::Loader::pivot_bogie_axle(unsigned i, unsigned j) void VehicleType::Rod::Loader::pivot_rod(const string &t) { - map::const_iterator i = tags.find(t); - if(i==tags.end()) - throw KeyError("Unknown rod tag", t); + obj.pivot_index = get_item(tags, t); obj.pivot = ROD; - obj.pivot_index = i->second; } void VehicleType::Rod::Loader::position(float x, float y, float z)